]> Dogcows Code - chaz/openbox/commitdiff
Fix the EXTENTS reported on window frames.
authorDana Jansens <danakj@orodu.net>
Mon, 14 Jun 2010 16:15:02 +0000 (12:15 -0400)
committerDana Jansens <danakj@orodu.net>
Mon, 14 Jun 2010 16:40:15 +0000 (12:40 -0400)
Change the order things are done on map, so we apply startup state without
  any states set first, thus getting all the functions possible for the window
  type etc.  then change the order states are applied, as some remove the
  ability to apply others (ie fullscreen comes last).
Add an oldsize to ObFrame that remembers the size of the frame last reported to
  the world through the EXTENTS property.  If you frame_adjust_area(FAKE) then
  frame_adjust_area(NONFAKE), the EXTENTS would not be updated since the
  oldsize wasn't remembered across fake updates.
Make the extentsrequest test ask about windows with states set also.

openbox/client.c
openbox/frame.c
openbox/frame.h
tests/extentsrequest.c

index 4cba7f1127aa46d225910a0908284a6177ca065a..11982dcb6d88b4b2cb66931fca7b957314465e58 100644 (file)
@@ -245,11 +245,6 @@ void client_manage(Window window, ObPrompt *prompt)
        that needs to be freed with g_free(). */
     settings = client_get_settings_state(self);
 
-    /* now we have all of the window's information so we can set this up.
-       do this before creating the frame, so it can tell that we are still
-       mapping and doesn't go applying things right away */
-    client_setup_decor_and_functions(self, FALSE);
-
     /* specify that if we exit, the window should not be destroyed and
        should be reparented back to root automatically, unless we are managing
        an internal ObPrompt window  */
@@ -520,11 +515,11 @@ ObClient *client_fake_manage(Window window)
        uses too. this returns a shallow copy that needs to be freed */
     settings = client_get_settings_state(self);
 
-    client_setup_decor_and_functions(self, FALSE);
-
     /* create the decoration frame for the client window and adjust its size */
     self->frame = frame_new(self);
