]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
use the nwe theme's show_handle value
[chaz/openbox] / openbox / client.c
index e905a6f97ca9faf8753252d278a42c30b9a0741b..adbab7a74774e9e2b618910efdca192490e0961e 100644 (file)
@@ -5,6 +5,7 @@
 #include "startup.h"
 #include "screen.h"
 #include "moveresize.h"
+#include "place.h"
 #include "prop.h"
 #include "extensions.h"
 #include "frame.h"
 #include "grab.h"
 #include "focus.h"
 #include "stacking.h"
-#include "dispatch.h"
 #include "openbox.h"
 #include "group.h"
 #include "config.h"
-#include "menu.h"
+#include "menuframe.h"
 #include "keyboard.h"
 #include "mouse.h"
 #include "render/render.h"
@@ -32,7 +32,8 @@
 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
                                ButtonMotionMask)
 
-GList      *client_list      = NULL;
+GList      *client_list        = NULL;
+GSList     *client_destructors = NULL;
 
 static void client_get_all(ObClient *self);
 static void client_toggle_border(ObClient *self, gboolean show);
@@ -58,6 +59,16 @@ void client_shutdown()
 {
 }
 
+void client_add_destructor(ObClientDestructorFunc func)
+{
+    client_destructors = g_slist_prepend(client_destructors, (gpointer)func);
+}
+
+void client_remove_destructor(ObClientDestructorFunc func)
+{
+    client_destructors = g_slist_remove(client_destructors, (gpointer)func);
+}
+
 void client_set_list()
 {
     Window *windows, *win_it;
@@ -254,10 +265,10 @@ void client_manage(Window window)
 
     frame_grab_client(self->frame, self);
 
-    client_apply_startup_state(self);
-
     grab_server(FALSE);
 
+    client_apply_startup_state(self);
+
     /* update the focus lists */
     focus_order_add_new(self);
 
@@ -272,6 +283,8 @@ void client_manage(Window window)
         (self->type == OB_CLIENT_TYPE_NORMAL ||
          self->type == OB_CLIENT_TYPE_DIALOG))
     {        
+        activate = TRUE;
+#if 0
         if (self->desktop != screen_desktop) {
             /* activate the window */
             activate = TRUE;
@@ -301,13 +314,28 @@ void client_manage(Window window)
                 activate = TRUE;
             }
         }
+#endif
     }
 
-    dispatch_client(Event_Client_New, self, 0, 0);
+    if (ob_state() == OB_STATE_RUNNING) {
+        int x = self->area.x, ox = x;
+        int y = self->area.y, oy = y;
+
+        place_client(self, &x, &y);
+
+        client_find_onscreen(self, &x, &y,
+                             self->frame->area.width,
+                             self->frame->area.height,
+                             client_normal(self));
+
+        if (x != ox || y != oy)
+            client_configure(self, OB_CORNER_TOPLEFT, x, y,
+                             self->area.width, self->area.height,
+                             TRUE, TRUE);
+    }
 
     /* make sure the window is visible */
-    if (ob_state() == OB_STATE_RUNNING)
-        client_move_onscreen(self, TRUE);
+        client_move_onscreen(self, client_normal(self));
 
     client_showhide(self);
 
@@ -336,8 +364,6 @@ void client_manage(Window window)
     keyboard_grab_for_client(self, TRUE);
     mouse_grab_for_client(self, TRUE);
 
-    dispatch_client(Event_Client_Mapped, self, 0, 0);
-
     ob_debug("Managed window 0x%lx (%s)\n", window, self->class);
 }
 
@@ -347,13 +373,6 @@ void client_unmanage_all()
        client_unmanage(client_list->data);
 }
 
-/* called by client_unmanage() to close any menus referencing this client */
-void client_close_menus(gpointer key, gpointer value, gpointer self)
-{
-    if (((ObMenu *)value)->client == (ObClient *)self)
-        menu_hide((ObMenu *)value);
-}
-
 void client_unmanage(ObClient *self)
 {
     guint j;
@@ -361,7 +380,6 @@ void client_unmanage(ObClient *self)
 
     ob_debug("Unmanaging window: %lx (%s)\n", self->window, self->class);
 
-    dispatch_client(Event_Client_Destroy, self, 0, 0);
     g_assert(self != NULL);
 
     keyboard_grab_for_client(self, FALSE);
@@ -407,13 +425,11 @@ void client_unmanage(ObClient *self)
         }
     }
 
