]> Dogcows Code - chaz/openbox/blobdiff - openbox/moveresize.c
use the right list in client_add_hide_notify, rename destructor to destroy_notify...
[chaz/openbox] / openbox / moveresize.c
index b03aed95619c76fd49a691f83b6721940c01b8b4..ac51f8b6e83399675dbb24cae379f6cbeba37b1d 100644 (file)
@@ -37,6 +37,9 @@
 #include <X11/Xlib.h>
 #include <glib.h>
 
+/* how far windows move and resize with the keyboard arrows */
+#define KEY_DIST 4
+
 gboolean moveresize_in_progress = FALSE;
 ObClient *moveresize_client = NULL;
 #ifdef SYNC
@@ -67,7 +70,7 @@ void moveresize_startup(gboolean reconfig)
     popup = popup_new(FALSE);
 
     if (!reconfig)
-        client_add_destructor(client_dest, NULL);
+        client_add_destroy_notify(client_dest, NULL);
 }
 
 void moveresize_shutdown(gboolean reconfig)
@@ -75,7 +78,7 @@ void moveresize_shutdown(gboolean reconfig)
     if (!reconfig) {
         if (moveresize_in_progress)
             moveresize_end(FALSE);
-        client_remove_destructor(client_dest);
+        client_remove_destroy_notify(client_dest);
     }
 
     popup_free(popup);
@@ -100,7 +103,7 @@ static void get_resize_position(gint *x, gint *y, gboolean cancel)
 
     /* see how much it is actually going to resize */
     {
-        gint cx = x, cy = y;
+        gint cx = *x, cy = *y;
         frame_frame_gravity(moveresize_client->frame, &cx, &cy, w, h);
         client_try_configure(moveresize_client, &cx, &cy, &w, &h,
                              &lw, &lh, TRUE);
@@ -159,6 +162,8 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
           (c->functions & OB_CLIENT_FUNC_RESIZE)))
         return;
 
+    frame_end_iconify_animation(c->frame);
+
     moveresize_client = c;
     start_cx = c->area.x;
     start_cy = c->area.y;
@@ -294,20 +299,23 @@ void moveresize_end(gboolean cancel)
     moveresize_client = NULL;
 }
 
-static void do_move(gboolean resist)
+static void do_move(gboolean keyboard)
 {
-    if (resist) {
-        resist_move_windows(moveresize_client, &cur_x, &cur_y);
-        resist_move_monitors(moveresize_client, &cur_x, &cur_y);
-    }
+    gint resist;
+
+    if (keyboard) resist = KEY_DIST - 1; /* resist for one key press */
+    else resist = config_resist_win;
+    resist_move_windows(moveresize_client, resist, &cur_x, &cur_y);
+    if (!keyboard) resist = config_resist_edge;
+    resist_move_monitors(moveresize_client, resist, &cur_x, &cur_y);
 
     client_configure(moveresize_client, cur_x, cur_y,
                      moveresize_client->area.width,
                      moveresize_client->area.height, TRUE, FALSE);
     if (config_resize_popup_show == 2) /* == "Always" */
         popup_coords(moveresize_client, "%d x %d",
-                moveresize_client->frame->area.x,
-                moveresize_client->frame->area.y);
+                     moveresize_client->frame->area.x,
+                     moveresize_client->frame->area.y);
 }
 
 static void do_resize()
@@ -369,26 +377,28 @@ static void do_resize()
        if there are 2 text boxes */
     if (config_resize_popup_show == 2 || /* == "Always" */
             (config_resize_popup_show == 1 && /* == "Nonpixel" */
-                (moveresize_client->size_inc.width > 1 ||
-                 moveresize_client->size_inc.height > 1))
-        )
+             moveresize_client->size_inc.width > 1 &&
+             moveresize_client->size_inc.height > 1))
         popup_coords(moveresize_client, "%d x %d",
                      moveresize_client->logical_size.width,
                      moveresize_client->logical_size.height);
 }
 
-static void calc_resize(gboolean resist)
+static void calc_resize(gboolean keyboard)
 {
+    gint resist;
+
     /* resist_size_* needs the frame size */
     cur_x += moveresize_client->frame->size.left +
         moveresize_client->frame->size.right;
     cur_y += moveresize_client->frame->size.top +
         moveresize_client->frame->size.bottom;
 
-    if (resist) {
-        resist_size_windows(moveresize_client, &cur_x, &cur_y, lockcorner);
-        resist_size_monitors(moveresize_client, &cur_x, &cur_y, lockcorner);
-    }
+    if (keyboard) resist = KEY_DIST - 1; /* resist for one key press */
+    else resist = config_resist_win;
+    resist_size_windows(moveresize_client, resist, &cur_x, &cur_y, lockcorner);
+    if (!keyboard) resist = config_resist_edge;
+    resist_size_monitors(moveresize_client, resist, &cur_x, &cur_y,lockcorner);
 
     cur_x -= moveresize_client->frame->size.left +
         moveresize_client->frame->size.right;
@@ -396,8 +406,10 @@ static void calc_resize(gboolean resist)
         moveresize_client->frame->size.bottom;
 }
 
