]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
when ending actions which can move windows, and we were using the mouse, instead...
[chaz/openbox] / openbox / client.c
index aa3174f73e3aa91084c98b96a6c0e3632989b2ca..c4b106beaef6b2232041d08bcb2e005e8587bdb3 100644 (file)
@@ -1,3 +1,21 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   client.c for the Openbox window manager
+   Copyright (c) 2003        Ben Jansens
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   See the COPYING file for a copy of the GNU General Public License.
+*/
+
 #include "client.h"
 #include "debug.h"
 #include "startupnotify.h"
@@ -461,6 +479,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 +570,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 +681,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 +696,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 +1425,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 +1568,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);
 }
@@ -1715,7 +1745,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);
@@ -1931,8 +1960,8 @@ void client_configure_full(ObClient *self, ObCorner anchor,
                                     (resized && config_redraw_resize))));
 
     /* 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);
+    if (send_resize_client && user && (w > oldw || h > oldh))
+        XResizeWindow(ob_display, self->window, MAX(w, oldw), MAX(h, oldh));
 
     /* move/resize the frame to match the request */
     if (self->frame) {
@@ -1962,12 +1991,14 @@ void client_configure_full(ObClient *self, ObCorner anchor,
             event.xconfigure.override_redirect = FALSE;
             XSendEvent(event.xconfigure.display, event.xconfigure.window,
                        FALSE, StructureNotifyMask, &event);
-       }
+        }
     }
 
     /* if the client is shrinking, then resize the frame before the client */
-    if (send_resize_client && (w <= oldw && h <= oldh))
-       XResizeWindow(ob_display, self->window, w, h);
+    if (send_resize_client && (!user || (w <= oldw || h <= oldh)))
+        XResizeWindow(ob_display, self->window, w, h);
+
+    XFlush(ob_display);
 }
 
 void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
@@ -2563,11 +2594,12 @@ gboolean client_focus(ObClient *self)
 
 void client_unfocus(ObClient *self)
 {
-    g_assert(focus_client == self);
+    if (focus_client == self) {
 #ifdef DEBUG_FOCUS
-    ob_debug("client_unfocus for %lx\n", self->window);
+        ob_debug("client_unfocus for %lx\n", self->window);
 #endif
-    focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
+        focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
+    }
 }
 
 void client_activate(ObClient *self, gboolean here)
@@ -2604,8 +2636,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)) {
@@ -2786,13 +2816,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
@@ -2985,3 +3017,24 @@ int client_directional_edge_search(ObClient *c, ObDirection dir)
     }
     return dest;
 }
+
+ObClient* client_under_pointer()
+{
+    int x, y;
+    GList *it;
+    ObClient *ret = NULL;
+
+    if (screen_pointer_pos(&x, &y)) {
+        for (it = stacking_list; it != NULL; it = it->next) {
+            if (WINDOW_IS_CLIENT(it->data)) {
+                ObClient *c = WINDOW_AS_CLIENT(it->data);
+                if (c->desktop == screen_desktop &&
+                    RECT_CONTAINS(c->frame->area, x, y)) {
+                    ret = c;
+                    break;
+                }
+            }
+        }
+    }
+    return ret;
+}
This page took 0.029415 seconds and 4 git commands to generate.