Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-ratiofullscreen-20210723-e493493.diff - sites - public wiki contents of suc…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-ratiofullscreen-20210723-e493493.diff (4893B)
---
1 From e493493fa3bffd8b58408a55714de9d49211b1ba Mon Sep 17 00:00:00 2001
2 From: Layerex <[email protected]>
3 Date: Fri, 23 Jul 2021 15:15:23 +0300
4 Subject: [PATCH] ratiofullscreen patch
5
6 Toggle fullscreen for a window while saving its ratio.
7 Space left uncovered by a window may be set to be black or left
8 transparent.
9 The patch is intended to be used with old games which have miniscule
10 window sizes and don't handle fullscreen correctly themselves.
11 Smartborders patch (its modified resizeclient function) is a dependency
12 of this patch.
13 ---
14 config.def.h | 3 +++
15 dwm.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++----
16 2 files changed, 59 insertions(+), 4 deletions(-)
17
18 diff --git a/config.def.h b/config.def.h
19 index 1c0b587..6966237 100644
20 --- a/config.def.h
21 +++ b/config.def.h
22 @@ -36,6 +36,8 @@ static const float mfact = 0.55; /* factor of mast…
23 static const int nmaster = 1; /* number of clients in master are…
24 static const int resizehints = 1; /* 1 means respect size hints in t…
25
26 +static const int ratiofullscreenborders = 1;
27 +
28 static const Layout layouts[] = {
29 /* symbol arrange function */
30 { "[]=", tile }, /* first entry is default */
31 @@ -61,6 +63,7 @@ static const char *termcmd[] = { "st", NULL };
32
33 static Key keys[] = {
34 /* modifier key function argu…
35 + { MODKEY|ControlMask, XK_f, toggleratiofullscr, …
36 { MODKEY, XK_p, spawn, {.v …
37 { MODKEY|ShiftMask, XK_Return, spawn, {.v …
38 { MODKEY, XK_b, togglebar, {0} …
39 diff --git a/dwm.c b/dwm.c
40 index 3c94e4b..7b19235 100644
41 --- a/dwm.c
42 +++ b/dwm.c
43 @@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
44 static void tile(Monitor *);
45 static void togglebar(const Arg *arg);
46 static void togglefloating(const Arg *arg);
47 +static void toggleratiofullscr(const Arg *arg);
48 static void toggletag(const Arg *arg);
49 static void toggleview(const Arg *arg);
50 static void unfocus(Client *c, int setfocus);
51 @@ -802,7 +803,9 @@ focus(Client *c)
52 detachstack(c);
53 attachstack(c);
54 grabbuttons(c, 1);
55 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBord…
56 + if (!c->isfullscreen) {
57 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel]…
58 + }
59 setfocus(c);
60 } else {
61 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentT…
62 @@ -1482,10 +1485,49 @@ setfullscreen(Client *c, int fullscreen)
63 if (fullscreen && !c->isfullscreen) {
64 XChangeProperty(dpy, c->win, netatom[NetWMState], XA_AT…
65 PropModeReplace, (unsigned char*)&netatom[NetWM…
66 - c->isfullscreen = 1;
67 + c->isfullscreen = fullscreen;
68 c->oldstate = c->isfloating;
69 + c->oldbw = c->bw;
70 + c->bw = 0;
71 c->isfloating = 1;
72 - resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->…
73 + int nx, ny, nw, nh, bw;
74 + if (fullscreen == 1) {
75 + nx = c->mon->mx;
76 + ny = c->mon->my;
77 + nw = c->mon->mw;
78 + nh = c->mon->mh;
79 + bw = 0;
80 + } else if (fullscreen == 2) {
81 + if ((nw = c->w * c->mon->mh / c->h) < c->mon->m…
82 + nh = c->mon->mh;
83 + nx = (c->mon->mw - nw) / 2;
84 + if (!ratiofullscreenborders) {
85 + ny = c->mon->my;
86 + bw = 0;
87 + } else {
88 + ny = -nx;
89 + bw = nx;
90 + nx = 0;
91 + }
92 + } else {
93 + nw = c->mon->mw;
94 + nh = c->h * c->mon->mw / c->w;
95 + ny = (c->mon->mh - nh) / 2;
96 + if (!ratiofullscreenborders) {
97 + nx = c->mon->mx;
98 + bw = 0;
99 + } else {
100 + nx = -ny;
101 + bw = ny;
102 + ny = 0;
103 + }
104 + }
105 + XSetWindowBorder(dpy, c->win, BlackPixel(dpy, s…
106 + } else {
107 + printf("Invalid argument (%d) provided to setfu…
108 + return;
109 + }
110 + resizeclient(c, nx, ny, nw, nh, bw);
111 XRaiseWindow(dpy, c->win);
112 } else if (!fullscreen && c->isfullscreen){
113 XChangeProperty(dpy, c->win, netatom[NetWMState], XA_AT…
114 @@ -1498,6 +1540,7 @@ setfullscreen(Client *c, int fullscreen)
115 c->h = c->oldh;
116 c->bw = c->oldbw;
117 resizeclient(c, c->x, c->y, c->w, c->h, c->bw);
118 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBord…
119 arrange(c->mon);
120 }
121 }
122 @@ -1730,6 +1773,13 @@ togglefloating(const Arg *arg)
123 arrange(selmon);
124 }
125
126 +void
127 +toggleratiofullscr(const Arg *arg)
128 +{
129 + if(selmon->sel)
130 + setfullscreen(selmon->sel, !selmon->sel->isfullscreen * 2);
131 +}
132 +
133 void
134 toggletag(const Arg *arg)
135 {
136 @@ -1763,7 +1813,9 @@ unfocus(Client *c, int setfocus)
137 if (!c)
138 return;
139 grabbuttons(c, 0);
140 - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pix…
141 + if (!c->isfullscreen) {
142 + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBor…
143 + }
144 if (setfocus) {
145 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentT…
146 XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
147 --
148 2.32.0
149
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.