]> Dogcows Code - chaz/openbox/commitdiff
add urgent actions
authorDana Jansens <danakj@orodu.net>
Mon, 1 Sep 2003 02:02:40 +0000 (02:02 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 1 Sep 2003 02:02:40 +0000 (02:02 +0000)
add some macros for moving/resizing clients
add 'vibrate' action

openbox/action.c
openbox/action.h
openbox/client.c
openbox/client.h
openbox/config.c
openbox/config.h
openbox/moveresize.c

index 6a81f792c40bcd8b4c58e2ae66818886127e140b..6e750d6f54f059e166ea519c5feb4b04a55a327e 100644 (file)
@@ -699,6 +699,11 @@ ActionString actionstrings[] =
         action_growtoedge,
         setup_action_growtoedge_east
     },
+    {
+        "vibrate",
+        action_vibrate,
+        NULL
+    },
     {
         NULL,
         NULL,
@@ -917,38 +922,31 @@ void action_move_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c)
-        client_configure(c, OB_CORNER_TOPLEFT,
-                         c->area.x + data->relative.delta, c->area.y,
-                         c->area.width, c->area.height, TRUE, TRUE);
+        client_move(c, c->area.x + data->relative.delta, c->area.y);
 }
 
 void action_move_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c)
-        client_configure(c, OB_CORNER_TOPLEFT,
-                         c->area.x, c->area.y + data->relative.delta,
-                         c->area.width, c->area.height, TRUE, TRUE);
+        client_move(c, c->area.x, c->area.y + data->relative.delta);
 }
 
 void action_resize_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c)
-        client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
-                         c->area.width +
-                         data->relative.delta * c->size_inc.width,
-                         c->area.height, TRUE, TRUE);
+        client_resize(c,
+                      c->area.width + data->relative.delta * c->size_inc.width,
+                      c->area.height);
 }
 
 void action_resize_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c && !c->shaded)
-        client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
-                         c->area.width, c->area.height +
-                         data->relative.delta * c->size_inc.height,
-                         TRUE, TRUE);
+        client_resize(c, c->area.width, c->area.height +
+                      data->relative.delta * c->size_inc.height);
 }
 
 void action_maximize_full(union ActionData *data)
@@ -1147,8 +1145,7 @@ void action_movetoedge(union ActionData *data)
         g_assert_not_reached();
     }
     frame_frame_gravity(c->frame, &x, &y);
-    client_configure(c, OB_CORNER_TOPLEFT,
-                     x, y, c->area.width, c->area.height, TRUE, TRUE);
+    client_move(c, x, y);
 
 }
 
@@ -1211,7 +1208,7 @@ void action_growtoedge(union ActionData *data)
     frame_frame_gravity(c->frame, &x, &y);
     width -= c->frame->size.left + c->frame->size.right;
     height -= c->frame->size.top + c->frame->size.bottom;
-    client_configure(c, OB_CORNER_TOPLEFT, x, y, width, height, TRUE, TRUE);
+    client_move(c, x, y);
 }
 
 void action_send_to_layer(union ActionData *data)
@@ -1246,3 +1243,28 @@ void action_unshow_desktop(union ActionData *data)
 {
     screen_show_desktop(FALSE);
 }
+
+void action_vibrate(union ActionData *data)
+{
+    ObClient *c = data->client.any.c;
+    gint x, y, thr, length, i;
+
+    if (!c) return;
+
+    x = c->frame->area.x;
+    y = c->frame->area.y;
+    thr = 120;
+    length = y + thr;
+    for (i = 0; i < 5; ++i) {
+        while (y < length) {
+            client_move(c, x, y);
+            y += 4;
+            x -= 1;
+        }
+        while (y >= length - thr) {
+            client_move(c, x, y);
+            y -= 4;
+            x += 1;
+        }
+    }
+}
index 3f6d84eb8b6ac7c7124e4e1323020c7f94c8acef..db618b36c997cccee8a17e4d5ab5063b292f2e8d 100644 (file)
@@ -244,5 +244,7 @@ void action_toggle_show_desktop(union ActionData *data);
 void action_show_desktop(union ActionData *data);
 /* Any */
 void action_unshow_desktop(union ActionData *data);
