Skip to content

Commit 01c96fb

Browse files
authored
released at 0.1.4
1 parent 90cb0fb commit 01c96fb

File tree

6 files changed

+48
-40
lines changed

6 files changed

+48
-40
lines changed

CHANGELOG

+12
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8383
### Changed
8484
- Default new window location from top-left to center.
8585

86+
## [0.1.4] - 2020-12-22
87+
### Added
88+
- Raise focus command keys to xwm.1 and README.
89+
90+
### Changed
91+
- The "Features" section of the README to indicate audience.
92+
93+
### Removed
94+
- Pointer warp on window resize/move as this appears to be default.
95+
96+
### Fixed
97+
- Spelling and grammar in man page.

README

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
xwm - a tiny XCB floating window manager
22

3-
FEATURES
4-
========
5-
6-
* Few features (just works)
7-
* Extensible & configurable
8-
* Focus follows mouse
3+
A minimal viable solution that was developed with single-monitor
4+
workflows in mind. Despite the small footprint, xwm maintains
5+
extensibility and can be customized to enhance the user experience.
96

10-
BUILD REQUIREMENTS
11-
==================
7+
REQUIREMENTS
8+
============
129

1310
xcb-util-keysyms, along with any default or user defined utilities:
14-
1511
application launcher https://git.suckless.org/dmenu
1612
terminal emulator https://git.suckless.org/st
1713
internet browser https://git.suckless.org/surf
@@ -20,7 +16,8 @@ COMMANDS
2016
========
2117

2218
Default keys and behavior can be customized via the config.h file:
23-
19+
Win+Button1 raise focused window to top of stack
20+
Win+Button3 raise focused window to top of stack
2421
Win+Button1+[drag] interactive window move
2522
Win+Button3+[drag] interactive window resize
2623
Win+Space run launcher menu (default: dmenu_run)
@@ -52,7 +49,7 @@ PATCHES
5249

5350
For additional features, I have provided a respository for sharing
5451
and hosting user created patches:
55-
https://github.com/mcpcpc/xwm-patches
52+
https://github.com/mcpcpc/xwm-community
5653

5754
EXAMPLES
5855
========

config.h

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

24+
#define ROOT_PADDING_TOP 0
25+
#define ROOT_PADDING_BOTTOM 0
26+
#define ROOT_PADDING_LEFT 0
27+
#define ROOT_PADDING_RIGHT 0
2428
#define WINDOW_X 600
2529
#define WINDOW_Y 400
2630
#define WINDOW_MIN_X 60
@@ -53,4 +57,3 @@ static Key keys[] = {
5357
{ MOD1, 0x0071, killclient, NULL }, /* 0x0071 = XK_q */
5458
{ MOD1|MOD2, 0x0071, closewm, NULL } /* 0x0071 = XK_q */
5559
};
56-

xwm.1

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.\"Manpage for xwm.
22
.TH XWM 1 "NOVEMBER 2020" Linux "User Manuals"
33
.SH NAME
4-
xwm \- a tiny XCB floating window managers
4+
xwm \- a tiny XCB floating window manager
55
.SH SYNOPSIS
66
.B xwm [-v]
77
.SH DESCRIPTION
88
.B xwm
99
is a tiny floating window manager implemented using
1010
the XCB protocol. Other than
11-
.BR libxcb (1),
11+
.BR xcb-util-keysyms (1),
1212
xwm relies on third-party tools, which can be
1313
configured or expanded to meet the user's preference.
1414
The default configuration provides support and
@@ -33,6 +33,14 @@ The default command key bindings are:
3333
tab(;);
3434
lb l l.
3535
_
36+
Super;MouseButton1;T{
37+
Raise focused window to top of stack.
38+
T}
39+
_
40+
Super;MouseButton3;T{
41+
Raise focused window to top of stack.
42+
T}
43+
_
3644
Super-MouseButton1;[drag];T{
3745
Interactive window move.
3846
T}

xwm.c

+14-25
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ static xcb_connection_t * dpy;
1212
static xcb_screen_t * scre;
1313
static xcb_drawable_t win;
1414
static uint32_t values[3];
15-
static uint32_t min_x = WINDOW_MIN_X;
16-
static uint32_t min_y = WINDOW_MIN_Y;
1715

1816
static void killclient(char **com) {
1917
UNUSED(com);
@@ -47,42 +45,36 @@ static void handleButtonPress(xcb_generic_event_t * ev) {
4745
win = e->child;
4846
values[0] = XCB_STACK_MODE_ABOVE;
4947
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_STACK_MODE, values);
50-
xcb_get_geometry_cookie_t geom_now = xcb_get_geometry(dpy, win);
51-
xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply(dpy, geom_now, NULL);
52-
if (1 == e->detail) {
53-
values[2] = 1;
54-
xcb_warp_pointer(dpy, XCB_NONE, win, 0, 0, 0, 0, 1, 1);
55-
} else if (win != 0) {
56-
values[2] = 3;
57-
xcb_warp_pointer(dpy, XCB_NONE, win, 0, 0, 0, 0, geom->width, geom->height);
58-
}
59-
else {}
48+
values[2] = ((1 == e->detail) ? 1 : ((win != 0) ? 3 : 0 ));
6049
xcb_grab_pointer(dpy, 0, scre->root, XCB_EVENT_MASK_BUTTON_RELEASE
6150
| XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_POINTER_MOTION_HINT,
62-
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, scre->root, XCB_NONE, XCB_CURRENT_TIME);
51+
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
52+
scre->root, XCB_NONE, XCB_CURRENT_TIME);
6353
}
6454

