mirror of
https://github.com/vale981/bspwm
synced 2025-03-05 09:51:38 -05:00
New setting: fit_monitor
This commit is contained in:
parent
44ab9fc037
commit
ae1ed3b795
12 changed files with 43 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
_bspc() {
|
||||
local commands='window desktop monitor query pointer rule restore control config quit'
|
||||
|
||||
local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color focused_frame_opacity active_frame_opacity normal_frame_opacity border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio growth_factor borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus honor_ewmh_focus'
|
||||
local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color focused_frame_opacity active_frame_opacity normal_frame_opacity border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio growth_factor borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus honor_ewmh_focus fit_monitor'
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
_bspc() {
|
||||
local -a commands settings
|
||||
commands=('window' 'desktop' 'monitor' 'query' 'pointer' 'rule' 'restore' 'control' 'config' 'quit')
|
||||
settings=('focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'focused_frame_opacity' 'active_frame_opacity' 'normal_frame_opacity' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'growth_factor' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'honor_ewmh_focus')
|
||||
settings=('focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'focused_frame_opacity' 'active_frame_opacity' 'normal_frame_opacity' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'growth_factor' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'honor_ewmh_focus' 'fit_monitor')
|
||||
if (( CURRENT == 2 )) ; then
|
||||
_values 'command' "$commands[@]"
|
||||
elif (( CURRENT == 3 )) ; then
|
||||
|
|
|
@ -93,7 +93,7 @@ void transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d)
|
|||
}
|
||||
|
||||
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
|
||||
fit_monitor(ms, md, n);
|
||||
translate_position(ms, md, n);
|
||||
|
||||
arrange(md, d);
|
||||
|
||||
|
@ -252,9 +252,9 @@ void swap_desktops(monitor_t *m1, desktop_t *d1, monitor_t *m2, desktop_t *d2)
|
|||
|
||||
if (m1 != m2) {
|
||||
for (node_t *n = first_extrema(d1->root); n != NULL; n = next_leaf(n, d1->root))
|
||||
fit_monitor(m1, m2, n);
|
||||
translate_position(m1, m2, n);
|
||||
for (node_t *n = first_extrema(d2->root); n != NULL; n = next_leaf(n, d2->root))
|
||||
fit_monitor(m2, m1, n);
|
||||
translate_position(m2, m1, n);
|
||||
history_swap_desktops(m1, d1, m2, d2);
|
||||
arrange(m1, d2);
|
||||
arrange(m2, d1);
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
.\" Title: bspwm
|
||||
.\" Author: [see the "Author" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||
.\" Date: 10/20/2013
|
||||
.\" Date: 10/23/2013
|
||||
.\" Manual: Bspwm Manual
|
||||
.\" Source: Bspwm 0.8.6
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "BSPWM" "1" "10/20/2013" "Bspwm 0\&.8\&.6" "Bspwm Manual"
|
||||
.TH "BSPWM" "1" "10/23/2013" "Bspwm 0\&.8\&.6" "Bspwm Manual"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
|
@ -1053,6 +1053,11 @@ atom of each window according to its floating state\&.
|
|||
.RS 4
|
||||
Honor EWMH requests to focus a window\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIfit_monitor\fR
|
||||
.RS 4
|
||||
Keep floating windows inside their monitor\&.
|
||||
.RE
|
||||
.SS "Monitor Settings"
|
||||
.PP
|
||||
\fItop_padding\fR, \fIright_padding\fR, \fIbottom_padding\fR, \fIleft_padding\fR
|
||||
|
|
|
@ -639,6 +639,9 @@ Global Settings
|
|||
'honor_ewmh_focus'::
|
||||
Honor EWMH requests to focus a window.
|
||||
|
||||
'fit_monitor'::
|
||||
Keep floating windows inside their monitor.
|
||||
|
||||
Monitor Settings
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -931,6 +931,7 @@ bool set_setting(coordinates_t loc, char *name, char *value)
|
|||
SETBOOL(auto_cancel)
|
||||
SETBOOL(history_aware_focus)
|
||||
SETBOOL(honor_ewmh_focus)
|
||||
SETBOOL(fit_monitor)
|
||||
#undef SETBOOL
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1004,6 +1005,7 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
|
|||
GETBOOL(auto_cancel)
|
||||
GETBOOL(history_aware_focus)
|
||||
GETBOOL(honor_ewmh_focus)
|
||||
GETBOOL(fit_monitor)
|
||||
#undef GETBOOL
|
||||
else
|
||||
return false;
|
||||
|
|
31
monitor.c
31
monitor.c
|
@ -71,13 +71,15 @@ monitor_t *get_monitor_by_id(xcb_randr_output_t id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n)
|
||||
void translate_position(monitor_t *ms, monitor_t *md, node_t *n)
|
||||
{
|
||||
if (frozen_pointer->action != ACTION_NONE)
|
||||
return;
|
||||
|
||||
xcb_rectangle_t a = ms->rectangle;
|
||||
xcb_rectangle_t b = md->rectangle;
|
||||
xcb_rectangle_t *r = &n->client->floating_rectangle;
|
||||
|
||||
if (ms != md) {
|
||||
double w = b.width;
|
||||
double h = b.height;
|
||||
|
@ -86,17 +88,20 @@ void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n)
|
|||
r->x = b.x + dx;
|
||||
r->y = b.y + dy;
|
||||
}
|
||||
if (r->x <= b.x || (r->x + r->width) >= (b.x + b.width)) {
|
||||
if (r->width >= b.width)
|
||||
r->x = b.x;
|
||||
else
|
||||
r->x = b.x + (b.width - r->width) / 2;
|
||||
}
|
||||
if (r->y <= b.y || (r->y + r->height) >= (b.y + b.height)) {
|
||||
if (r->height >= b.height)
|
||||
r->y = b.y;
|
||||
else
|
||||
r->y = b.y + (b.height - r->height) / 2;
|
||||
|
||||
if (fit_monitor) {
|
||||
if (r->x <= b.x || (r->x + r->width) >= (b.x + b.width)) {
|
||||
if (r->width >= b.width)
|
||||
r->x = b.x;
|
||||
else
|
||||
r->x = b.x + (b.width - r->width) / 2;
|
||||
}
|
||||
if (r->y <= b.y || (r->y + r->height) >= (b.y + b.height)) {
|
||||
if (r->height >= b.height)
|
||||
r->y = b.y;
|
||||
else
|
||||
r->y = b.y + (b.height - r->height) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +302,7 @@ bool import_monitors(void)
|
|||
update_root(mm);
|
||||
for (desktop_t *d = mm->desk_head; d != NULL; d = d->next)
|
||||
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
|
||||
fit_monitor(mm, mm, n);
|
||||
translate_position(mm, mm, n);
|
||||
arrange(mm, mm->desk);
|
||||
mm->wired = true;
|
||||
PRINTF("update monitor %s (0x%X)\n", mm->name, mm->id);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
monitor_t *make_monitor(xcb_rectangle_t rect);
|
||||
monitor_t *find_monitor(char *name);
|
||||
monitor_t *get_monitor_by_id(xcb_randr_output_t id);
|
||||
void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n);
|
||||
void translate_position(monitor_t *ms, monitor_t *md, node_t *n);
|
||||
void update_root(monitor_t *m);
|
||||
void focus_monitor(monitor_t *m);
|
||||
monitor_t *add_monitor(xcb_rectangle_t rect);
|
||||
|
|
|
@ -77,4 +77,5 @@ void load_settings(void)
|
|||
auto_cancel = AUTO_CANCEL;
|
||||
history_aware_focus = HISTORY_AWARE_FOCUS;
|
||||
honor_ewmh_focus = HONOR_EWMH_FOCUS;
|
||||
fit_monitor = FIT_MONITOR;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#define AUTO_CANCEL false
|
||||
#define APPLY_FLOATING_ATOM false
|
||||
#define HONOR_EWMH_FOCUS false
|
||||
#define FIT_MONITOR false
|
||||
|
||||
char focused_border_color[MAXLEN];
|
||||
char active_border_color[MAXLEN];
|
||||
|
@ -94,6 +95,7 @@ bool auto_alternate;
|
|||
bool auto_cancel;
|
||||
bool history_aware_focus;
|
||||
bool honor_ewmh_focus;
|
||||
bool fit_monitor;
|
||||
|
||||
void run_config(void);
|
||||
void load_settings(void);
|
||||
|
|
6
tree.c
6
tree.c
|
@ -968,8 +968,8 @@ bool swap_nodes(monitor_t *m1, desktop_t *d1, node_t *n1, monitor_t *m2, desktop
|
|||
d2->focus = n1;
|
||||
|
||||
if (m1 != m2) {
|
||||
fit_monitor(m2, m1, n2);
|
||||
fit_monitor(m1, m2, n1);
|
||||
translate_position(m2, m1, n2);
|
||||
translate_position(m1, m2, n1);
|
||||
}
|
||||
|
||||
ewmh_set_wm_desktop(n1, d2);
|
||||
|
@ -1007,7 +1007,7 @@ bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desk
|
|||
insert_node(md, dd, ns, nd);
|
||||
|
||||
if (md != ms)
|
||||
fit_monitor(ms, md, ns);
|
||||
translate_position(ms, md, ns);
|
||||
|
||||
if (ds != dd) {
|
||||
ewmh_set_wm_desktop(ns, dd);
|
||||
|
|
2
window.c
2
window.c
|
@ -78,7 +78,7 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
|
|||
n->client = c;
|
||||
|
||||
insert_node(m, d, n, d->focus);
|
||||
fit_monitor(m, m, n);
|
||||
translate_position(m, m, n);
|
||||
|
||||
disable_floating_atom(c->window);
|
||||
set_floating(n, floating);
|
||||
|
|
Loading…
Add table
Reference in a new issue