dwm-movethrow-6.2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-movethrow-6.2.diff (3044B)
       ---
            1 This patch is heavily inspired by the moveplace patch. It allows to "throw"
            2 windows in 4 directions, which makes them floating (if not floating already)
            3 and then moves them in the chosen direction until they hit the border of the
            4 screen. Unlike moveplace, the windows get to keep their original size.
            5 Additionally, there's a "middle direction" defined which simply centers a
            6 window on the screen.
            7 
            8 diff --git a/config.def.h b/config.def.h
            9 index 1c0b587..cd8b0a7 100644
           10 --- a/config.def.h
           11 +++ b/config.def.h
           12 @@ -84,6 +84,11 @@ static Key keys[] = {
           13          { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
           14          { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
           15          { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
           16 +        { MODKEY|ShiftMask,             XK_Up,     movethrow,      {.ui = DIR_N }},
           17 +        { MODKEY|ShiftMask,             XK_Down,   movethrow,      {.ui = DIR_S }},
           18 +        { MODKEY|ShiftMask,             XK_Left,   movethrow,      {.ui = DIR_W }},
           19 +        { MODKEY|ShiftMask,             XK_Right,  movethrow,      {.ui = DIR_E }},
           20 +        { MODKEY|ShiftMask,             XK_m,      movethrow,      {.ui = DIR_C }},
           21          TAGKEYS(                        XK_1,                      0)
           22          TAGKEYS(                        XK_2,                      1)
           23          TAGKEYS(                        XK_3,                      2)
           24 diff --git a/dwm.c b/dwm.c
           25 index 4465af1..16f4b08 100644
           26 --- a/dwm.c
           27 +++ b/dwm.c
           28 @@ -66,6 +66,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
           29  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
           30  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
           31         ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
           32 +enum { DIR_N, DIR_W, DIR_C, DIR_E, DIR_S, }; /* coordinates for movethrow */
           33  
           34  typedef union {
           35          int i;
           36 @@ -183,6 +184,7 @@ static void maprequest(XEvent *e);
           37  static void monocle(Monitor *m);
           38  static void motionnotify(XEvent *e);
           39  static void movemouse(const Arg *arg);
           40 +static void movethrow(const Arg *arg);
           41  static Client *nexttiled(Client *c);
           42  static void pop(Client *);
           43  static void propertynotify(XEvent *e);
           44 @@ -1192,6 +1194,46 @@ movemouse(const Arg *arg)
           45          }
           46  }
           47  
           48 +void
           49 +movethrow(const Arg *arg)
           50 +{
           51 +        Client *c;
           52 +        int nh, nw, nx, ny;
           53 +        c = selmon->sel;
           54 +        if (!c)
           55 +                return;
           56 +        if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
           57 +                togglefloating(NULL);
           58 +        nw = c->w;
           59 +        nh = c->h;
           60 +        switch(arg->ui) {
           61 +                case DIR_N:
           62 +                        nx = c->x;
           63 +                        ny = selmon->wy;
           64 +                        break;
           65 +                case DIR_E:
           66 +                        nx = selmon->wx + selmon->ww - c->w - c->bw*2;
           67 +                        ny = c->y;
           68 +                        break;
           69 +                case DIR_S:
           70 +                        nx = c->x;
           71 +                        ny = selmon->wy + selmon->wh - c->h - c->bw*2;
           72 +                        break;
           73 +                case DIR_W:
           74 +                        nx = selmon->wx;
           75 +                        ny = c->y;
           76 +                        break;
           77 +                case DIR_C:
           78 +                        nx = selmon->wx + ((selmon->ww - c->w - c->bw*2) / 2);
           79 +                        ny = selmon->wy + ((selmon->wh - c->h - c->bw*2) / 2);
           80 +                        break;
           81 +                default:
           82 +                        return;
           83 +        }
           84 +        resize(c, nx, ny, nw, nh, True);
           85 +        XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, nw/2, nh/2);
           86 +}
           87 +
           88  Client *
           89  nexttiled(Client *c)
           90  {