-    frame_adjust_area(self->frame, FALSE, TRUE, TRUE);
+
+    client_apply_startup_state(self, self->area.x, self->area.y,
+                               self->area.width, self->area.height);
 
     ob_debug("gave extents left %d right %d top %d bottom %d",
              self->frame->size.left, self->frame->size.right,
@@ -1103,9 +1098,16 @@ static void client_get_all(ObClient *self, gboolean real)
     client_get_mwm_hints(self);
     /* this can change the mwmhints for special cases */
     client_get_type_and_transientness(self);
-    client_get_state(self);
     client_update_normal_hints(self);
 
+    /* set up the decor/functions before getting the state.  the states may
+       affect which functions are available, but we want to know the maximum
+       decor/functions are available to this window, so we can then apply them
+       in client_apply_startup_state() */
+    client_setup_decor_and_functions(self, FALSE);
+
+    client_get_state(self);
+
     /* get the session related properties, these can change decorations
        from per-app settings */
     client_get_session_ids(self);
@@ -2734,8 +2736,6 @@ static void client_apply_startup_state(ObClient *self,
 
     if (iconic)
         client_iconify(self, TRUE, FALSE, TRUE);
-    if (fullscreen)
-        client_fullscreen(self, TRUE);
     if (undecorated)
         client_set_undecorated(self, TRUE);
     if (shaded)
@@ -2750,6 +2750,10 @@ static void client_apply_startup_state(ObClient *self,
     else if (max_horz)
         client_maximize(self, TRUE, 1);
 
+    /* fullscreen removes the ability to apply other states */
+    if (fullscreen)
+        client_fullscreen(self, TRUE);
+
     /* if the window hasn't been configured yet, then do so now, in fact the
        x,y,w,h may _not_ be the same as the area rect, which can end up
        meaning that the client isn't properly moved/resized by the fullscreen
index c6a47b0859ffee452ec7340e3ba1396088075d10..1623a83472d6938acac054959a09ece709febdde 100644 (file)
@@ -190,7 +190,7 @@ ObFrame *frame_new(ObClient *client)
 
     /* make sure the size will be different the first time, so the extent hints
        will be set */
-    STRUT_SET(self->size, -1, -1, -1, -1);
+    STRUT_SET(self->oldsize, -1, -1, -1, -1);
 
     set_theme_statics(self);
 
@@ -330,10 +330,6 @@ void frame_adjust_shape(ObFrame *self)
 void frame_adjust_area(ObFrame *self, gboolean moved,
                        gboolean resized, gboolean fake)
 {
-    Strut oldsize;
-
-    oldsize = self->size;
-
     if (resized) {
         /* do this before changing the frame's status like max_horz max_vert */
         frame_adjust_cursors(self);
@@ -849,7 +845,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             frame_adjust_shape(self);
         }
 
-        if (!STRUT_EQUAL(self->size, oldsize)) {
+        if (!STRUT_EQUAL(self->size, self->oldsize)) {
             gulong vals[4];
             vals[0] = self->size.left;
             vals[1] = self->size.right;
@@ -859,6 +855,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                             CARDINAL, vals, 4);
             OBT_PROP_SETA32(self->client->window, KDE_NET_WM_FRAME_STRUT,
                             CARDINAL, vals, 4);
+            self->oldsize = self->size;
         }
 
         /* if this occurs while we are focus cycling, the indicator needs to
index b0d996906bd47e908ca1001519745ad11c738822..0e28b9f1afc24f379fd06496ef8f99e494aac08f 100644 (file)
@@ -84,7 +84,8 @@ struct _ObFrame
 
     Window    window;
 
-    Strut     size;
+    Strut     size;    /* the size of the frame */
+    Strut     oldsize; /* the size of the frame last told to the client */
     Rect      area;
     gboolean  visible;
 
index 3fb0c7ac80ba1bec0dd68344bcd9fd47014aa323..055624d5d35468a64b7cb128773b9c6a95514770 100644 (file)
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
-int main () {
-  Display   *display;
-  Window     win;
-  XEvent     report;
-  Atom       _request, _extents, _type, _normal, _desktop;
+void request (Display *display, Atom _request, Atom _extents, Window win) {
   XEvent     msg;
-  int        x=10,y=10,h=100,w=400;
-
-  display = XOpenDisplay(NULL);
-
-  if (display == NULL) {
-    fprintf(stderr, "couldn't connect to X server :0\n");
-    return 0;
-  }
-
-  _type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
-  _normal = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
-  _desktop = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
-  _request = XInternAtom(display, "_NET_REQUEST_FRAME_EXTENTS", False);
-  _extents = XInternAtom(display, "_NET_FRAME_EXTENTS", False);
-
-  win = XCreateWindow(display, RootWindow(display, 0),
-                     x, y, w, h, 10, CopyFromParent, CopyFromParent,
-                     CopyFromParent, 0, NULL);
-  XSelectInput(display, win, PropertyChangeMask);
-
-  printf("requesting for type normal\n");
-  XChangeProperty(display, win, _type, XA_ATOM, 32,
-                  PropModeReplace, (unsigned char*)&_normal, 1);
   msg.xclient.type = ClientMessage;
   msg.xclient.message_type = _request;
   msg.xclient.display = display;
@@ -63,9 +36,12 @@ int main () {
   XSendEvent(display, RootWindow(display, 0), False,
              SubstructureNotifyMask | SubstructureRedirectMask, &msg);
   XFlush(display);
+}
 
-  printf("waiting for extents\n");
+void reply (Display* display, Atom _extents) {
+  printf("  waiting for extents\n");
   while (1) {
+    XEvent     report;
     XNextEvent(display, &report);
 
     if (report.type == PropertyNotify &&
@@ -75,57 +51,83 @@ int main () {
         int ret_format;
         unsigned long ret_items, ret_bytesleft;
         unsigned long *prop_return;
-        XGetWindowProperty(display, win, _extents, 0, 4,
+        XGetWindowProperty(display, report.xproperty.window, _extents, 0, 4,
                            False, XA_CARDINAL, &ret_type, &ret_format,
                            &ret_items, &ret_bytesleft,
                            (unsigned char**) &prop_return);
         if (ret_type == XA_CARDINAL && ret_format == 32 && ret_items == 4)
-            printf("got new extents %d, %d, %d, %d\n",
+            printf("  got new extents %d, %d, %d, %d\n",
                    prop_return[0], prop_return[1], prop_return[2],
                    prop_return[3]);
         break;
     }
   }
+}
 
-  printf("requesting for type desktop\n");
-  XChangeProperty(display, win, _type, XA_ATOM, 32,
-                  PropModeReplace, (unsigned char*)&_desktop, 1);
-  msg.xclient.type = ClientMessage;
-  msg.xclient.message_type = _request;
-  msg.xclient.display = display;
-  msg.xclient.window = win;
-  msg.xclient.format = 32;
-  msg.xclient.data.l[0] = 0l;
-  msg.xclient.data.l[1] = 0l;
-  msg.xclient.data.l[2] = 0l;
-  msg.xclient.data.l[3] = 0l;
-  msg.xclient.data.l[4] = 0l;
-  XSendEvent(display, RootWindow(display, 0), False,
-            SubstructureNotifyMask | SubstructureRedirectMask, &msg);
-  XFlush(display);
+int main () {
+  Display   *display;
+  Window     win;
+  Atom       _request, _extents, _type, _normal, _desktop, _state;
+  Atom       _state_fs, _state_mh, _state_mv;
+  int        x=10,y=10,h=100,w=400;
 
-  printf("waiting for extents\n");
-  while (1) {
-    XNextEvent(display, &report);
+  display = XOpenDisplay(NULL);
 
-    if (report.type == PropertyNotify &&
-        report.xproperty.atom == _extents)
-    {
-        Atom ret_type;
-        int ret_format;
-        unsigned long ret_items, ret_bytesleft;
-        unsigned long *prop_return;
-        XGetWindowProperty(display, win, _extents, 0, 4,
-                           False, XA_CARDINAL, &ret_type, &ret_format,
-                           &ret_items, &ret_bytesleft,
-                           (unsigned char**) &prop_return);
-        if (ret_type == XA_CARDINAL && ret_format == 32 && ret_items == 4)
-            printf("got new extents %d, %d, %d, %d\n",
-                   prop_return[0], prop_return[1], prop_return[2],
-                   prop_return[3]);
-        break;
-    }
+  if (display == NULL) {
+    fprintf(stderr, "couldn't connect to X server :0\n");
+    return 0;
   }
 
+  _type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
+  _normal = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
+  _desktop = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
+  _request = XInternAtom(display, "_NET_REQUEST_FRAME_EXTENTS", False);
+  _extents = XInternAtom(display, "_NET_FRAME_EXTENTS", False);
+  _state = XInternAtom(display, "_NET_WM_STATE", False);
+  _state_fs = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
+  _state_mh = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+  _state_mv = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+
+  win = XCreateWindow(display, RootWindow(display, 0),
+                     x, y, w, h, 10, CopyFromParent, CopyFromParent,
+                     CopyFromParent, 0, NULL);
+  XSelectInput(display, win, PropertyChangeMask);
+
+  printf("requesting for type normal\n");
+  XChangeProperty(display, win, _type, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_normal, 1);
+  request(display, _request, _extents, win);
+  reply(display, _extents);
+
+  printf("requesting for type normal+fullscreen\n");
+  XChangeProperty(display, win, _type, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_normal, 1);
+  XChangeProperty(display, win, _state, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_state_fs, 1);
+  request(display, _request, _extents, win);
+  reply(display, _extents);
+
+  printf("requesting for type normal+maxv\n");
+  XChangeProperty(display, win, _type, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_normal, 1);
+  XChangeProperty(display, win, _state, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_state_mv, 1);
+  request(display, _request, _extents, win);
+  reply(display, _extents);
+
+  printf("requesting for type normal+maxh\n");
+  XChangeProperty(display, win, _type, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_normal, 1);
+  XChangeProperty(display, win, _state, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_state_mh, 1);
+  request(display, _request, _extents, win);
+  reply(display, _extents);
+
+  printf("requesting for type desktop\n");
+  XChangeProperty(display, win, _type, XA_ATOM, 32,
+                  PropModeReplace, (unsigned char*)&_desktop, 1);
+  request(display, _request, _extents, win);
+  reply(display, _extents);
+
   return 1;
 }
This page took 0.034004 seconds and 4 git commands to generate.