]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
break focus. or maybe make it better.
[chaz/openbox] / openbox / client.c
index 23348d510981088eeeb7de8b80a86725b6584490..83291132a14535917763ad0c622b6f743e566fcb 100644 (file)
@@ -461,6 +461,7 @@ void client_unmanage(ObClient *self)
     g_free(self->name);
     g_free(self->class);
     g_free(self->role);
+    g_free(self->sm_client_id);
     g_free(self);
      
     /* update the list hints */
@@ -551,14 +552,16 @@ gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h,
     /* XXX watch for xinerama dead areas */
 
     a = screen_area(self->desktop);
-    if (!self->strut.right && *x >= a->x + a->width - 1)
-        *x = a->x + a->width - self->frame->area.width;
-    if (!self->strut.bottom && *y >= a->y + a->height - 1)
-        *y = a->y + a->height - self->frame->area.height;
-    if (!self->strut.left && *x + self->frame->area.width - 1 < a->x)
-        *x = a->x;
-    if (!self->strut.top && *y + self->frame->area.height - 1 < a->y)
-        *y = a->y;
+    if (client_normal(self)) {
+        if (!self->strut.right && *x >= a->x + a->width - 1)
+            *x = a->x + a->width - self->frame->area.width;
+        if (!self->strut.bottom && *y >= a->y + a->height - 1)
+            *y = a->y + a->height - self->frame->area.height;
+        if (!self->strut.left && *x + self->frame->area.width - 1 < a->x)
+            *x = a->x;
+        if (!self->strut.top && *y + self->frame->area.height - 1 < a->y)
+            *y = a->y;
+    }
 
     if (rude) {
         /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good.
@@ -660,8 +663,6 @@ static void client_get_all(ObClient *self)
     client_get_state(self);
     client_get_shaped(self);
 
-    g_message("self->iconic %d", self->iconic);
-
     client_get_mwm_hints(self);
     client_get_type(self);/* this can change the mwmhints for special cases */
 
@@ -677,6 +678,7 @@ static void client_get_all(ObClient *self)
   
     client_update_title(self);
     client_update_class(self);
+    client_update_sm_client_id(self);
     client_update_strut(self);
     client_update_icons(self);
 }
@@ -1405,7 +1407,7 @@ void client_update_class(ObClient *self)
     }
 
     if (PROP_GETS(self->window, wm_window_role, locale, &s))
-       self->role = g_strdup(s);
+       self->role = s;
 
     if (self->name == NULL) self->name = g_strdup("");
     if (self->class == NULL) self->class = g_strdup("");
@@ -1548,6 +1550,16 @@ void client_update_icons(ObClient *self)
         }
     }
 
+    if (!self->nicons) {
+        self->nicons++;
+        self->icons = g_new(ObClientIcon, self->nicons);
+        self->icons[self->nicons-1].width = 48;
+        self->icons[self->nicons-1].height = 48;
+        self->icons[self->nicons-1].data = g_memdup(ob_rr_theme->def_win_icon,
+                                                    sizeof(RrPixel32)
+                                                    * 48 * 48);
+    }
+
     if (self->frame)
        frame_adjust_icon(self->frame);
 }
