Skip to content

Commit

Permalink
new config options
Browse files Browse the repository at this point in the history
  • Loading branch information
tudurom committed May 12, 2017
1 parent 1f2c04f commit 2c3a5d2
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 45 deletions.
2 changes: 2 additions & 0 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static struct Command c[] = {
{ "window_resize" , IPCWindowResize , 2 , fn_offset } ,
{ "window_resize_absolute" , IPCWindowResizeAbsolute , 2 , fn_naturals } ,
{ "window_maximize" , IPCWindowMaximize , 0 , NULL } ,
{ "window_unmaximize" , IPCWindowUnmaximize , 0 , NULL } ,
{ "window_hor_maximize" , IPCWindowHorMaximize , 0 , NULL } ,
{ "window_ver_maximize" , IPCWindowVerMaximize , 0 , NULL } ,
{ "window_monocle" , IPCWindowMonocle , 0 , NULL } ,
Expand Down Expand Up @@ -88,6 +89,7 @@ static struct ConfigEntry configs[] = {
{ "sticky_windows" , IPCConfigStickyWindows , fn_bool },
{ "enable_borders" , IPCConfigEnableBorders , fn_bool },
{ "enable_last_window_focusing", IPCConfigEnableLastWindowFocusing, fn_bool },
{ "apply_settings" , IPCConfigApplySettings , fn_bool },
};

/*
Expand Down
3 changes: 3 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@
/* if true, focus last window when the currently focused window is unmapped */
#define LAST_WINDOW_FOCUSING true

/* if true, apply settings on windows when they are set (like border color, border width) */
#define APPLY_SETTINGS true

#endif
2 changes: 2 additions & 0 deletions ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum IPCCommand {
IPCWindowResize,
IPCWindowResizeAbsolute,
IPCWindowMaximize,
IPCWindowUnmaximize,
IPCWindowHorMaximize,
IPCWindowVerMaximize,
IPCWindowMonocle,
Expand Down Expand Up @@ -51,6 +52,7 @@ enum IPCConfig {
IPCConfigStickyWindows,
IPCConfigEnableBorders,
IPCConfigEnableLastWindowFocusing,
IPCConfigApplySettings,
NR_IPC_CONFIGS
};

Expand Down
10 changes: 9 additions & 1 deletion man/waitron.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" https://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "WAITRON" "1" "March 2017" "Windowchef" "Windowchef Manual"
.TH "WAITRON" "1" "May 2017" "Windowchef" "Windowchef Manual"
.
.SH "NAME"
\fBwaitron\fR \- A client for windowchef(1)
Expand Down Expand Up @@ -62,6 +62,10 @@ Resize the focused window up to \fIwidth\fR and \fIheight\fR\.
Hide the border and maximize the focused window on the current monitor\. Execute it again after maximizing to revert the state of the window\.
.
.TP
\fBwindow_unmaximize\fR
If the currently focused window is maximized in any way (fully, vertically, horizontally, monocled), return it to normal state\.
.
.TP
\fBwindow_hor_maximize\fR
Horizontally maximize the focused window on the current monitor, preserving its \fIx\fR component\. Leaves a gap at the left and right of the monitor that can be configured\. Execute it again after maximizing to revert the state of the window\.
.
Expand Down Expand Up @@ -222,6 +226,10 @@ If true, border colors will be set each time a window gets/loses focus\. Setting
\fBenable_last_window_focusing\fR \fIBOOL\fR
If true, when the currently focused window is unmapped or closed, \fBwindowchef\fR will focus the previously focused window\. See the \fBwindow_focus_last\fR command\.
.
.TP
\fBapply_settings\fR \fIBOOL\fR
If true, then some settings will be applied on all windows instead of newly created windows\. True by default\.
.
.SH "SEE ALSO"
windowchef(1), sxhkd(1), wmutils(1), pfw(1), lsw(1), chwb2(1), lemonbar(1)
.
Expand Down
5 changes: 4 additions & 1 deletion man/waitron.1.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions man/waitron.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ anything on `stdout`.
Hide the border and maximize the focused window on the current monitor.
Execute it again after maximizing to revert the state of the window.

* `window_unmaximize`:
If the currently focused window is maximized in any way (fully, vertically, horizontally, monocled), return it to normal state.

* `window_hor_maximize`:
Horizontally maximize the focused window on the current monitor, preserving
its <x> component. Leaves a gap at the left and right of the monitor that
Expand Down Expand Up @@ -196,6 +199,10 @@ are:
If true, when the currently focused window is unmapped or closed, `windowchef` will focus the
previously focused window. See the `window_focus_last` command.

* `apply_settings` <BOOL>:
If true, then some settings will be applied on all windows instead of newly created windows.
True by default.

## SEE ALSO

windowchef(1), sxhkd(1), wmutils(1), pfw(1), lsw(1), chwb2(1), lemonbar(1)
Expand Down
2 changes: 2 additions & 0 deletions types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define _TYPES_H

#include <xcb/randr.h>
#include <stdbool.h>

enum position {
BOTTOM_LEFT,
Expand Down Expand Up @@ -73,6 +74,7 @@ struct conf {
bool sticky_windows;
bool borders;
bool last_window_focusing;
bool apply_settings;
};

#endif
118 changes: 75 additions & 43 deletions wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static void ipc_window_move_absolute(uint32_t *);
static void ipc_window_resize(uint32_t *);
static void ipc_window_resize_absolute(uint32_t *);
static void ipc_window_maximize(uint32_t *);
static void ipc_window_unmaximize(uint32_t *);
static void ipc_window_hor_maximize(uint32_t *);
static void ipc_window_ver_maximize(uint32_t *);
static void ipc_window_monocle(uint32_t *);
Expand Down Expand Up @@ -1910,6 +1911,9 @@ change_nr_of_groups(uint32_t groups)
static void
refresh_borders(void)
{
if (!conf.apply_settings)
return;

struct list_item *item;
struct client *client;

Expand Down Expand Up @@ -2069,6 +2073,11 @@ snap_window(struct client *client, enum position pos)
xcb_flush(conn);
}


/*
* Put window in grid.
*/

static void
grid_window(struct client *client, uint32_t grid_width, uint32_t grid_height, uint32_t grid_x, uint32_t grid_y)
{
Expand Down Expand Up @@ -2477,6 +2486,7 @@ register_ipc_handlers(void)
ipc_handlers[IPCWindowResize] = ipc_window_resize;
ipc_handlers[IPCWindowResizeAbsolute] = ipc_window_resize_absolute;
ipc_handlers[IPCWindowMaximize] = ipc_window_maximize;
ipc_handlers[IPCWindowUnmaximize] = ipc_window_unmaximize;
ipc_handlers[IPCWindowHorMaximize] = ipc_window_hor_maximize;
ipc_handlers[IPCWindowVerMaximize] = ipc_window_ver_maximize;
ipc_handlers[IPCWindowMonocle] = ipc_window_monocle;
Expand Down Expand Up @@ -2632,6 +2642,21 @@ ipc_window_maximize(uint32_t *d)
xcb_flush(conn);
}

static void
ipc_window_unmaximize(uint32_t *d)
{
(void)(d);

if (focused_win == NULL)
return;

unmaximize_window(focused_win);

set_focused(focused_win);

xcb_flush(conn);
}

static void
ipc_window_hor_maximize(uint32_t *d)
{
Expand Down Expand Up @@ -2849,52 +2874,58 @@ ipc_wm_config(uint32_t *d)
key = d[0];

switch (key) {
case IPCConfigBorderWidth:
conf.border_width = d[1];
case IPCConfigBorderWidth:
conf.border_width = d[1];
if (conf.apply_settings)
refresh_borders();
break;
case IPCConfigColorFocused:
conf.focus_color = d[1];
break;
case IPCConfigColorFocused:
conf.focus_color = d[1];
if (conf.apply_settings)
refresh_borders();
break;
case IPCConfigColorUnfocused:
conf.unfocus_color = d[1];
break;
case IPCConfigColorUnfocused:
conf.unfocus_color = d[1];
if (conf.apply_settings)
refresh_borders();
break;
case IPCConfigGapWidth:
switch (d[1]) {
case LEFT: conf.gap_left = d[2]; break;
case BOTTOM: conf.gap_down = d[2]; break;
case TOP: conf.gap_up = d[2]; break;
case RIGHT: conf.gap_right = d[2]; break;
case ALL: conf.gap_left = conf.gap_down
= conf.gap_up = conf.gap_right = d[2];
default: break;
}
break;
case IPCConfigGridGapWidth:
conf.grid_gap = d[1];
case IPCConfigCursorPosition:
conf.cursor_position = d[1];
break;
case IPCConfigGroupsNr:
change_nr_of_groups(d[1]);
break;
case IPCConfigEnableSloppyFocus:
conf.sloppy_focus = d[1];
break;
case IPCConfigStickyWindows:
conf.sticky_windows = d[1];
break;
case IPCConfigEnableBorders:
conf.borders = d[1];
break;
case IPCConfigEnableLastWindowFocusing:
conf.last_window_focusing = d[1];
break;
default:
DMSG("!!! unhandled config key %d\n", key);
break;
break;
case IPCConfigGapWidth:
switch (d[1]) {
case LEFT: conf.gap_left = d[2]; break;
case BOTTOM: conf.gap_down = d[2]; break;
case TOP: conf.gap_up = d[2]; break;
case RIGHT: conf.gap_right = d[2]; break;
case ALL: conf.gap_left = conf.gap_down
= conf.gap_up = conf.gap_right = d[2];
default: break;
}
break;
case IPCConfigGridGapWidth:
conf.grid_gap = d[1];
case IPCConfigCursorPosition:
conf.cursor_position = d[1];
break;
case IPCConfigGroupsNr:
change_nr_of_groups(d[1]);
break;
case IPCConfigEnableSloppyFocus:
conf.sloppy_focus = d[1];
break;
case IPCConfigStickyWindows:
conf.sticky_windows = d[1];
break;
case IPCConfigEnableBorders:
conf.borders = d[1];
break;
case IPCConfigEnableLastWindowFocusing:
conf.last_window_focusing = d[1];
break;
case IPCConfigApplySettings:
conf.apply_settings = d[1];
break;
default:
DMSG("!!! unhandled config key %d\n", key);
break;
}
}

Expand Down Expand Up @@ -2930,6 +2961,7 @@ load_defaults(void)
conf.sticky_windows = STICKY_WINDOWS;
conf.borders = BORDERS;
conf.last_window_focusing = LAST_WINDOW_FOCUSING;
conf.apply_settings = APPLY_SETTINGS;
}

static void
Expand Down

0 comments on commit 2c3a5d2

Please sign in to comment.