Browse Source

Allow client move among screens in free mode

Martin Duquesnoy 12 years ago
parent
commit
0f3bc2ed0d
5 changed files with 38 additions and 18 deletions
  1. 29 4
      src/client.c
  2. 0 13
      src/draw.h
  3. 8 0
      src/mouse.c
  4. 0 1
      src/tag.c
  5. 1 0
      src/wmfs.h

+ 29 - 4
src/client.c

@@ -1086,6 +1086,32 @@ client_moveresize(struct client *c, struct geo *g)
           c->wgeo.y = c->tbarw;
           c->geo.w = c->rgeo.w = c->wgeo.w + c->border + c->border;
           c->geo.h = c->rgeo.h = c->wgeo.h + c->tbarw + c->border;
+
+          c->rgeo.x += c->screen->ugeo.x;
+          c->rgeo.y += c->screen->ugeo.y;
+
+          if(!INAREA(c->rgeo.x, c->rgeo.y, c->screen->ugeo))
+          {
+               /* New screen (moved by mouse) */
+               if(c->flags & CLIENT_MOUSE)
+               {
+                    c->flags |= CLIENT_IGNORE_LAYOUT;
+                    c->screen = screen_gb_geo(c->rgeo.x, c->rgeo.y);
+                    tag_client(c->screen->seltag, c);
+
+                    c->geo.x = c->rgeo.x - c->screen->ugeo.x;
+                    c->geo.y = c->rgeo.y - c->screen->ugeo.y;
+
+               }
+               /* Out of the screen case */
+               else
+               {
+                    c->geo.x = (c->screen->ugeo.w >> 1) - (c->geo.w >> 1);
+                    c->geo.y = (c->screen->ugeo.h >> 1) - (c->geo.h >> 1);
+                    c->rgeo.x = c->screen->ugeo.x + c->geo.x;
+                    c->rgeo.y = c->screen->ugeo.y + c->geo.y;
+               }
+          }
      }
      /* Adjust window regarding required size for frame (tiling) */
      else
@@ -1094,11 +1120,10 @@ client_moveresize(struct client *c, struct geo *g)
 
           if(!(c->flags & CLIENT_DID_WINSIZE))
                client_winsize(c, g);
-     }
 
-     /* Real geo regarding full root size */
-     c->rgeo.x += c->screen->ugeo.x;
-     c->rgeo.y += c->screen->ugeo.y;
+          c->rgeo.x += c->screen->ugeo.x;
+          c->rgeo.y += c->screen->ugeo.y;
+     }
 
      XMoveResizeWindow(W->dpy, c->frame,
                        c->rgeo.x, c->rgeo.y,

+ 0 - 13
src/draw.h

@@ -83,19 +83,6 @@ draw_reversed_rect(Drawable dr, struct client *c, bool t)
                     g->h - (i << 1));
 }
 
-static inline void
-draw_reversed_cross(Drawable dr, struct geo *g)
-{
-     int x = g->x + W->screen->ugeo.x;
-     int y = g->y + W->screen->ugeo.y;
-
-     XDrawLine(W->dpy, dr, W->rgc,
-               x, y, x + g->w, y + g->h);
-
-     XDrawLine(W->dpy, dr, W->rgc,
-               x + g->w, y, x, y + g->h);
-}
-
 static inline unsigned short
 draw_textw(struct theme *t, const char *str)
 {

+ 8 - 0
src/mouse.c

@@ -42,6 +42,8 @@ mouse_resize(struct client *c)
      ix = ox;
      iy = oy;
 
+     c->flags |= CLIENT_MOUSE;
+
      do
      {
           XMaskEvent(W->dpy, MouseMask | SubstructureRedirectMask, &ev);
@@ -110,6 +112,8 @@ mouse_resize(struct client *c)
           layout_save_set(c->tag);
      }
 
+     c->flags &= ~CLIENT_MOUSE;
+
      XUngrabServer(W->dpy);
 }
 
@@ -152,6 +156,8 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*))
 
      _REV_SBORDER(c);
 
+     c->flags |= CLIENT_MOUSE;
+
      do
      {
           XMaskEvent(W->dpy, MouseMask | SubstructureRedirectMask, &ev);
@@ -205,6 +211,8 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*))
           if(!func)
                client_moveresize(c, &c->geo);
      }
+
+     c->flags &= ~CLIENT_MOUSE;
 }
 
 void

+ 0 - 1
src/tag.c

@@ -118,7 +118,6 @@ tag_client(struct tag *t, struct client *c)
 
      if(t != c->screen->seltag || c->flags & CLIENT_TABBED)
           client_unmap(c);
-
 }
 
 void

+ 1 - 0
src/wmfs.h

@@ -198,6 +198,7 @@ struct client
 #define CLIENT_FULLSCREEN    0x800
 #define CLIENT_FREE          0x1000
 #define CLIENT_TILED         0x2000
+#define CLIENT_MOUSE         0x4000
      Flags flags;
      Window win, frame, tmp;
      SLIST_ENTRY(client) next;   /* Global list */