index.md - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       index.md (1805B)
       ---
            1 movetoedge
            2 ==========
            3 
            4 Description
            5 -----------
            6 This patch adds functionality to move windows to edges easily.
            7 
            8 Usage
            9 -----
           10 1. Put the following `movetoedge()` function somewhere in your `dwm.c`,
           11   **after** the line which includes the config.h file:
           12 
           13         void
           14         movetoedge(const Arg *arg) {
           15                  /* only floating windows can be moved */
           16                 Client *c;
           17                 c = selmon->sel;
           18                 int x, y, nx, ny;
           19 
           20                 if (!c || !arg)
           21                         return;
           22                 if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
           23                         return;
           24                 if (sscanf((char *)arg->v, "%d %d", &x, &y) != 2)
           25                         return;
           26         
           27                 if(x == 0)
           28                         nx = (selmon->mw - c->w)/2;
           29                 else if(x == -1)
           30                         nx = borderpx;
           31                 else if(x == 1)
           32                         nx = selmon->mw - (c->w + 2 * borderpx);
           33                 else
           34                         nx = c->x;
           35         
           36                 if(y == 0)
           37                         ny = (selmon->mh - (c->h + bh))/2;
           38                 else if(y == -1)
           39                         ny = bh + borderpx;
           40                 else if(y == 1)
           41                         ny = selmon->mh - (c->h + 2 * borderpx);
           42                 else 
           43                         ny = c->y;
           44         
           45         
           46                 XRaiseWindow(dpy, c->win);
           47                 resize(c, nx, ny, c->w, c->h, True);
           48         }
           49 
           50 2. Add a movetoedge() function definition in dwm.c below the line:
           51         static void movetoedge(const Arg *arg);
           52 
           53 3. In config file :
           54         { MODKEY,                         XK_KP_End,    movetoedge,       {.v = "-1 1" } },
           55         { MODKEY,                         XK_KP_Down,   movetoedge,       {.v = "0 1" } },
           56         { MODKEY,                         XK_KP_Next,   movetoedge,       {.v = "1 1" } },
           57         { MODKEY,                         XK_KP_Left,   movetoedge,       {.v = "-1 0" } },
           58         { MODKEY,                         XK_KP_Begin,  movetoedge,       {.v = "0 0" } },
           59         { MODKEY,                         XK_KP_Right,  movetoedge,       {.v = "1 0" } },
           60         { MODKEY,                         XK_KP_Home,   movetoedge,       {.v = "-1 -1" } },
           61         { MODKEY,                         XK_KP_Up,     movetoedge,       {.v = "0 -1" } },
           62         { MODKEY,                         XK_KP_Prior,  movetoedge,       {.v = "1 -1" } },
           63 
           64 Download
           65 --------
           66 * [dwm-movetoedge-6.2.diff](dwm-movetoedge-6.2.diff)
           67 
           68 Authors
           69 -------
           70 * Dhaval Patel - <dhavalpatel32768@gmail.com>