diff options
Diffstat (limited to 'ui/gfx/gl/gl_context_linux.cc')
-rw-r--r-- | ui/gfx/gl/gl_context_linux.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ui/gfx/gl/gl_context_linux.cc b/ui/gfx/gl/gl_context_linux.cc index 36f0e8a..bf0b75e 100644 --- a/ui/gfx/gl/gl_context_linux.cc +++ b/ui/gfx/gl/gl_context_linux.cc @@ -37,6 +37,19 @@ Display* GetXDisplayHelper() { return display; } +bool IsCompositingWindowManagerActive(Display* display) { + // The X macro "None" has been undefined by gl_bindings.h. + const int kNone = 0; + static Atom net_wm_cm_s0 = kNone; + if (net_wm_cm_s0 == kNone) { + net_wm_cm_s0 = XInternAtom(display, "_NET_WM_CM_S0", True); + } + if (net_wm_cm_s0 == kNone) { + return false; + } + return XGetSelectionOwner(display, net_wm_cm_s0) != kNone; +} + } // namespace namespace gfx { @@ -335,7 +348,13 @@ void ViewGLContext::SetSwapInterval(int interval) { DCHECK(IsCurrent()); if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { Display* display = GetXDisplayHelper(); - glXSwapIntervalEXT(display, window_, interval); + // Only enable vsync if we aren't using a compositing window + // manager. At the moment, compositing window managers don't + // respect this setting anyway (tearing still occurs) and it + // dramatically increases latency. + if (!IsCompositingWindowManagerActive(display)) { + glXSwapIntervalEXT(display, window_, interval); + } } } |