Skip to content

Commit 1c3a5be

Browse files
authored
released at 0.1.6
1 parent 7062a7f commit 1c3a5be

File tree

6 files changed

+45
-49
lines changed

6 files changed

+45
-49
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9999
## [0.1.5] - 2020-12-23
100100
### Removed
101101
- Unused root padding definitions.
102+
103+
## [0.1.6] - 2020-12-28
104+
### Added
105+
- Window fullscreen command alias (default: Win+f).

README

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Default keys and behavior can be customized via the config.h file:
2424
Win+Enter create new terminal window (default: st)
2525
Win+b create new browser window (default: surf)
2626
Win+q kill focused window
27+
Win+f full-screen focused window
2728
Win+Shift+q quit window manager
2829

2930
INSTALL

config.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
* window behavior.
2222
*/
2323

24-
#define WINDOW_X 600
25-
#define WINDOW_Y 400
26-
#define WINDOW_MIN_X 60
27-
#define WINDOW_MIN_Y 40
24+
#define WINDOW_WIDTH 600 /* pixels */
25+
#define WINDOW_HEIGHT 400 /* pixels */
26+
#define WINDOW_MIN_WIDTH 60 /* pixels */
27+
#define WINDOW_MIN_HEIGHT 40 /* pixels */
2828
#define BORDER_WIDTH 1 /* 0 = no border effect */
2929
#define BORDER_COLOR_UNFOCUSED 0x696969 /* 0xRRGGBB */
3030
#define BORDER_COLOR_FOCUSED 0xFFFFFF /* 0xRRGGBB */
@@ -50,6 +50,7 @@ static Key keys[] = {
5050
{ MOD1, 0x0062, spawn, browcmd }, /* 0x0062 = XK_b */
5151
{ MOD1, 0xff0d, spawn, termcmd }, /* 0xff0d = XK_Enter */
5252
{ MOD1, 0x0020, spawn, menucmd }, /* 0x0020 = XK_space */
53+
{ MOD1, 0x0066, fullclient, NULL }, /* 0x0066 = XK_f */
5354
{ MOD1, 0x0071, killclient, NULL }, /* 0x0071 = XK_q */
5455
{ MOD1|MOD2, 0x0071, closewm, NULL } /* 0x0071 = XK_q */
5556
};

xwm.1

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ Super;b;T{
6161
Create new browser window (default: surf).
6262
T}
6363
_
64+
Super;f;T{
65+
Full-screen focused window.
66+
T}
67+
_
6468
Super;q;T{
6569
Kill focused window.
6670
T}

xwm.c

+29-41
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ static void spawn(char **com) {
4040
wait(NULL);
4141
}
4242