6555
static void handleMotionNotify(xcb_generic_event_t * ev) {
6656
UNUSED(ev);
6757
xcb_query_pointer_cookie_t coord = xcb_query_pointer(dpy, scre->root);
6858
xcb_query_pointer_reply_t * poin = xcb_query_pointer_reply(dpy, coord, 0);
69-
uint32_t val[2] = {1, 3};
70-
if ((values[2] == val[0]) && (win != 0)) {
59+
if ((values[2] == (uint32_t)(1)) && (win != 0)) {
7160
xcb_get_geometry_cookie_t geom_now = xcb_get_geometry(dpy, win);
7261
xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply(dpy, geom_now, NULL);
73-
values[0] = ((poin->root_x + geom->width + (2 * BORDER_WIDTH)) > scre->width_in_pixels) ?
74-
(scre->width_in_pixels - geom->width - (2 * BORDER_WIDTH)) : poin->root_x;
75-
values[1] = ((poin->root_y + geom->height + (2 * BORDER_WIDTH)) > scre->height_in_pixels) ?
76-
(scre->height_in_pixels - geom->height - (2 * BORDER_WIDTH)) : poin->root_y;
62+
uint16_t geom_x = geom->width + (2 * BORDER_WIDTH);
63+
uint16_t geom_y = geom->height + (2 * BORDER_WIDTH);
64+
values[0] = ((poin->root_x + geom_x) > scre->width_in_pixels) ?
65+
(scre->width_in_pixels - geom_x) : poin->root_x;
66+
values[1] = ((poin->root_y + geom_y) > scre->height_in_pixels) ?
67+
(scre->height_in_pixels - geom_y) : poin->root_y;
7768
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_X
7869
| XCB_CONFIG_WINDOW_Y, values);
79-
} else if ((values[2] == val[1]) && (win != 0)) {
70+
} else if ((values[2] == (uint32_t)(3)) && (win != 0)) {
8071
xcb_get_geometry_cookie_t geom_now = xcb_get_geometry(dpy, win);
8172
xcb_get_geometry_reply_t* geom = xcb_get_geometry_reply(dpy, geom_now, NULL);
8273
if (!((poin->root_x <= geom->x) || (poin->root_y <= geom->y))) {
8374
values[0] = poin->root_x - geom->x - BORDER_WIDTH;
8475
values[1] = poin->root_y - geom->y - BORDER_WIDTH;
85-
if ((values[0] >= min_x) && (values[1] >= min_y)) {
76+
if ((values[0] >= (uint32_t)(WINDOW_MIN_X)) &&
77+
(values[1] >= (uint32_t)(WINDOW_MIN_Y))) {
8678
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_WIDTH
8779
| XCB_CONFIG_WINDOW_HEIGHT, values);
8880
}
@@ -218,14 +210,12 @@ static int eventHandler(void) {
218210
}
219211

220212
static void setup(void) {
221-
/* subscribe to events */
222213
values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
223214
| XCB_EVENT_MASK_STRUCTURE_NOTIFY
224215
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY
225216
| XCB_EVENT_MASK_PROPERTY_CHANGE;
226217
xcb_change_window_attributes_checked(dpy, scre->root,
227218
XCB_CW_EVENT_MASK, values);
228-
/* grab keys */
229219
xcb_ungrab_key(dpy, XCB_GRAB_ANY, scre->root, XCB_MOD_MASK_ANY);
230220
int key_table_size = sizeof(keys) / sizeof(*keys);
231221
for (int i = 0; i < key_table_size; ++i) {
@@ -274,7 +264,7 @@ static int strcmp_c(char * str1, char * str2) {
274264
int main(int argc, char * argv[]) {
275265
int ret = 0;
276266
if ((argc == 2) && (strcmp_c("-v", argv[1]) == 0)) {
277-
ret = die("xwm-0.1.3, © 2020 Michael Czigler, see LICENSE for details\n");
267+
ret = die("xwm-0.1.4, © 2020 Michael Czigler, see LICENSE for details\n");
278268
}
279269
if ((ret == 0) && (argc != 1)) {
280270
ret = die("usage: xwm [-v]\n");
@@ -295,4 +285,3 @@ int main(int argc, char * argv[]) {
295285
}
296286
return ret;
297287
}
298-

xwm.h

-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ static void setup(void);
5959
/* error handling & misc. */
6060
static int die(char * errstr);
6161
static int strcmp_c(char * str1, char * str2);
62-

0 commit comments

Comments
 (0)