summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llwindow/llwindowsdl.cpp161
1 files changed, 159 insertions, 2 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index fe0ada5b09..cb4e04511c 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -950,7 +950,68 @@ BOOL LLWindowSDL::getMaximized()
if (mWindow)
{
- // TODO
+#if LL_X11
+ if (mSDL_Display)
+ {
+ maybe_lock_display();
+
+ // Return data in the specified format, XA_ATOM.
+ U8* prop;
+ // Actual format of the property.
+ int format;
+ // Actual number of items stored in the prop return data.
+ unsigned long nitems;
+ // Number of bytes remaining to be read in the property if a partial read was performed.
+ unsigned long bytes_after;
+ // Atom identifier that defines the actual type of the property.
+ Atom type;
+
+ // Atom used to obtain list of hints describing the window state.
+ Atom wm_state = XInternAtom(mSDL_Display, "_NET_WM_STATE", False);
+
+ // Atoms indicates that the window is vertically/horizontally maximized.
+ Atom max_vert = XInternAtom(mSDL_Display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+ Atom max_horz = XInternAtom(mSDL_Display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+
+ // How many atoms in which we interested are present in list of hints.
+ U32 pass = 0;
+
+ do
+ {
+ nitems = 0;
+ bytes_after = 0;
+ type = None;
+ if ( (XGetWindowProperty (mSDL_Display,
+ mSDL_XWindowID,
+ wm_state,
+ 0, UINT_MAX,
+ False, XA_ATOM,
+ &type, &format,
+ &nitems, &bytes_after,
+ &prop) == Success)
+ && type != None )
+ {
+ Atom *atoms = (Atom *)prop;
+ for (unsigned long i=0; i<nitems; ++i)
+ {
+ if (atoms[i] == max_horz)
+ ++pass;
+ else if (atoms[i] == max_vert)
+ ++pass;
+ }
+ XFree (atoms);
+ }
+ else
+ {
+ break;
+ }
+ } while (bytes_after > 0);
+
+ result = (pass == 2);
+
+ maybe_unlock_display();
+ }
+#endif // LL_X11
}
return(result);
@@ -958,7 +1019,103 @@ BOOL LLWindowSDL::getMaximized()
BOOL LLWindowSDL::maximize()
{
- // TODO
+#if LL_X11
+ if (mSDL_Display && !mFullscreen)
+ {
+ maybe_lock_display();
+
+ BOOL is_maximize_allowed = FALSE;
+
+ // Check if maximize is allowed
+ {
+ // Return data in the specified format, XA_ATOM.
+ U8* prop;
+ // Actual format of the property.
+ int format;
+ // Actual number of items stored in the prop return data.
+ unsigned long nitems;
+ // Number of bytes remaining to be read in the property if a partial read was performed.
+ unsigned long bytes_after;
+ // Atom identifier that defines the actual type of the property.
+ Atom type;
+
+ // Atom used to obtain a list of atoms indicating user operations that the Window Manager supports for this window.
+ Atom allowed_act = XInternAtom(mSDL_Display, "_NET_WM_ALLOWED_ACTIONS", False);
+
+ // Atoms that indicates that the window may be vertically/horizontally maximized.
+ Atom max_vert_act = XInternAtom(mSDL_Display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False);
+ Atom max_horz_act = XInternAtom(mSDL_Display, "_NET_WM_ACTION_MAXIMIZE_VERT", False);
+
+ // How many atoms in which we interested are present in list of hints.
+ U32 pass = 0;
+
+ do
+ {
+ nitems = 0;
+ bytes_after = 0;
+ type = None;
+ if ( (XGetWindowProperty (mSDL_Display,
+ mSDL_XWindowID,
+ allowed_act,
+ 0, UINT_MAX,
+ False, XA_ATOM,
+ &type, &format,
+ &nitems, &bytes_after,
+ &prop) == Success)
+ && type != None )
+ {
+ Atom *atoms = (Atom *)prop;
+ for (unsigned long i=0; i<nitems; ++i)
+ {
+ if (atoms[i] == max_vert_act)
+ ++pass;
+ else if (atoms[i] == max_horz_act)
+ ++pass;
+ }
+ XFree (atoms);
+ }
+ else
+ {
+ break;
+ }
+ } while (bytes_after > 0);
+
+ is_maximize_allowed = (pass == 2);
+ }
+
+ // Send maximize event to X11 system
+ if (is_maximize_allowed)
+ {
+ XEvent xev;
+
+ // Atom describing the window state.
+ Atom wm_state = XInternAtom(mSDL_Display, "_NET_WM_STATE", False);
+
+ // Atoms indicates that the window is vertically/horizontally maximized.
+ Atom max_vert = XInternAtom(mSDL_Display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+ Atom max_horz = XInternAtom(mSDL_Display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = mSDL_XWindowID;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1; // add/set property
+ xev.xclient.data.l[1] = max_vert;
+ xev.xclient.data.l[2] = max_horz;
+ xev.xclient.data.l[3] = 0;
+ xev.xclient.data.l[4] = 0;
+
+ XSendEvent(mSDL_Display,
+ DefaultRootWindow(mSDL_Display),
+ False,
+ SubstructureNotifyMask, &xev);
+ }
+
+ maybe_unlock_display();
+ return is_maximize_allowed;
+ }
+#endif // LL_X11
return FALSE;
}