Add Lock action.
authorMikael Magnusson <mikachu@comhem.se>
Sat, 23 Feb 2008 19:15:34 +0000 (20:15 +0100)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:24:07 +0000 (17:24 +0100)
Allows locking windows so you can't move/resize/close/etc them by mistake.

It's probably better to check in client.c than the actions, just
testing if I want it at all for now.

27 files changed:
Makefile.am
openbox/actions.c
openbox/actions.h
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/close.c
openbox/actions/decorations.c
openbox/actions/desktop.c
openbox/actions/growtoedge.c
openbox/actions/iconify.c
openbox/actions/kill.c
openbox/actions/layer.c
openbox/actions/lock.c [new file with mode: 0644]
openbox/actions/lower.c
openbox/actions/maximize.c
openbox/actions/move.c
openbox/actions/moverelative.c
openbox/actions/moveresizeto.c
openbox/actions/movetoedge.c
openbox/actions/omnipresent.c
openbox/actions/raise.c
openbox/actions/raiselower.c
openbox/actions/resize.c
openbox/actions/resizerelative.c
openbox/actions/shade.c
openbox/client.h
openbox/client_menu.c

index 24ed0a9ab1ac34a2dd5c1486d2c1b5b8968845ce..e14fd8fb7d324248d4f0111a8a9671da28fdfa31 100644 (file)
@@ -190,6 +190,7 @@ openbox_openbox_SOURCES = \
        openbox/actions/if.c \
        openbox/actions/kill.c \
        openbox/actions/layer.c \
+       openbox/actions/lock.c \
        openbox/actions/lower.c \
        openbox/actions/maximize.c \
        openbox/actions/move.c \
index 8f72714e9403026b55ddb5394b381ae941fd3fc6..8e84a82f5c0c7bcfe854148b297401c89d7db17e 100644 (file)
@@ -363,3 +363,10 @@ void actions_client_move(ObActionsData *data, gboolean start)
             event_end_ignore_all_enters(ignore_start);
     }
 }
+
+gboolean actions_client_locked(ObActionsData *data)
+{
+    ObClient *c = data->client;
+
+    return c && c->locked;
+}
index 7a09a665509072b58a6ef740957d6e6d45f0d3b7..0b2dd99659951f74ec168f29cd48a3eabc5f4292 100644 (file)
@@ -98,3 +98,5 @@ gboolean actions_interactive_input_event(XEvent *e);
 
 /*! Function for actions to call when they are moving a client around */
 void actions_client_move(ObActionsData *data, gboolean start);
+/*! May we do something to this client? */
+gboolean actions_client_locked(ObActionsData *data);
index f5d5d06239b1f548ec99e83b27f2a5a15873e589..9b4284e344b0e07f7ff897ddd3c55328d801239e 100644 (file)
@@ -40,4 +40,5 @@ void action_all_startup(void)
     action_if_startup();
     action_focustobottom_startup();
     action_sendkeyevent_startup();
+    action_lock_startup();
 }
index 332e8d111c43e0ff8fd4fa4c8f01f16f378935e4..f444aae1404afc7141661189857dbfd930b058ff 100644 (file)
@@ -41,5 +41,6 @@ void action_growtoedge_startup(void);
 void action_if_startup(void);
 void action_focustobottom_startup(void);
 void action_sendkeyevent_startup(void);
+void action_lock_startup(void);
 
 #endif
index ab75e05da4d1578ce5bf4c983c3467c66e0ac62f..5996cc64ab9ce74734bc59889e23b46d7f12d06b 100644 (file)
@@ -14,7 +14,8 @@ void action_close_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) client_close(data->client);
+    if (!actions_client_locked(data))
+        client_close(data->client);
 
     return FALSE;
 }
