sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-moveplace-20180524-c8e9479.diff (4225B)


      1 From ae0f69b86a4a4d1647a3bb049e05d31d9aa29d40 Mon Sep 17 00:00:00 2001
      2 From: Christopher Drelich <cd@cdrakka.com>
      3 Date: Thu, 24 May 2018 21:12:22 -0400
      4 Subject: [PATCH] Makes win floating, and moves it into one of 9 screen
      5  positions.
      6 
      7 ---
      8  config.def.h |  9 +++++++++
      9  dwm.1        |  5 +++++
     10  dwm.c        | 34 +++++++++++++++++++++++++++++++++-
     11  3 files changed, 47 insertions(+), 1 deletion(-)
     12 
     13 diff --git a/config.def.h b/config.def.h
     14 index a9ac303..1087b9e 100644
     15 --- a/config.def.h
     16 +++ b/config.def.h
     17 @@ -84,6 +84,15 @@ static Key keys[] = {
     18  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     19  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     20  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     21 +	{ MODKEY,                       XK_q,      moveplace,      {.ui = WIN_NW }},
     22 +	{ MODKEY,                       XK_w,      moveplace,      {.ui = WIN_N  }},
     23 +	{ MODKEY,                       XK_e,      moveplace,      {.ui = WIN_NE }},
     24 +	{ MODKEY,                       XK_a,      moveplace,      {.ui = WIN_W  }},
     25 +	{ MODKEY,                       XK_s,      moveplace,      {.ui = WIN_C  }},
     26 +	{ MODKEY,                       XK_d,      moveplace,      {.ui = WIN_E  }},
     27 +	{ MODKEY,                       XK_z,      moveplace,      {.ui = WIN_SW }},
     28 +	{ MODKEY,                       XK_x,      moveplace,      {.ui = WIN_S  }},
     29 +	{ MODKEY,                       XK_c,      moveplace,      {.ui = WIN_SE }},
     30  	TAGKEYS(                        XK_1,                      0)
     31  	TAGKEYS(                        XK_2,                      1)
     32  	TAGKEYS(                        XK_3,                      2)
     33 diff --git a/dwm.1 b/dwm.1
     34 index 13b3729..8df7d9f 100644
     35 --- a/dwm.1
     36 +++ b/dwm.1
     37 @@ -131,6 +131,11 @@ Apply all tags to focused window.
     38  .B Mod1\-Control\-Shift\-[1..n]
     39  Add/remove nth tag to/from focused window.
     40  .TP
     41 +.B Mod1\-[q,w,e,a,s,d,z,x,c]
     42 +Makes the window floating, 1/3rd height and 1/3rd width of screen, and puts it in a
     43 +position based on the key-pressed. The position on screen is equivalent to the
     44 +position of those keys relative to each other, with "s" being the center.
     45 +.TP
     46  .B Mod1\-[1..n]
     47  View all windows with nth tag.
     48  .TP
     49 diff --git a/dwm.c b/dwm.c
     50 index bb95e26..480f59d 100644
     51 --- a/dwm.c
     52 +++ b/dwm.c
     53 @@ -66,6 +66,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
     54  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
     55  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
     56         ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
     57 +enum { WIN_NW, WIN_N, WIN_NE, WIN_W, WIN_C, WIN_E, WIN_SW, WIN_S, WIN_SE }; /* coordinates for moveplace */
     58  
     59  typedef union {
     60  	int i;
     61 @@ -92,7 +93,7 @@ struct Client {
     62  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     63  	int bw, oldbw;
     64  	unsigned int tags;
     65 -	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     66 +	int isfixed, isfloating, wasfloating, isurgent, neverfocus, oldstate, isfullscreen;
     67  	Client *next;
     68  	Client *snext;
     69  	Monitor *mon;
     70 @@ -183,6 +184,7 @@ static void maprequest(XEvent *e);
     71  static void monocle(Monitor *m);
     72  static void motionnotify(XEvent *e);
     73  static void movemouse(const Arg *arg);
     74 +static void moveplace(const Arg *arg);
     75  static Client *nexttiled(Client *c);
     76  static void pop(Client *);
     77  static void propertynotify(XEvent *e);
     78 @@ -1192,6 +1194,36 @@ movemouse(const Arg *arg)
     79  	}
     80  }
     81  
     82 +void
     83 +moveplace(const Arg *arg)
     84 +{
     85 +	Client *c;
     86 +	int nh, nw, nx, ny;
     87 +	c = selmon->sel;
     88 +	if (!c || (arg->ui >= 9))
     89 +		 return;
     90 +	if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
     91 +		togglefloating(NULL);
     92 +	nh = (selmon->wh / 3) - (c->bw * 2);
     93 +	nw = (selmon->ww / 3) - (c->bw * 2);
     94 +	nx = (arg->ui % 3) -1;
     95 +	ny = (arg->ui / 3) -1;
     96 +	if (nx < 0)
     97 +		nx = selmon->wx;
     98 +	else if(nx > 0)
     99 +		nx = selmon->wx + selmon->ww - nw - c->bw*2;
    100 +	else
    101 +		nx = selmon->wx + selmon->ww/2 - nw/2 - c->bw;
    102 +	if (ny <0)
    103 +		ny = selmon->wy;
    104 +	else if(ny > 0)
    105 +		ny = selmon->wy + selmon->wh - nh - c->bw*2;
    106 +	else
    107 +		ny = selmon->wy + selmon->wh/2 - nh/2 - c->bw;
    108 +	resize(c, nx, ny, nw, nh, True);
    109 +	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, nw/2, nh/2);
    110 +}
    111 +
    112  Client *
    113  nexttiled(Client *c)
    114  {
    115 -- 
    116 2.7.4
    117