+/* Client */
+void action_vibrate(union ActionData *data);
 
 #endif
index 70b13c7e1c2df182d9a4cbab84b15d2780d1eb59..c7c9a548de6a3f666c92c474961d08cef34334af 100644 (file)
@@ -49,6 +49,7 @@ static void client_change_state(ObClient *self);
 static void client_apply_startup_state(ObClient *self);
 static void client_restore_session_state(ObClient *self);
 static void client_restore_session_stacking(ObClient *self);
+static void client_act_urgent(ObClient *self);
 
 void client_startup()
 {
@@ -330,9 +331,7 @@ void client_manage(Window window)
                              client_normal(self));
 
         if (x != ox || y != oy)
-            client_configure(self, OB_CORNER_TOPLEFT, x, y,
-                             self->area.width, self->area.height,
-                             TRUE, TRUE);
+            client_move(self, x, y);
     }
 
     client_showhide(self);
@@ -483,6 +482,18 @@ void client_unmanage(ObClient *self)
     client_set_list();
 }
 
+static void client_act_urgent(ObClient *self)
+{
+    GSList *it;
+
+    for (it = config_urgent_actions; it; it = g_slist_next(it)) {
+        ObAction *a = it->data;
+
+        a->data.any.c = self;
+        a->func(&a->data);
+    }
+}
+
 static void client_restore_session_state(ObClient *self)
 {
     GList *it;
@@ -543,9 +554,7 @@ void client_move_onscreen(ObClient *self, gboolean rude)
     if (client_find_onscreen(self, &x, &y,
                              self->frame->area.width,
                              self->frame->area.height, rude)) {
-        client_configure(self, OB_CORNER_TOPLEFT, x, y,
-                         self->area.width, self->area.height,
-                         TRUE, TRUE);
+        client_move(self, x, y);
     }
 }
 
@@ -1296,9 +1305,8 @@ 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) {
-            /* XXX do shit */
-        }
+       if (self->frame && self->urgent)
+            client_act_urgent(self);
     }
 }
 
@@ -1722,7 +1730,7 @@ static void client_apply_startup_state(ObClient *self)
        client_shade(self, TRUE);
     }
     if (self->urgent)
-        /* XXX do shit */;
+        client_act_urgent(self);
   
     if (self->max_vert && self->max_horz) {
        self->max_vert = self->max_horz = FALSE;
@@ -2021,7 +2029,7 @@ void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
 
     client_setup_decor_and_functions(self);
 
-    client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
+    client_move_resize(self, x, y, w, h);
 
     /* try focus us when we go into fullscreen mode */
     client_focus(self);
@@ -2197,7 +2205,7 @@ void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
 
     /* figure out where the client should be going */
     frame_frame_gravity(self->frame, &x, &y);
-    client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
+    client_move_resize(self, x, y, w, h);
 }
 
 void client_shade(ObClient *self, gboolean shade)
index 758851e1432dc143073b8f76454f6319151c9047..b28acab2dbe77aca7999128c095142b840c7232b 100644 (file)
@@ -273,6 +273,16 @@ gboolean client_normal(ObClient *self);
 /* Returns if the window is focused */
 gboolean client_focused(ObClient *self);
 
+#define client_move(self, x, y) \
+  client_configure(self, OB_CORNER_TOPLEFT, x, y, \
+                   self->area.width, self->area.height, \
+                   TRUE, TRUE)
+#define client_resize(self, w, h) \
+  client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y, \
+                   w, h, TRUE, TRUE)
+#define client_move_resize(self, x, y, w, h) \
+  client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE)
+
 #define client_configure(self, anchor, x, y, w, h, user, final) \
   client_configure_full(self, anchor, x, y, w, h, user, final, FALSE)
 