index e85fb8ef1c9dbb3b22ebb4a74fedebc77ad5c6ff..9834d26daf9c367819cf33208457225914349792 100644 (file)
@@ -16,7 +16,7 @@ void action_decorations_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_on(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_set_undecorated(data->client, FALSE);
         actions_client_move(data, FALSE);
@@ -27,7 +27,7 @@ static gboolean run_func_on(ObActionsData *data, gpointer options)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_off(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_set_undecorated(data->client, TRUE);
         actions_client_move(data, FALSE);
@@ -38,7 +38,7 @@ static gboolean run_func_off(ObActionsData *data, gpointer options)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_toggle(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_set_undecorated(data->client, !data->client->undecorated);
         actions_client_move(data, FALSE);
index 37268bba9900c42d29fb4ffbb450f68168388c9b..5102eb34c71dd6cdc1b17160aa0a981d062c3133 100644 (file)
@@ -118,8 +118,6 @@ static gboolean run_func(ObActionsData *data, gpointer options)
     Options *o = options;
     guint d;
 
-
-
     switch (o->type) {
     case LAST:
         d = screen_last_desktop;
@@ -137,7 +135,9 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         gboolean go = TRUE;
 
         actions_client_move(data, TRUE);
-        if (o->send && data->client && client_normal(data->client)) {
+        if (o->send && !actions_client_locked(data) &&
+            client_normal(data->client))
+        {
             client_set_desktop(data->client, d, o->follow, FALSE);
             go = o->follow;
         }
index a37e3a26e093606100ea82581e368bcf7bb4fff1..fda04778105fabbceb43f0372df56d03a5bf46a3 100644 (file)
@@ -95,6 +95,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
     gint half;
 
     if (!data->client ||
+        actions_client_locked(data) ||
         /* don't allow vertical resize if shaded */
         ((o->dir == OB_DIRECTION_NORTH || o->dir == OB_DIRECTION_SOUTH) &&
          data->client->shaded))
index 8a3091d2f583d9b45853f448bf76fd5a03242cb2..9f4fd4502dfaeef1474a18e04c4c7b3ca784ed36 100644 (file)
@@ -24,7 +24,7 @@ static gpointer setup_func(xmlNodePtr node)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_iconify(data->client, !options, FALSE, FALSE);
         actions_client_move(data, FALSE);
index 68244407bb0a344e623812dac18ad0a157e780c8..ac0293bf326013b0ee230de0b21362463126a42e 100644 (file)
@@ -14,7 +14,7 @@ void action_kill_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client)
+    if (!actions_client_locked(data))
         client_kill(data->client);
 
     return FALSE;
index bbfda57218f122ae1784dc11ba03c9372d4cebf1..18556d276fe7c22e98f199e875a532da9e01e6bf 100644 (file)
@@ -66,7 +66,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         ObClient *c = data->client;
 
         actions_client_move(data, TRUE);
diff --git a/openbox/actions/lock.c b/openbox/actions/lock.c
new file mode 100644 (file)
index 0000000..bd13958
--- /dev/null
@@ -0,0 +1,18 @@
+#include "openbox/actions.h"
+#include "openbox/client.h"
+
+static gboolean run_func(ObActionsData *data, gpointer options);
+
+void action_lock_startup(void)
+{
+    actions_register("Lock", NULL, NULL, run_func,
+                     NULL, NULL);
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    if (data->client)
+        data->client->locked = !data->client->locked;
+    return FALSE;
+}
index d34e933bc738a9e86203fb45d9fb26223421aa1e..ffe01333ae7d77e4cec54559c96f9ad996bb4523 100644 (file)
@@ -15,7 +15,7 @@ void action_lower_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         stacking_lower(CLIENT_AS_WINDOW(data->client));
         actions_client_move(data, FALSE);
index 45e8b38ed55801812a61f897c473fbd860c5db08..fa4199019afe22843867907cadc056ec66daec2d 100644 (file)
@@ -53,7 +53,7 @@ static gpointer setup_func(xmlNodePtr node)
 static gboolean run_func_on(ObActionsData *data, gpointer options)
 {
     Options *o = options;
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_maximize(data->client, TRUE, o->dir);
         actions_client_move(data, FALSE);
@@ -65,7 +65,7 @@ static gboolean run_func_on(ObActionsData *data, gpointer options)
 static gboolean run_func_off(ObActionsData *data, gpointer options)
 {
     Options *o = options;
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_maximize(data->client, FALSE, o->dir);
         actions_client_move(data, FALSE);
@@ -77,7 +77,7 @@ static gboolean run_func_off(ObActionsData *data, gpointer options)
 static gboolean run_func_toggle(ObActionsData *data, gpointer options)
 {
     Options *o = options;
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         gboolean toggle;
         actions_client_move(data, TRUE);
         toggle = ((o->dir == HORZ && !data->client->max_horz) ||
index ddd3f59af7d1a76fb9144132c933e0612e112f59..70ecf66da9e4f4bcd181348a674a159c5aba910c 100644 (file)
@@ -1,4 +1,5 @@
 #include "openbox/actions.h"
+#include "openbox/client.h"
 #include "openbox/moveresize.h"
 #include "obt/prop.h"
 
@@ -15,7 +16,7 @@ void action_move_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (data->client && !(ObClient *)(data->client)->locked) {
         guint32 corner;
 
         corner = data->button != 0 ?
index ccdff545d5702d02c4a470e98df31b3249c7e823..e923858318442f42e7d3ae49f850aa6669adddd6 100644 (file)
@@ -37,7 +37,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         ObClient *c;
         gint x, y, lw, lh, w, h;
 
index 357c7315d87b84c01e1de9b2a21197d4dcf4c933..6ea70682f726bbd0d01b95341720014bf71e9d47 100644 (file)
@@ -98,7 +98,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         Rect *area, *carea;
         ObClient *c;
         gint mon, cmon;
index f360ddd03da63309ea0da0ddc26a989b350a7e8e..ce975645025de4e636bd3b761b163aa259f8a9c9 100644 (file)
@@ -50,7 +50,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         gint x, y;
 
         client_find_move_directional(data->client, o->dir, &x, &y);
index 030a01592b9857df888dd768440cc964024de8eb..8b0fd918ccefee8c15ddae7d5e0817841efacd47 100644 (file)
@@ -13,7 +13,7 @@ void action_omnipresent_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_toggle(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_set_desktop(data->client,
                            data->client->desktop == DESKTOP_ALL ?
index 6837bce2564916e2bc8bfe1550bfc9c1621296b7..3ee21efadea433ca51cdac55c8bd592f15fc315f 100644 (file)
@@ -15,7 +15,7 @@ void action_raise_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         stacking_raise(CLIENT_AS_WINDOW(data->client));
         actions_client_move(data, FALSE);
index 80fc917fc328db62e7b8bab7015625dccb9110b6..9fb3c29910e282ea6df48850cafb46e9427c0a9b 100644 (file)
@@ -14,7 +14,7 @@ void action_raiselower_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         stacking_restack_request(data->client, NULL, Opposite);
         actions_client_move(data, FALSE);
index 47f45f5b2de4aadcfb3dbcc88870d67ae86bf701..0c224929ffb1aec2ad3b3f9e0791127a5b6b14d5 100644 (file)
@@ -60,7 +60,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         ObClient *c = data->client;
         guint32 corner;
 
index 5742e1fcff0a963e589aa370de47e6d11377c135..ca0a5daa0ecd5eef024b6d43c355274171c19705 100644 (file)
@@ -46,7 +46,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
 
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         ObClient *c = data->client;
         gint x, y, ow, xoff, nw, oh, yoff, nh, lw, lh;
 
index 2342067fc429405b5939333e7d9cb34ca252877e..c394f4f636548bd65328ab8bdd8fd0d744419cac 100644 (file)
@@ -15,7 +15,7 @@ void action_shade_startup(void)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_on(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_shade(data->client, TRUE);
         actions_client_move(data, FALSE);
@@ -26,7 +26,7 @@ static gboolean run_func_on(ObActionsData *data, gpointer options)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_off(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_shade(data->client, FALSE);
         actions_client_move(data, FALSE);
@@ -37,7 +37,7 @@ static gboolean run_func_off(ObActionsData *data, gpointer options)
 /* Always return FALSE because its not interactive */
 static gboolean run_func_toggle(ObActionsData *data, gpointer options)
 {
-    if (data->client) {
+    if (!actions_client_locked(data)) {
         actions_client_move(data, TRUE);
         client_shade(data->client, !data->client->shaded);
         actions_client_move(data, FALSE);
index 6a396cf426835f1f78eaf817a2d43de24004dd02..aadf930308d9fe71e3ebe32d0590df4e57f0d150 100644 (file)
@@ -298,6 +298,9 @@ struct _ObClient
     */
     guint functions;
 
+    /*! Prevent window from being accidentally acted upon */
+    gboolean locked;
+
     /* The window's icon, in a variety of shapes and sizes */
     RrImage *icon_set;
 
index 04f50e857fb31d6e34fe0d0c8cfbe989ec3ec473..addee73162c829ee972d847141760602bda2ad7e 100644 (file)
@@ -111,6 +111,9 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
 
     g_assert(c);
 
+    if (c->locked)
+        return;
+
     if (!config_focus_under_mouse)
         ignore_start = event_start_ignore_all_enters();
 
@@ -208,6 +211,9 @@ static void layer_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
 
     g_assert(c);
 
+    if (c->locked)
+        return;
+
     if (!config_focus_under_mouse)
         ignore_start = event_start_ignore_all_enters();
 
@@ -284,6 +290,9 @@ static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
 {
     g_assert(c);
 
+    if (c->locked)
+        return;
+
     client_set_desktop(c, e->id, FALSE, FALSE);
     /* the client won't even be on the screen anymore, so hide the menu */
     if (f)