-    if (moveresize_client == self)
-        moveresize_end(TRUE);
-
-    /* close any windows that are attached to this window */
-    g_hash_table_foreach(menu_hash, client_close_menus, self);
-
-    
+    for (it = client_destructors; it; it = g_slist_next(it)) {
+        ObClientDestructorFunc func = (ObClientDestructorFunc) it->data;
+        func(self);
+    }
+        
     if (focus_client == self) {
         XEvent e;
 
@@ -429,10 +445,6 @@ void client_unmanage(ObClient *self)
         self->group = NULL;
     }
 
-    /* dispatch the unmapped event */
-    dispatch_client(Event_Client_Unmapped, self, 0, 0);
-    g_assert(self != NULL);
-
     /* give the client its border back */
     client_toggle_border(self, TRUE);
 
@@ -1021,20 +1033,22 @@ void client_update_normal_hints(ObClient *self)
 void client_setup_decor_and_functions(ObClient *self)
 {
     /* start with everything (cept fullscreen) */
-    self->decorations = (OB_FRAME_DECOR_TITLEBAR |
-                         OB_FRAME_DECOR_HANDLE |
-                         OB_FRAME_DECOR_GRIPS |
-                         OB_FRAME_DECOR_BORDER |
-                         OB_FRAME_DECOR_ICON |
-                         OB_FRAME_DECOR_ALLDESKTOPS |
-                         OB_FRAME_DECOR_ICONIFY |
-                         OB_FRAME_DECOR_MAXIMIZE |
-                         OB_FRAME_DECOR_SHADE);
-    self->functions = (OB_CLIENT_FUNC_RESIZE |
-                       OB_CLIENT_FUNC_MOVE |
-                       OB_CLIENT_FUNC_ICONIFY |
-                       OB_CLIENT_FUNC_MAXIMIZE |
-                       OB_CLIENT_FUNC_SHADE);
+    self->decorations =
+        (OB_FRAME_DECOR_TITLEBAR |
+         (ob_rr_theme->show_handle ? OB_FRAME_DECOR_HANDLE : 0) |
+         OB_FRAME_DECOR_GRIPS |
+         OB_FRAME_DECOR_BORDER |
+         OB_FRAME_DECOR_ICON |
+         OB_FRAME_DECOR_ALLDESKTOPS |
+         OB_FRAME_DECOR_ICONIFY |
+         OB_FRAME_DECOR_MAXIMIZE |
+         OB_FRAME_DECOR_SHADE);
+    self->functions =
+        (OB_CLIENT_FUNC_RESIZE |
+         OB_CLIENT_FUNC_MOVE |
+         OB_CLIENT_FUNC_ICONIFY |
+         OB_CLIENT_FUNC_MAXIMIZE |
+         OB_CLIENT_FUNC_SHADE);
     if (self->delete_window) {
        self->functions |= OB_CLIENT_FUNC_CLOSE;
         self->decorations |= OB_FRAME_DECOR_CLOSE;
@@ -1284,8 +1298,9 @@ void client_update_wmhints(ObClient *self)
                  ur ? "ON" : "OFF");
        /* fire the urgent callback if we're mapped, otherwise, wait until
           after we're mapped */
-       if (self->frame)
-            dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
+       if (self->frame) {
+            /* XXX do shit */
+        }
     }
 }
 
@@ -1709,7 +1724,7 @@ static void client_apply_startup_state(ObClient *self)
        client_shade(self, TRUE);
     }
     if (self->urgent)
-        dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
+        /* XXX do shit */;
   
     if (self->max_vert && self->max_horz) {
        self->max_vert = self->max_horz = FALSE;
@@ -2066,9 +2081,6 @@ static void client_iconify_recursive(ObClient *self,
         client_change_state(self);
         client_showhide(self);
         screen_update_areas();
-
-        dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
-                        self, 0, 0);
     }
 
     /* iconify all transients */
@@ -2270,8 +2282,6 @@ void client_set_desktop_recursive(ObClient *self,
             focus_order_to_top(self);
         else
             focus_order_to_bottom(self);
-
-        dispatch_client(Event_Client_Desktop, self, target, old);
     }
 
     /* move all transients */
This page took 0.025409 seconds and 4 git commands to generate.