index 21f03d3e27dea11e6cc692469b2c9781e6534156..2095060323c1fd153d6981f6a229432d6c9a1273 100644 (file)
@@ -40,6 +40,8 @@ GSList *config_menu_files;
 gint config_resist_win;
 gint config_resist_edge;
 
+GSList *config_urgent_actions;
+
 /*
 
 <keybind key="C-x">
@@ -352,6 +354,33 @@ static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         config_resist_edge = parse_int(doc, n);
 }
 
+static void parse_urgent(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+                         void *d)
+{
+    ObAction *action;
+    xmlNodePtr nact;
+
+    nact = parse_find_node("action", node->xmlChildrenNode);
+    while (nact) {
+        if ((action = action_parse(i, doc, nact))) {
+            /* validate that its okay for an urgent binding */
+            if (action->func == action_moveresize &&
+                action->data.moveresize.corner !=
+                prop_atoms.net_wm_moveresize_move_keyboard &&
+                action->data.moveresize.corner !=
+                prop_atoms.net_wm_moveresize_size_keyboard) {
+                action_free(action);
+                action = NULL;
+            }
+
+            if (action)
+                config_urgent_actions = g_slist_append(config_urgent_actions,
+                                                       action);
+        }
+        nact = parse_find_node("action", nact->next);
+    }
+}
+
 void config_startup(ObParseInst *i)
 {
     config_focus_new = TRUE;
@@ -405,6 +434,8 @@ void config_startup(ObParseInst *i)
     config_menu_files = NULL;
 
     parse_register(i, "menu", parse_menu, NULL);
+
+    parse_register(i, "urgent", parse_urgent, NULL);
 }
 
 void config_shutdown()
index 02ee2457a6008e23b64728b69f952fd4dadbf6eb..ea9b5f61d8b26f0b96f039e8cce541de9337e71e 100644 (file)
@@ -71,6 +71,9 @@ extern gint config_resist_edge;
 /*! User-specified menu files */
 extern GSList *config_menu_files;
 
+/*! Actions to execute when a client sets its urgent flag */
+extern GSList *config_urgent_actions;
+
 void config_startup(struct _ObParseInst *i);
 void config_shutdown();
 
index 8f92f71f958f34af73564ba2a84e2edddbf5d502..424b8a14b8b7ed01bdf55cfe227eeb14c067402e 100644 (file)
@@ -7,6 +7,7 @@
 #include "openbox.h"
 #include "resist.h"
 #include "popup.h"
+#include "moveresize.h"
 #include "config.h"
 #include "render/render.h"
 #include "render/theme.h"
@@ -143,10 +144,9 @@ void moveresize_end(gboolean cancel)
     popup_hide(popup);
 
     if (moving) {
-        client_configure(moveresize_client, OB_CORNER_TOPLEFT,
-                         (cancel ? start_cx : cur_x),
-                         (cancel ? start_cy : cur_y),
-                         start_cw, start_ch, TRUE, TRUE);
+        client_move(moveresize_client,
+                    (cancel ? start_cx : cur_x),
+                    (cancel ? start_cy : cur_y));
     } else {
         client_configure(moveresize_client, lockcorner,
                          moveresize_client->area.x,
@@ -168,8 +168,7 @@ static void do_move(gboolean resist)
 
     /* get where the client should be */
     frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y);
-    client_configure(moveresize_client, OB_CORNER_TOPLEFT, cur_x, cur_y,
-                     start_cw, start_ch, TRUE, FALSE);
+    client_move(moveresize_client, cur_x, cur_y);
 
     /* this would be better with a fixed width font ... XXX can do it better
        if there are 2 text boxes */
This page took 0.034358 seconds and 4 git commands to generate.