Re: [AD] RFC - Linux WM Fullscreen Patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Here's another patch. There are 4 lines added besides the new file.
On 14-08-07 01:46 PM, Trent Gamblin wrote:
The information I was given by someone here before was that the "WM
Fullscreen" ie ALLEGRO_FULLSCREEN_VIRTUAL mode would be scaled up but it
wold be all done without the user having to worry about it and behave
exactly like ALLEGRO_FULLSCREEN otherwise.
In actuality, as I learned today, it's almost identical to
ALLEGRO_FULLSCREEN. The only difference is, some WM flags are set when
supported. The reason we didn't combine ALLEGRO_FULLSCREEN and
ALLEGRO_FULLSCREEN_VIRTUAL before was that someone said the scaling would be
a problem on certain hardware ie they needed it to be exactly like a
hardware fullscreen mode. However, I found out today that it is exactly the
same as a real hardware fullscreen mode.
So IMO the best thing to do is to remove the ALLEGRO_FULLSCREEN_VIRTUAL flag
and use the code paths I just added all the time (they check for support
first.) I don't see any drawback of doing it that way, in fact SDL does the
same thing, so if anyone has legitimate objections bring them up now.
----- Original Message -----
From: "SiegeLordEx" <slabode@xxxxxxxxxx>
To: <alleg-developers@xxxxxxxxxx>
Sent: Thursday, August 07, 2014 1:16 PM
Subject: Re: [AD] RFC - Linux WM Fullscreen Patch
On 08/07/2014 02:58 PM, Trent Gamblin wrote:
Looked at SDL closer - it behaves differently than I was told. It
doesn't scale at all, it uses the window manager to go fullscreen and
then xrandr/xvidmode to change the mode. Better for us, I did the same
and the patch is a ton simpler now.
I'd like to propose changing ALLEGRO_FULLSCREEN_WINDOW so that it
implies ALLEGRO_FULLSCREEN as well. That'll require a few changed checks
here and there but not as bad as making ALLEGRO_FULLSCREEN separate from
ALLEGRO_FULLSCREEN_WINDOW and ALLEGRO_FULLSCREEN_VIRTUAL. IMO it should
have been that way from the start, as a modifier.
What does this implication mean exactly? Will you be able to do
mode-setting via ALLEGRO_FULLSCREEN_WINDOW? I note the patch doesn't
seem to do that...
This wasn't really clear from the fullscreen thread earlier either...
what are the use cases for the 3 separate FULLSCREEN options? In the
current system, you use ALLEGRO_FULLSCREEN for performance (i.e. want
direct access and/or don't want to have a buffer bitmap + scaling) with
the caveat that it doesn't work well on modern monitors and
ALLEGRO_FULLSCREEN_WINDOW otherwise (i.e. most of the time). Does the
current plan change that reasoning? If the scaling idea is (at least
temporarily) abandoned, what is the use case for
ALLEGRO_FULLSCREEN_VIRTUAL?
Is there no way for ALLEGRO_FULLSCREEN_WINDOW and
ALLEGRO_FULLSCREEN_VIRTUAL to be combined?
-SL
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
diff --git a/cmake/FileList.cmake b/cmake/FileList.cmake
index ede9c57..007dddd 100644
--- a/cmake/FileList.cmake
+++ b/cmake/FileList.cmake
@@ -114,6 +114,7 @@ set(ALLEGRO_SRC_X_FILES
src/x/xrandr.c
src/x/xsystem.c
src/x/xwindow.c
+ src/x/xwmfullscreen.c
src/linux/lhaptic.c
src/linux/ljoynu.c
)
diff --git a/include/allegro5/internal/aintern_xdisplay.h b/include/allegro5/internal/aintern_xdisplay.h
index a8e616d..d353376 100644
--- a/include/allegro5/internal/aintern_xdisplay.h
+++ b/include/allegro5/internal/aintern_xdisplay.h
@@ -92,6 +92,8 @@ struct ALLEGRO_XWIN_DISPLAY_OVERRIDABLE_INTERFACE
bool _al_xwin_set_gtk_display_overridable_interface(uint32_t check_version,
const ALLEGRO_XWIN_DISPLAY_OVERRIDABLE_INTERFACE *vt);
+bool x_try_fullscreen_via_netwm(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d);
+
#endif /* !ALLEGRO_RASPBERRYPI */
#endif
diff --git a/src/x/xfullscreen.c b/src/x/xfullscreen.c
index 0651e46..1e35b53 100644
--- a/src/x/xfullscreen.c
+++ b/src/x/xfullscreen.c
@@ -364,7 +364,9 @@ static bool xfvm_set_mode(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, int w
{
int mode_idx = -1;
int adapter = _al_xglx_get_adapter(s, d, false);
-
+
+ x_try_fullscreen_via_netwm(s, d);
+
#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
/* TwinView workarounds, nothing to do here, since we can't really change or restore modes */
if (s->xinerama_available && s->xinerama_screen_count != s->xfvm_screen_count) {
diff --git a/src/x/xrandr.c b/src/x/xrandr.c
index 36f3857..201b018 100644
--- a/src/x/xrandr.c
+++ b/src/x/xrandr.c
@@ -503,7 +503,9 @@ static bool xrandr_set_mode(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, int
{
int adapter = _al_xglx_get_adapter(s, d, false);
int xscreen = _al_xglx_get_xscreen(s, adapter);
-
+
+ x_try_fullscreen_via_netwm(s, d);
+
xrandr_screen *screen = _al_vector_ref(&s->xrandr_screens, xscreen);
xrandr_crtc *crtc = xrandr_map_to_crtc(s, xscreen, adapter);
diff --git a/src/x/xwmfullscreen.c b/src/x/xwmfullscreen.c
index a497b87..b03e023 100644
--- a/src/x/xwmfullscreen.c
+++ b/src/x/xwmfullscreen.c
@@ -14,48 +14,9 @@ ALLEGRO_DEBUG_CHANNEL("display")
#define _NET_WM_STATE_ADD 1l
#define _NET_WM_STATE_TOGGLE 2l
-/* The following code uses the window manager to set a fullscreen mode when supported */
+#define GET_ATOM(X) XInternAtom(display, #X, False)
-bool x_set_fullscreen_via_net_wm(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d)
-{
- Display *display = s->x11display;
-#define GET_ATOM(X) X = XInternAtom(display, #X, False)
- Atom _NET_WM_STATE = GET_ATOM(_NET_WM_STATE);
- Atom _NET_WM_STATE_FULLSCREEN = GET_ATOM(_NET_WM_STATE_FULLSCREEN);
-#undef GET_ATOM
-
- XEvent e;
-
- /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we
- can be resized to the fullscreen resolution (or reset so we're not resizable again) */
- XSizeHints *sizehints = XAllocSizeHints();
- long flags = 0;
-
- XGetWMNormalHints(display, d->window, sizehints, &flags);
- /* set the resize flags on */
- /* we are going fullscreen so turn the flags off */
- sizehints->flags &= ~(PMinSize | PMaxSize);
- XSetWMNormalHints(display, d->window, sizehints);
- XFree(sizehints);
-
- memset(&e, 0, sizeof(e));
- e.xany.type = ClientMessage;
- e.xclient.message_type = _NET_WM_STATE;
- e.xclient.format = 32;
- e.xclient.window = d->window;
- e.xclient.data.l[0] =_NET_WM_STATE_ADD;
- e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
- e.xclient.data.l[3] = 0l;
-
- XSendEvent(display, RootWindow(display, DefaultScreen(display)), 0,
- SubstructureNotifyMask | SubstructureRedirectMask, &e);
-
- XFlush(display);
-
- return true;
-}
-
-bool x_have_net_supporting_wm(Display *display)
+static bool have_net_supporting_wm(Display *display)
{
Atom _NET_SUPPORTING_WM_CHECK;
int status, real_format;
@@ -98,3 +59,31 @@ bool x_have_net_supporting_wm(Display *display)
return true;
}
+bool x_try_fullscreen_via_netwm(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d)
+{
+ Display *display = s->x11display;
+ Atom _NET_WM_STATE = GET_ATOM(_NET_WM_STATE);
+ Atom _NET_WM_STATE_FULLSCREEN = GET_ATOM(_NET_WM_STATE_FULLSCREEN);
+
+ if (!have_net_supporting_wm(s->x11display)) {
+ return false;
+ }
+
+ Atom _NET_WM_STATE_MAXIMIZED_VERT = GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
+ Atom _NET_WM_STATE_MAXIMIZED_HORZ = GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
+ Atom _NET_WM_STATE_FOCUSED = GET_ATOM(_NET_WM_STATE_FOCUSED);
+
+ Atom atoms[4];
+
+ atoms[0] = _NET_WM_STATE_MAXIMIZED_VERT;
+ atoms[1] = _NET_WM_STATE_MAXIMIZED_HORZ;
+ atoms[2] = _NET_WM_STATE_FULLSCREEN;
+ atoms[3] = _NET_WM_STATE_FOCUSED;
+
+ XChangeProperty(display, d->window, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, 4);
+
+ XFlush(display);
+
+ return true;
+}
+