-void moveresize_event(XEvent *e)
+gboolean moveresize_event(XEvent *e)
 {
+    gboolean used = FALSE;
+
     g_assert(moveresize_in_progress);
 
     if (e->type == ButtonPress) {
@@ -406,15 +418,17 @@ void moveresize_event(XEvent *e)
             start_y = e->xbutton.y_root;
             button = e->xbutton.button; /* this will end it now */
         }
+        used = e->xbutton.button == button;
     } else if (e->type == ButtonRelease) {
         if (!button || e->xbutton.button == button) {
             moveresize_end(FALSE);
+            used = TRUE;
         }
     } else if (e->type == MotionNotify) {
         if (moving) {
             cur_x = start_cx + e->xmotion.x_root - start_x;
             cur_y = start_cy + e->xmotion.y_root - start_y;
-            do_move(TRUE);
+            do_move(FALSE);
         } else {
             if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
                 cur_x = start_cw - (e->xmotion.x_root - start_x);
@@ -457,28 +471,33 @@ void moveresize_event(XEvent *e)
             } else
                 g_assert_not_reached();
 
-            calc_resize(TRUE);
+            calc_resize(FALSE);
             do_resize();
         }
+        used = TRUE;
     } else if (e->type == KeyPress) {
-        if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
+        if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) {
             moveresize_end(TRUE);
-        else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN))
+            used = TRUE;
+        } else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) {
             moveresize_end(FALSE);
-        else {
+            used = TRUE;
+        } else if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT) ||
+                   e->xkey.keycode == ob_keycode(OB_KEY_LEFT) ||
+                   e->xkey.keycode == ob_keycode(OB_KEY_DOWN) ||
+                   e->xkey.keycode == ob_keycode(OB_KEY_UP))
+        {
             if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
                 gint dx = 0, dy = 0, ox = cur_x, oy = cur_y;
 
                 if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
-                    dx = MAX(4, moveresize_client->size_inc.width);
+                    dx = MAX(KEY_DIST, moveresize_client->size_inc.width);
                 else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT))
-                    dx = -MAX(4, moveresize_client->size_inc.width);
+                    dx = -MAX(KEY_DIST, moveresize_client->size_inc.width);
                 else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
-                    dy = MAX(4, moveresize_client->size_inc.height);
-                else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
-                    dy = -MAX(4, moveresize_client->size_inc.height);
-                else
-                    return;
+                    dy = MAX(KEY_DIST, moveresize_client->size_inc.height);
+                else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */
+                    dy = -MAX(KEY_DIST, moveresize_client->size_inc.height);
 
                 cur_x += dx;
                 cur_y += dy;
@@ -490,7 +509,8 @@ void moveresize_event(XEvent *e)
                     while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
                 }
 
-                do_resize(FALSE);
+                calc_resize(TRUE);
+                do_resize();
 
                 /* because the cursor moves even though the window does
                    not nessesarily (resistance), this adjusts where the curor
@@ -498,20 +518,20 @@ void moveresize_event(XEvent *e)
                    actually is */
                 start_x += dx - (cur_x - ox);
                 start_y += dy - (cur_y - oy);
+
+                used = TRUE;
             } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) {
                 gint dx = 0, dy = 0, ox = cur_x, oy = cur_y;
                 gint opx, px, opy, py;
 
                 if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
-                    dx = 4;
+                    dx = KEY_DIST;
                 else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT))
-                    dx = -4;
+                    dx = -KEY_DIST;
                 else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
-                    dy = 4;
-                else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
-                    dy = -4;
-                else
-                    return;
+                    dy = KEY_DIST;
+                else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */
+                    dy = -KEY_DIST;
 
                 cur_x += dx;
                 cur_y += dy;
@@ -525,7 +545,7 @@ void moveresize_event(XEvent *e)
                 }
                 screen_pointer_pos(&px, &py);
 
-                do_move(FALSE);
+                do_move(TRUE);
 
                 /* because the cursor moves even though the window does
                    not nessesarily (resistance), this adjusts where the curor
@@ -533,6 +553,8 @@ void moveresize_event(XEvent *e)
                    actually is */
                 start_x += (px - opx) - (cur_x - ox);
                 start_y += (py - opy) - (cur_y - oy);
+
+                used = TRUE;
             }
         }
     }
@@ -541,6 +563,8 @@ void moveresize_event(XEvent *e)
     {
         waiting_for_sync = FALSE; /* we got our sync... */
         do_resize(); /* ...so try resize if there is more change pending */
+        used = TRUE;
     }
 #endif
+    return used;
 }
This page took 0.029431 seconds and 4 git commands to generate.