43+
static void fullclient(char **com) {
44+
UNUSED(com);
45+
uint32_t vals[4];
46+
vals[0] = 0 - BORDER_WIDTH;
47+
vals[1] = 0 - BORDER_WIDTH;
48+
vals[2] = scre->width_in_pixels;
49+
vals[3] = scre->height_in_pixels;
50+
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_X |
51+
XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH |
52+
XCB_CONFIG_WINDOW_HEIGHT, vals);
53+
xcb_flush(dpy);
54+
}
55+
4356
static void handleButtonPress(xcb_generic_event_t * ev) {
4457
xcb_button_press_event_t * e = (xcb_button_press_event_t *) ev;
4558
win = e->child;
@@ -73,8 +86,8 @@ static void handleMotionNotify(xcb_generic_event_t * ev) {
7386
if (!((poin->root_x <= geom->x) || (poin->root_y <= geom->y))) {
7487
values[0] = poin->root_x - geom->x - BORDER_WIDTH;
7588
values[1] = poin->root_y - geom->y - BORDER_WIDTH;
76-
if ((values[0] >= (uint32_t)(WINDOW_MIN_X)) &&
77-
(values[1] >= (uint32_t)(WINDOW_MIN_Y))) {
89+
if ((values[0] >= (uint32_t)(WINDOW_MIN_WIDTH)) &&
90+
(values[1] >= (uint32_t)(WINDOW_MIN_HEIGHT))) {
7891
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_WIDTH
7992
| XCB_CONFIG_WINDOW_HEIGHT, values);
8093
}
@@ -105,7 +118,7 @@ static void setFocus(xcb_drawable_t window) {
105118
}
106119
}
107120

108-
static void setBorderColor(xcb_window_t window, int focus) {
121+
static void setFocusColor(xcb_window_t window, int focus) {
109122
if ((BORDER_WIDTH > 0) && (scre->root != window) && (0 != window)) {
110123
uint32_t vals[1];
111124
vals[0] = focus ? BORDER_COLOR_FOCUSED : BORDER_COLOR_UNFOCUSED;
@@ -114,37 +127,6 @@ static void setBorderColor(xcb_window_t window, int focus) {
114127
}
115128
}
116129

117-
static void setBorderWidth(xcb_window_t window) {
118-
if ((BORDER_WIDTH > 0) && (scre->root != window) && (0 != window)) {
119-
uint32_t vals[2];
120-
vals[0] = BORDER_WIDTH;
121-
xcb_configure_window(dpy, window, XCB_CONFIG_WINDOW_BORDER_WIDTH, vals);
122-
xcb_flush(dpy);
123-
}
124-
}
125-
126-
static void setWindowDimensions(xcb_window_t window) {
127-
if ((scre->root != window) && (0 != window)) {
128-
uint32_t vals[2];
129-
vals[0] = WINDOW_X;
130-
vals[1] = WINDOW_Y;
131-
xcb_configure_window(dpy, window, XCB_CONFIG_WINDOW_WIDTH |
132-
XCB_CONFIG_WINDOW_HEIGHT, vals);
133-
xcb_flush(dpy);
134-
}
135-
}
136-
137-
static void setWindowPosition(xcb_window_t window) {
138-
if ((scre->root != window) && (0 != window)) {
139-
uint32_t vals[2];
140-
vals[0] = (scre->width_in_pixels / 2) - (WINDOW_X / 2);
141-
vals[1] = (scre->height_in_pixels / 2) - (WINDOW_Y / 2);
142-
xcb_configure_window(dpy, window, XCB_CONFIG_WINDOW_X |
143-
XCB_CONFIG_WINDOW_Y, vals);
144-
xcb_flush(dpy);
145-
}
146-
}
147-
148130
static void handleKeyPress(xcb_generic_event_t * ev) {
149131
xcb_key_press_event_t * e = ( xcb_key_press_event_t *) ev;
150132
xcb_keysym_t keysym = xcb_get_keysym(e->detail);
@@ -174,20 +156,27 @@ static void handleDestroyNotify(xcb_generic_event_t * ev) {
174156

175157
static void handleFocusIn(xcb_generic_event_t * ev) {
176158
xcb_focus_in_event_t * e = (xcb_focus_in_event_t *) ev;
177-
setBorderColor(e->event, 1);
159+
setFocusColor(e->event, 1);
178160
}
179161

180162
static void handleFocusOut(xcb_generic_event_t * ev) {
181163
xcb_focus_out_event_t * e = (xcb_focus_out_event_t *) ev;
182-
setBorderColor(e->event, 0);
164+
setFocusColor(e->event, 0);
183165
}
184166

185167
static void handleMapRequest(xcb_generic_event_t * ev) {
186168
xcb_map_request_event_t * e = (xcb_map_request_event_t *) ev;
187169
xcb_map_window(dpy, e->window);
188-
setWindowDimensions(e->window);
189-
setWindowPosition(e->window);
190-
setBorderWidth(e->window);
170+
uint32_t vals[5];
171+
vals[0] = (scre->width_in_pixels / 2) - (WINDOW_WIDTH / 2);
172+
vals[1] = (scre->height_in_pixels / 2) - (WINDOW_HEIGHT / 2);
173+
vals[2] = WINDOW_WIDTH;
174+
vals[3] = WINDOW_HEIGHT;
175+
vals[4] = BORDER_WIDTH;
176+
xcb_configure_window(dpy, e->window, XCB_CONFIG_WINDOW_X |
177+
XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH |
178+
XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH, vals);
179+
xcb_flush(dpy);
191180
values[0] = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_FOCUS_CHANGE;
192181
xcb_change_window_attributes_checked(dpy, e->window,
193182
XCB_CW_EVENT_MASK, values);
@@ -226,7 +215,6 @@ static void setup(void) {
226215
}
227216
}
228217
xcb_flush(dpy);
229-
/* grab buttons */
230218
xcb_grab_button(dpy, 0, scre->root, XCB_EVENT_MASK_BUTTON_PRESS |
231219
XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_ASYNC,
232220
XCB_GRAB_MODE_ASYNC, scre->root, XCB_NONE, 1, MOD1);
@@ -264,7 +252,7 @@ static int strcmp_c(char * str1, char * str2) {
264252
int main(int argc, char * argv[]) {
265253
int ret = 0;
266254
if ((argc == 2) && (strcmp_c("-v", argv[1]) == 0)) {
267-
ret = die("xwm-0.1.5, © 2020 Michael Czigler, see LICENSE for details\n");
255+
ret = die("xwm-0.1.6, © 2020 Michael Czigler, see LICENSE for details\n");
268256
}
269257
if ((ret == 0) && (argc != 1)) {
270258
ret = die("usage: xwm [-v]\n");

xwm.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ static xcb_keysym_t xcb_get_keysym(xcb_keycode_t keycode);
2121
static void killclient(char **com);
2222
static void spawn(char **com);
2323
static void closewm(char ** com);
24+
static void fullclient(char ** com);
2425

2526
/* window behavior */
2627
static void setFocus(xcb_drawable_t window);
27-
static void setWindowDimensions(xcb_drawable_t window);
28-
static void setWindowPosition(xcb_drawable_t window);
29-
static void setBorderWidth(xcb_drawable_t window);
30-
static void setBorderColor(xcb_drawable_t window, int focus);
28+
static void setFocusColor(xcb_drawable_t window, int focus);
3129

3230
/* event hander actions */
3331
static int eventHandler(void);

0 commit comments

Comments
 (0)