[openbox] switch desktop on edge of screen with mouse

Mikael Magnusson mangosoft at comhem.se
Sun Jan 4 15:13:12 EST 2004


On Sun, 4 Jan 2004, AthlonRob wrote:

> On Sun, 2004-01-04 at 11:35, Mikael Magnusson wrote:
> > this is the first version of a small app that changes desk when you move 
> > the mouse to the edge of the screen, delays is for 0.2. i hope you dialup 
> > users dont mind the extra second downloading because of the attachment.
> 
> Nice.  :-)
> 
> A feature request for 0.21....
> 
> It would be nice to be able to drag windows with the mouse over the edge
> to another desktop.
> 
> Rob

Has to be patched in the wm, since it grabs the mouse on drags, attached. 
(does not work well with xinerama, but then again, neither does my 
program)

--
Mikael Magnusson
-------------- next part --------------
===================================================================
RCS file: /cvs/cvsroot/openbox/openbox/moveresize.c,v
retrieving revision 1.49
diff -p -u -d -r1.49 moveresize.c
--- openbox/moveresize.c	15 Oct 2003 03:59:35 -0000	1.49
+++ openbox/moveresize.c	4 Jan 2004 20:09:36 -0000
@@ -23,6 +23,7 @@
 #include "client.h"
 #include "frame.h"
 #include "openbox.h"
+#include "action.h"
 #include "resist.h"
 #include "popup.h"
 #include "moveresize.h"
@@ -220,7 +221,9 @@ static void do_resize(gboolean resist)
 
 void moveresize_event(XEvent *e)
 {
     g_assert(moveresize_in_progress);
+    ObAction *a;
+    gint warpx, warpy;
 
     if (e->type == ButtonPress) {
         if (!button) {
@@ -245,6 +248,37 @@ void moveresize_event(XEvent *e)
         if (moving) {
             cur_x = start_cx + e->xmotion.x_root - start_x;
             cur_y = start_cy + e->xmotion.y_root - start_y;
+            Rect *area;
+            area = screen_area_monitor(moveresize_client->desktop, 0);
+            if (e->xmotion.x_root > area->width - 2) {
+                a = action_from_string("sendtodesktopright", OB_USER_ACTION_MOUSE_MOTION);
+                warpx = 5 - area->width;
+                warpy = 0;
+                goto sendtodesk;
+            } else if (e->xmotion.x_root < 2) {
+                a = action_from_string("sendtodesktopleft", OB_USER_ACTION_MOUSE_MOTION);
+                warpx = area->width - 5;
+                warpy = 0;
+                goto sendtodesk;
+            } else if (e->xmotion.y_root < 2) {
+                a = action_from_string("sendtodesktopup", OB_USER_ACTION_MOUSE_MOTION);
+                warpx = 0;
+                warpy = area->height - 5;
+                goto sendtodesk;
+            } else if (e->xmotion.y_root > area->height - 2) {
+                a = action_from_string("sendtodesktopdown", OB_USER_ACTION_MOUSE_MOTION);
+                warpx = 0;
+                warpy = 5 - area->height;
+                goto sendtodesk;
+            }
+            goto donesend;
+sendtodesk:
+            grab_pointer(TRUE, OB_CURSOR_NONE);
+            XWarpPointer(ob_display, 0, 0, 0, 0, 0, 0, warpx, warpy);
+            a->data.sendtodir.inter.any.c = moveresize_client;
+            action_send_to_desktop_dir(&a->data);
+            grab_pointer(FALSE, OB_CURSOR_NONE);
+donesend:
             do_move(TRUE);
         } else {
             if (corner == prop_atoms.net_wm_moveresize_size_topleft) {


More information about the openbox mailing list