Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add window resize hints support #32

Merged
merged 3 commits into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static struct ConfigEntry configs[] = {
{ "cursor_position" , IPCConfigCursorPosition , fn_position },
{ "groups_nr" , IPCConfigGroupsNr , fn_naturals },
{ "enable_sloppy_focus" , IPCConfigEnableSloppyFocus , fn_bool },
{ "enable_resize_hints" , IPCConfigEnableResizeHints , fn_bool },
{ "sticky_windows" , IPCConfigStickyWindows , fn_bool },
{ "enable_borders" , IPCConfigEnableBorders , fn_bool },
{ "enable_last_window_focusing", IPCConfigEnableLastWindowFocusing, fn_bool },
Expand Down
3 changes: 3 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
/* focus windows after hovering them with the pointer */
#define SLOPPY_FOCUS true

/* respect window resize hints */
#define RESIZE_HINTS false

/* if true, new windows will be assigned to the last activated group */
#define STICKY_WINDOWS false

Expand Down
1 change: 1 addition & 0 deletions examples/windowchefrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ waitron wm_config gap_width all 0
waitron wm_config grid_gap_width 0
waitron wm_config cursor_position middle
waitron wm_config groups_nr 9
waitron wm_config enable_resize_hints false
waitron wm_config enable_sloppy_focus true
waitron wm_config sticky_windows false
waitron wm_config enable_borders true
Expand Down
1 change: 1 addition & 0 deletions ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum IPCConfig {
IPCConfigCursorPosition,
IPCConfigGroupsNr,
IPCConfigEnableSloppyFocus,
IPCConfigEnableResizeHints,
IPCConfigStickyWindows,
IPCConfigEnableBorders,
IPCConfigEnableLastWindowFocusing,
Expand Down
2 changes: 2 additions & 0 deletions types.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct client {
struct monitor *monitor;
uint16_t min_width, min_height;
uint16_t max_width, max_height;
uint16_t width_inc, height_inc;
bool mapped;
uint32_t group;
};
Expand All @@ -71,6 +72,7 @@ struct conf {
enum position cursor_position;
uint32_t groups;
bool sloppy_focus;
bool resize_hints;
bool sticky_windows;
bool borders;
bool last_window_focusing;
Expand Down
14 changes: 12 additions & 2 deletions wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ setup_window(xcb_window_t win)
client->geom.x = client->geom.y = client->geom.width
= client->geom.height
= client->min_width = client->min_height = 0;
client->width_inc = client->height_inc = 1;
client->maxed = client->hmaxed = client->vmaxed
= client->monocled = client->geom.set_by_user = false;
client->monitor = NULL;
Expand All @@ -677,6 +678,12 @@ setup_window(xcb_window_t win)
client->min_height = hints.min_height;
}

if (hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC &&
conf.resize_hints) {
client->width_inc = hints.width_inc;
client->height_inc = hints.height_inc;
}

DMSG("new window was born 0x%08x\n", client->window);

return client;
Expand Down Expand Up @@ -2166,11 +2173,11 @@ event_configure_request(xcb_generic_event_t *ev)

if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH
&& !client->maxed && !client->monocled && !client->hmaxed)
client->geom.width= e->width;
client->geom.width = e->width - (e->width % client->width_inc);

if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT
&& !client->maxed && !client->monocled && !client->vmaxed)
client->geom.height = e->height;
client->geom.height = e->height - (e->height % client->height_inc);

if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
values[0] = e->stack_mode;
Expand Down Expand Up @@ -2911,6 +2918,8 @@ ipc_wm_config(uint32_t *d)
case IPCConfigEnableSloppyFocus:
conf.sloppy_focus = d[1];
break;
case IPCConfigEnableResizeHints:
conf.resize_hints = d[1];
case IPCConfigStickyWindows:
conf.sticky_windows = d[1];
break;
Expand Down Expand Up @@ -2958,6 +2967,7 @@ load_defaults(void)
conf.cursor_position = CURSOR_POSITION;
conf.groups = GROUPS;
conf.sloppy_focus = SLOPPY_FOCUS;
conf.resize_hints = RESIZE_HINTS;
conf.sticky_windows = STICKY_WINDOWS;
conf.borders = BORDERS;
conf.last_window_focusing = LAST_WINDOW_FOCUSING;
Expand Down