Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X11 present #989

Merged
merged 13 commits into from
Jun 30, 2020
Prev Previous commit
Next Next commit
Add an environment variable for testing.
  • Loading branch information
jneem committed Jun 21, 2020
commit 4175a2dba953e8d479d245da7096cb071d364366
17 changes: 12 additions & 5 deletions druid-shell/src/platform/x11/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ impl Application {
quitting: false,
windows: HashMap::new(),
}));
let present_opcode = match Application::query_present_opcode(&connection) {
Ok(p) => p,
Err(e) => {
log::info!("failed to find Present extension: {}", e);
None

let present_opcode = if std::env::var_os("DRUID_SHELL_DISABLE_X11_PRESENT").is_some() {
jneem marked this conversation as resolved.
Show resolved Hide resolved
// Allow disabling Present with an environment variable.
None
} else {
match Application::query_present_opcode(&connection) {
Ok(p) => p,
Err(e) => {
log::info!("failed to find Present extension: {}", e);
None
}
}
};

Ok(Application {
connection,
screen_num: screen_num as i32,
Expand Down
2 changes: 2 additions & 0 deletions druid-shell/src/platform/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ impl Window {
// We aren't using the present extension, so fall back to sleeping for scheduling
// redraws. Sleeping is a terrible way to schedule redraws, but hopefully we don't
// have to fall back to this very often.
// TODO: once we have an idle handler, we should use that. Sleeping causes lots of
// problems when windows are dragged to resize.
jneem marked this conversation as resolved.
Show resolved Hide resolved
if anim && self.refresh_rate.is_some() {
let sleep_amount_ms = (1000.0 / self.refresh_rate.unwrap()) as u64;
std::thread::sleep(std::time::Duration::from_millis(sleep_amount_ms));
Expand Down