From 70a2e7923c03c4a34bbb7504ca6b2c2b325f99d6 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Wed, 29 Apr 2015 12:54:36 +0300 Subject: [PATCH] 8051617: Fullscreen mode is not working properly on Xorg Reviewed-by: alexsch, serb --- .../classes/sun/awt/X11ComponentPeer.java | 1 + .../classes/sun/awt/X11GraphicsDevice.java | 10 ++--- .../native/libawt_xawt/awt/awt_GraphicsEnv.c | 38 +++---------------- 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11ComponentPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11ComponentPeer.java index 68839725026..35623a67b8c 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11ComponentPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11ComponentPeer.java @@ -32,6 +32,7 @@ import sun.java2d.SurfaceData; import java.awt.Graphics; public interface X11ComponentPeer { + long getWindow(); long getContentWindow(); SurfaceData getSurfaceData(); GraphicsConfiguration getGraphicsConfiguration(); diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index 3307ada3415..98a8d510e98 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -299,11 +299,7 @@ public class X11GraphicsDevice @Override public boolean isFullScreenSupported() { - // REMIND: for now we will only allow fullscreen exclusive mode - // on the primary screen; we could change this behavior slightly - // in the future by allowing only one screen to be in fullscreen - // exclusive mode at any given time... - boolean fsAvailable = (screen == 0) && isXrandrExtensionSupported(); + boolean fsAvailable = isXrandrExtensionSupported(); if (fsAvailable) { SecurityManager security = System.getSecurityManager(); if (security != null) { @@ -329,7 +325,7 @@ public class X11GraphicsDevice private static void enterFullScreenExclusive(Window w) { X11ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(w); if (peer != null) { - enterFullScreenExclusive(peer.getContentWindow()); + enterFullScreenExclusive(peer.getWindow()); peer.setFullScreenExclusiveModeState(true); } } @@ -338,7 +334,7 @@ public class X11GraphicsDevice X11ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(w); if (peer != null) { peer.setFullScreenExclusiveModeState(false); - exitFullScreenExclusive(peer.getContentWindow()); + exitFullScreenExclusive(peer.getWindow()); } } diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 0e2d15d0466..1a20b404ad0 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -1716,9 +1716,9 @@ X11GD_InitXrandrFuncs(JNIEnv *env) /* * REMIND: Fullscreen mode doesn't work quite right with multi-monitor - * setups and RANDR 1.2. So for now we also require a single screen. + * setups and RANDR 1.2. */ - if (awt_numScreens > 1 ) { + if ((rr_maj_ver == 1 && rr_min_ver <= 2) && awt_numScreens > 1) { J2dRlsTraceLn(J2D_TRACE_INFO, "X11GD_InitXrandrFuncs: Can't use Xrandr. " "Multiple screens in use"); dlclose(pLibRandR); @@ -1806,40 +1806,14 @@ X11GD_SetFullscreenMode(Window win, jboolean enabled) Atom wmState = XInternAtom(awt_display, "_NET_WM_STATE", False); Atom wmStateFs = XInternAtom(awt_display, "_NET_WM_STATE_FULLSCREEN", False); - Window root, parent, *children = NULL; - unsigned int numchildren; + XWindowAttributes attr; XEvent event; - Status status; - if (wmState == None || wmStateFs == None) { + if (wmState == None || wmStateFs == None + || !XGetWindowAttributes(awt_display, win, &attr)) { return; } - /* - * Note: the Window passed to this method is typically the "content - * window" of the top-level, but we need the actual shell window for - * the purposes of constructing the XEvent. Therefore, we walk up the - * window hierarchy here to find the true top-level. - */ - do { - if (!XQueryTree(awt_display, win, - &root, &parent, - &children, &numchildren)) - { - return; - } - - if (children != NULL) { - XFree(children); - } - - if (parent == root) { - break; - } - - win = parent; - } while (root != parent); - memset(&event, 0, sizeof(event)); event.xclient.type = ClientMessage; event.xclient.message_type = wmState; @@ -1849,7 +1823,7 @@ X11GD_SetFullscreenMode(Window win, jboolean enabled) event.xclient.data.l[0] = enabled ? 1 : 0; // 1==add, 0==remove event.xclient.data.l[1] = wmStateFs; - XSendEvent(awt_display, root, False, + XSendEvent(awt_display, attr.root, False, SubstructureRedirectMask | SubstructureNotifyMask, &event); XSync(awt_display, False);