]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
base rudeness on if they have a strut or not
[chaz/openbox] / openbox / client.c
index b31c939cd45585d2fc0e9e10495db9d2de245e20..e0dc3f876761e0e8e67e7a670241cfd4e6a38949 100644 (file)
@@ -300,7 +300,9 @@ void client_manage(Window window)
     dispatch_client(Event_Client_New, self, 0, 0);
 
     /* make sure the window is visible */
-    client_move_onscreen(self);
+    if (!(self->strut.left || self->strut.right ||
+          self->strut.top || self->strut.bottom))
+        client_move_onscreen(self, TRUE);
 
     screen_update_areas();
 
@@ -425,8 +427,8 @@ void client_unmanage(ObClient *self)
     if (ob_state() != OB_STATE_EXITING) {
        /* these values should not be persisted across a window
           unmapping/mapping */
-       prop_erase(self->window, prop_atoms.net_wm_desktop);
-       prop_erase(self->window, prop_atoms.net_wm_state);
+       PROP_ERASE(self->window, net_wm_desktop);
+       PROP_ERASE(self->window, net_wm_state);
     } else {
        /* if we're left in an iconic state, the client wont be mapped. this is
           bad, since we will no longer be managing the window on restart */
@@ -454,27 +456,61 @@ void client_unmanage(ObClient *self)
     client_set_list();
 }
 
-void client_move_onscreen(ObClient *self)
+void client_move_onscreen(ObClient *self, gboolean rude)
+{
+    int x = self->area.x;
+    int y = self->area.y;
+    if (client_find_onscreen(self, &x, &y,
+                             self->area.width, self->area.height, rude)) {
+        client_configure(self, OB_CORNER_TOPLEFT, x, y,
+                         self->area.width, self->area.height,
+                         TRUE, TRUE);
+    }
+}
+
+gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h,
+                              gboolean rude)
 {
     Rect *a;
-    int x = self->frame->area.x, y = self->frame->area.y;
+    int ox = *x, oy = *y;
+
+    frame_client_gravity(self->frame, x, y); /* get where the frame
+                                                would be */
 
     /* XXX watch for xinerama dead areas */
+
     a = screen_area(self->desktop);
-    if (x >= a->x + a->width - 1)
-        x = a->x + a->width - self->frame->area.width;
-    if (y >= a->y + a->height - 1)
-        y = a->y + a->height - self->frame->area.height;
-    if (x + self->frame->area.width - 1 < a->x)
-        x = a->x;
-    if (y + self->frame->area.height - 1< a->y)
-        y = a->y;
-
-    frame_frame_gravity(self->frame, &x, &y); /* get where the client
-                                                 should be */
-    client_configure(self, OB_CORNER_TOPLEFT, x, y,
-                     self->area.width, self->area.height,
-                     TRUE, TRUE);
+    if (*x >= a->x + a->width - 1)
+        *x = a->x + a->width - self->frame->area.width;
+    if (*y >= a->y + a->height - 1)
+        *y = a->y + a->height - self->frame->area.height;
+    if (*x + self->frame->area.width - 1 < a->x)
+        *x = a->x;
+    if (*y + self->frame->area.height - 1 < a->y)
+        *y = a->y;
+
+    if (rude) {
+        /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good.
+           Java can suck it too. */
+
+        /* dont let windows map/move into the strut unless they
+           are bigger than the available area */
+        if (w <= a->width) {
+            if (*x < a->x) *x = a->x;
+            if (*x + w > a->x + a->width)
+                *x = a->x + a->width - w;
+        }
+        if (h <= a->height) {
+            if (*y < a->y) *y = a->y;
+            if (*y + h > a->y + a->height)
+                *y = a->y + a->height - h;
+        }
+    }
+
+    frame_frame_gravity(self->frame, x, y); /* get where the client
+                                               should be */
+
+    return ox != *x || oy != *y;
 }
 
 static void client_toggle_border(ObClient *self, gboolean show)
@@ -891,7 +927,7 @@ void client_update_normal_hints(ObClient *self)
 
     /* get the hints from the window */
     if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) {
-       self->positioned = !!(size.flags & (PPosition|USPosition));
+        self->positioned = !!(size.flags & (PPosition|USPosition));
 
        if (size.flags & PWinGravity) {
            self->gravity = size.win_gravity;
@@ -1312,8 +1348,11 @@ void client_update_strut(ObClient *self)
     if (!PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
        STRUT_SET(self->strut, 0, 0, 0, 0);
     } else {
-        if (num == 4)
+        if (num == 4) {
+            g_message("new strut: %d %d %d %d",
+                      data[0], data[2], data[1], data[3]);
             STRUT_SET(self->strut, data[0], data[2], data[1], data[3]);
+        }
         else
             STRUT_SET(self->strut, 0, 0, 0, 0);
        g_free(data);
@@ -2635,3 +2674,16 @@ ObClient *client_search_top_transient(ObClient *self)
 
     return self;
 }
+
+ObClient *client_search_transient(ObClient *self, ObClient *search)
+{
+    GSList *sit;
+
+    for (sit = self->transients; sit; sit = g_slist_next(sit)) {
+        if (sit->data == search)
+            return search;
+        if (client_search_transient(sit->data, search))
+            return search;
+    }
+    return NULL;
+}
This page took 0.02396 seconds and 4 git commands to generate.