@@ -1635,7 +1647,9 @@ static ObStackingLayer calc_layer(ObClient *self)
 {
     ObStackingLayer l;
 
-    if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
+    if (self->fullscreen &&
+        (client_focused(self) || client_search_focus_tree(self)))
+        l = OB_STACKING_LAYER_FULLSCREEN;
     else if (self->type == OB_CLIENT_TYPE_DESKTOP)
         l = OB_STACKING_LAYER_DESKTOP;
     else if (self->type == OB_CLIENT_TYPE_DOCK) {
@@ -1657,7 +1671,9 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
 
     old = self->layer;
     own = calc_layer(self);
-    self->layer = l > own ? l : own;
+    self->layer = MAX(l, own);
+
+    g_message("calc for 0x%x %d %d", self->window, old, self->layer);
 
     for (it = self->transients; it; it = it->next)
         client_calc_layer_recursive(it->data, orig,
@@ -1665,7 +1681,6 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
 
     if (!raised && l != old)
        if (orig->frame) { /* only restack if the original window is managed */
-            /* XXX add_non_intrusive ever? */
             stacking_remove(CLIENT_AS_WINDOW(self));
             stacking_add(CLIENT_AS_WINDOW(self));
         }
@@ -1715,7 +1730,6 @@ static void client_apply_startup_state(ObClient *self)
 {
     /* these are in a carefully crafted order.. */
 
-    g_message("self->iconic %d", self->iconic);
     if (self->iconic) {
        self->iconic = FALSE;
        client_iconify(self, TRUE, FALSE);
@@ -1932,7 +1946,7 @@ void client_configure_full(ObClient *self, ObCorner anchor,
 
     /* if the client is enlarging, the resize the client before the frame */
     if (send_resize_client && (w > oldw || h > oldh))
-       XResizeWindow(ob_display, self->window, w, h);
+       XResizeWindow(ob_display, self->window, MAX(w, oldw), MAX(h, oldh));
 
     /* move/resize the frame to match the request */
     if (self->frame) {
@@ -1966,7 +1980,7 @@ void client_configure_full(ObClient *self, ObCorner anchor,
     }
 
     /* if the client is shrinking, then resize the frame before the client */
-    if (send_resize_client && (w <= oldw && h <= oldh))
+    if (send_resize_client && (w <= oldw || h <= oldh))
        XResizeWindow(ob_display, self->window, w, h);
 
     XFlush(ob_display);
@@ -2515,14 +2529,15 @@ gboolean client_focus(ObClient *self)
     /* choose the correct target */
     self = client_focus_target(self);
 
-    if (!client_can_focus(self)) {
-        if (!self->frame->visible) {
-            /* update the focus lists */
-            focus_order_to_top(self);
-        }
+    if (!self->frame->visible) {
+        /* update the focus lists */
+        focus_order_to_top(self);
         return FALSE;
     }
 
+    if (!client_can_focus(self))
+        return FALSE;
+
     if (self->can_focus) {
         /* RevertToPointerRoot causes much more headache than RevertToNone, so
            I choose to use it always, hopefully to find errors quicker, if any
@@ -2550,6 +2565,8 @@ gboolean client_focus(ObClient *self)
        XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
     }
 
+    focus_set_client(self);
+
 #ifdef DEBUG_FOCUS
     ob_debug("%sively focusing %lx at %d\n",
              (self->can_focus ? "act" : "pass"),
@@ -2606,8 +2623,6 @@ ObClientIcon *client_icon(ObClient *self, int w, int h)
     /* li is the largest image < req */
     unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
 
-    if (!self->nicons) return NULL;
-
     for (i = 0; i < self->nicons; ++i) {
         size = self->icons[i].width * self->icons[i].height;
         if (size < smallest && size >= (unsigned)(w * h)) {
@@ -2788,13 +2803,15 @@ ObClient *client_search_transient(ObClient *self, ObClient *search)
     return NULL;
 }
 
-gchar* client_get_sm_client_id(ObClient *self)
+void client_update_sm_client_id(ObClient *self)
 {
-    gchar *id = NULL;
+    g_free(self->sm_client_id);
+    self->sm_client_id = NULL;
 
-    if (!PROP_GETS(self->window, sm_client_id, locale, &id) && self->group)
-        PROP_GETS(self->group->leader, sm_client_id, locale, &id);
-    return id;
+    if (!PROP_GETS(self->window, sm_client_id, locale, &self->sm_client_id) &&
+        self->group)
+        PROP_GETS(self->group->leader, sm_client_id, locale,
+                  &self->sm_client_id);
 }
 
 /* finds the nearest edge in the given direction from the current client
This page took 0.029131 seconds and 4 git commands to generate.