Add new setting: hide_by_moving

This commit is contained in:
Bastien Dejean 2018-08-29 17:17:14 +02:00
parent 56ad57c952
commit d2b13147d1
9 changed files with 96 additions and 50 deletions

View file

@ -499,7 +499,7 @@ void show_desktop(desktop_t *d)
if (d == NULL) {
return;
}
show_node(d, d->root);
show_node(d, d->root, hide_by_moving);
}
void hide_desktop(desktop_t *d)
@ -507,7 +507,7 @@ void hide_desktop(desktop_t *d)
if (d == NULL) {
return;
}
hide_node(d, d->root);
hide_node(d, d->root, hide_by_moving);
}
bool is_urgent(desktop_t *d)

View file

@ -1618,9 +1618,9 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
focus_follows_pointer = b;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
if (focus_follows_pointer) {
window_show(m->root);
window_show(m->root, false);
} else {
window_hide(m->root);
window_hide(m->root, false);
}
for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
listen_enter_notify(d->root, focus_follows_pointer);
@ -1650,6 +1650,7 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
SET_BOOL(pointer_follows_focus)
SET_BOOL(pointer_follows_monitor)
SET_BOOL(ignore_ewmh_focus)
SET_BOOL(hide_by_moving)
SET_BOOL(center_pseudo_tiled)
SET_BOOL(honor_size_hints)
#undef SET_BOOL
@ -1768,6 +1769,7 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
GET_BOOL(pointer_follows_focus)
GET_BOOL(pointer_follows_monitor)
GET_BOOL(ignore_ewmh_focus)
GET_BOOL(hide_by_moving)
GET_BOOL(center_pseudo_tiled)
GET_BOOL(honor_size_hints)
GET_BOOL(remove_disabled_monitors)

View file

@ -77,7 +77,7 @@ void update_root(monitor_t *m, xcb_rectangle_t *rect)
xcb_icccm_set_wm_name(dpy, m->root, XCB_ATOM_STRING, 8, strlen(m->name), m->name);
window_lower(m->root);
if (focus_follows_pointer) {
window_show(m->root);
window_show(m->root, false);
}
} else {
window_move_resize(m->root, rect->x, rect->y, rect->width, rect->height);

View file

@ -79,6 +79,7 @@ void load_settings(void)
ignore_ewmh_focus = IGNORE_EWMH_FOCUS;
ignore_ewmh_fullscreen = IGNORE_EWMH_FULLSCREEN;
hide_by_moving = HIDE_BY_MOVING;
center_pseudo_tiled = CENTER_PSEUDO_TILED;
honor_size_hints = HONOR_SIZE_HINTS;

View file

@ -55,6 +55,7 @@
#define IGNORE_EWMH_FOCUS false
#define IGNORE_EWMH_FULLSCREEN 0
#define HIDE_BY_MOVING false
#define CENTER_PSEUDO_TILED true
#define HONOR_SIZE_HINTS false
#define MAPPING_EVENTS_COUNT 1
@ -96,6 +97,7 @@ bool swallow_first_click;
bool ignore_ewmh_focus;
state_transition_t ignore_ewmh_fullscreen;
bool hide_by_moving;
bool center_pseudo_tiled;
bool honor_size_hints;

View file

@ -86,6 +86,10 @@ void apply_layout(monitor_t *m, desktop_t *d, node_t *n, layout_t l, xcb_rectang
center_pointer(r);
}
if (n->hidden) {
return;
}
if (n->presel != NULL) {
draw_presel_feedback(m, d, n);
}
@ -139,7 +143,12 @@ void apply_layout(monitor_t *m, desktop_t *d, node_t *n, layout_t l, xcb_rectang
apply_size_hints(n->client, &r.width, &r.height);
if (!rect_eq(r, cr)) {
window_move_resize(n->id, r.x, r.y, r.width, r.height);
if (m->desk == d || !hide_by_moving) {
window_move_resize(n->id, r.x, r.y, r.width, r.height);
} else {
int16_t x = -(r.x + (int16_t) r.width + (int16_t) (2 * bw));
window_move_resize(n->id, x, r.y, r.width, r.height);
}
if (!grabbing) {
put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", m->id, d->id, n->id, r.width, r.height, r.x, r.y);
}
@ -626,45 +635,45 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
return true;
}
void hide_node(desktop_t *d, node_t *n)
void hide_node(desktop_t *d, node_t *n, bool move)
{
if (n == NULL) {
return;
} else {
if (!n->hidden) {
if (n->presel != NULL && d->layout != LAYOUT_MONOCLE) {
window_hide(n->presel->feedback);
window_hide(n->presel->feedback, false);
}
if (n->client != NULL) {
window_hide(n->id);
window_hide(n->id, move);
}
}
if (n->client != NULL) {
n->client->shown = false;
}
hide_node(d, n->first_child);
hide_node(d, n->second_child);
hide_node(d, n->first_child, move);
hide_node(d, n->second_child, move);
}
}
void show_node(desktop_t *d, node_t *n)
void show_node(desktop_t *d, node_t *n, bool move)
{
if (n == NULL) {
return;
} else {
if (!n->hidden) {
if (n->client != NULL) {
window_show(n->id);
window_show(n->id, move);
}
if (n->presel != NULL && d->layout != LAYOUT_MONOCLE) {
window_show(n->presel->feedback);
window_show(n->presel->feedback, false);
}
}
if (n->client != NULL) {
n->client->shown = true;
}
show_node(d, n->first_child);
show_node(d, n->second_child);
show_node(d, n->first_child, move);
show_node(d, n->second_child, move);
}
}
@ -1358,15 +1367,15 @@ bool swap_nodes(monitor_t *m1, desktop_t *d1, node_t *n1, monitor_t *m2, desktop
bool d2_was_focused = (d2 == mon->desk);
if (m1->desk != d1 && m2->desk == d2) {
show_node(d2, n1);
show_node(d2, n1, hide_by_moving);
if (!follow || !d2_was_focused || !n2_held_focus) {
hide_node(d2, n2);
hide_node(d2, n2, hide_by_moving);
}
} else if (m1->desk == d1 && m2->desk != d2) {
if (!follow || !d1_was_focused || !n1_held_focus) {
hide_node(d1, n1);
hide_node(d1, n1, hide_by_moving);
}
show_node(d1, n2);
show_node(d1, n2, hide_by_moving);
}
if (n1_held_focus) {
@ -1449,9 +1458,9 @@ bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desk
ewmh_set_wm_desktop(ns, dd);
if (sticky_still) {
if (ds == ms->desk && dd != md->desk) {
hide_node(ds, ns);
hide_node(ds, ns, hide_by_moving);
} else if (ds != ms->desk && dd == md->desk) {
show_node(dd, ns);
show_node(dd, ns, hide_by_moving);
}
}
}
@ -1845,7 +1854,7 @@ void set_hidden_local(monitor_t *m, desktop_t *d, node_t *n, bool value)
if (n->client != NULL) {
if (n->client->shown) {
window_set_visibility(n->id, !value);
window_set_visibility(n->id, !value, hide_by_moving);
}
if (IS_TILED(n->client)) {

View file

@ -42,8 +42,8 @@ void insert_receptacle(monitor_t *m, desktop_t *d, node_t *n);
bool activate_node(monitor_t *m, desktop_t *d, node_t *n);
void transfer_sticky_nodes(monitor_t *m, desktop_t *ds, desktop_t *dd, node_t *n);
bool focus_node(monitor_t *m, desktop_t *d, node_t *n);
void hide_node(desktop_t *d, node_t *n);
void show_node(desktop_t *d, node_t *n);
void hide_node(desktop_t *d, node_t *n, bool move);
void show_node(desktop_t *d, node_t *n, bool move);
node_t *make_node(uint32_t id);
client_t *make_client(void);
void initialize_client(node_t *n);

View file

@ -48,9 +48,10 @@ void schedule_window(xcb_window_t win)
if (wa != NULL) {
override_redirect = wa->override_redirect;
free(wa);
}
free(wa);
if (override_redirect || locate_window(win, &loc)) {
return;
}
@ -87,7 +88,7 @@ bool manage_window(xcb_window_t win, rule_consequence_t *csq, int fd)
if (!csq->manage) {
free(csq->layer);
free(csq->state);
window_show(win);
xcb_map_window(dpy, win);
return false;
}
@ -196,9 +197,9 @@ bool manage_window(xcb_window_t win, rule_consequence_t *csq, int fd)
window_grab_buttons(win);
if (d == m->desk) {
show_node(d, n);
show_node(d, n, false);
} else {
hide_node(d, n);
hide_node(d, n, false);
}
if (!csq->hidden && csq->focus) {
@ -321,7 +322,7 @@ void draw_presel_feedback(monitor_t *m, desktop_t *d, node_t *n)
presel_rect.width, presel_rect.height);
if (!exists && m->desk == d) {
window_show(p->feedback);
window_show(p->feedback, false);
}
}
@ -344,7 +345,7 @@ void show_presel_feedbacks(monitor_t *m, desktop_t *d, node_t *n)
return;
} else {
if (n->presel != NULL) {
window_show(n->presel->feedback);
window_show(n->presel->feedback, false);
}
show_presel_feedbacks(m, d, n->first_child);
show_presel_feedbacks(m, d, n->second_child);
@ -357,7 +358,7 @@ void hide_presel_feedbacks(monitor_t *m, desktop_t *d, node_t *n)
return;
} else {
if (n->presel != NULL) {
window_hide(n->presel->feedback);
window_hide(n->presel->feedback, false);
}
hide_presel_feedbacks(m, d, n->first_child);
hide_presel_feedbacks(m, d, n->second_child);
@ -383,8 +384,8 @@ void update_colors_in(node_t *n, desktop_t *d, monitor_t *m)
xcb_change_window_attributes(dpy, n->presel->feedback, XCB_CW_BACK_PIXEL, &pxl);
if (d == m->desk) {
/* hack to induce back pixel refresh */
window_hide(n->presel->feedback);
window_show(n->presel->feedback);
window_hide(n->presel->feedback, false);
window_show(n->presel->feedback, false);
}
}
if (n == d->focus) {
@ -719,7 +720,7 @@ void apply_size_hints(client_t *c, uint16_t *width, uint16_t *height)
void query_pointer(xcb_window_t *win, xcb_point_t *pt)
{
if (motion_recorder.enabled) {
window_hide(motion_recorder.id);
window_hide(motion_recorder.id, false);
}
xcb_query_pointer_reply_t *qpr = xcb_query_pointer_reply(dpy, xcb_query_pointer(dpy, root), NULL);
@ -749,7 +750,7 @@ void query_pointer(xcb_window_t *win, xcb_point_t *pt)
free(qpr);
if (motion_recorder.enabled) {
window_show(motion_recorder.id);
window_show(motion_recorder.id, false);
}
}
@ -781,13 +782,14 @@ void update_motion_recorder(void)
void enable_motion_recorder(xcb_window_t win)
{
printf("enable motion recorder\n");
xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, win), NULL);
if (geo != NULL) {
uint16_t width = geo->width + 2 * geo->border_width;
uint16_t height = geo->height + 2 * geo->border_width;
window_move_resize(motion_recorder.id, geo->x, geo->y, width, height);
window_above(motion_recorder.id, win);
window_show(motion_recorder.id);
window_show(motion_recorder.id, false);
motion_recorder.enabled = true;
}
free(geo);
@ -798,11 +800,12 @@ void disable_motion_recorder(void)
if (!motion_recorder.enabled) {
return;
}
window_hide(motion_recorder.id);
printf("disable motion recorder\n");
window_hide(motion_recorder.id, false);
motion_recorder.enabled = false;
}
void window_border_width(xcb_window_t win, uint32_t bw)
void window_border_width(xcb_window_t win, uint16_t bw)
{
uint32_t values[] = {bw};
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_BORDER_WIDTH, values);
@ -826,6 +829,26 @@ void window_move_resize(xcb_window_t win, int16_t x, int16_t y, uint16_t w, uint
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_X_Y_WIDTH_HEIGHT, values);
}
void window_mirror(xcb_window_t win)
{
xcb_get_window_attributes_reply_t *wa = xcb_get_window_attributes_reply(dpy, xcb_get_window_attributes(dpy, win), NULL);
if (wa != NULL) {
printf("0x%08X %u\n", win, wa->map_state);
}
if (wa != NULL && wa->map_state == XCB_MAP_STATE_UNMAPPED) {
free(wa);
xcb_map_window(dpy, win);
return;
}
free(wa);
xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, win), NULL);
if (geo != NULL) {
int16_t x = -(geo->x + (int16_t) geo->width + (int16_t) (2 * geo->border_width));
window_move(win, x, geo->y);
}
free(geo);
}
void window_center(monitor_t *m, client_t *c)
{
xcb_rectangle_t *r = &c->floating_rectangle;
@ -872,29 +895,37 @@ void window_lower(xcb_window_t win)
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_STACK_MODE, values);
}
void window_set_visibility(xcb_window_t win, bool visible)
void window_set_visibility(xcb_window_t win, bool visible, bool move)
{
uint32_t values_off[] = {ROOT_EVENT_MASK & ~XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY};
uint32_t values_on[] = {ROOT_EVENT_MASK};
xcb_change_window_attributes(dpy, root, XCB_CW_EVENT_MASK, values_off);
if (visible) {
set_window_state(win, XCB_ICCCM_WM_STATE_NORMAL);
xcb_map_window(dpy, win);
if (move) {
window_mirror(win);
} else {
xcb_map_window(dpy, win);
}
} else {
xcb_unmap_window(dpy, win);
if (move) {
window_mirror(win);
} else {
xcb_unmap_window(dpy, win);
}
set_window_state(win, XCB_ICCCM_WM_STATE_ICONIC);
}
xcb_change_window_attributes(dpy, root, XCB_CW_EVENT_MASK, values_on);
}
void window_hide(xcb_window_t win)
void window_hide(xcb_window_t win, bool move)
{
window_set_visibility(win, false);
window_set_visibility(win, false, move);
}
void window_show(xcb_window_t win)
void window_show(xcb_window_t win, bool move)
{
window_set_visibility(win, true);
window_set_visibility(win, true, move);
}
void update_input_focus(void)

View file

@ -56,18 +56,19 @@ void query_pointer(xcb_window_t *win, xcb_point_t *pt);
void update_motion_recorder(void);
void enable_motion_recorder(xcb_window_t win);
void disable_motion_recorder(void);
void window_border_width(xcb_window_t win, uint32_t bw);
void window_border_width(xcb_window_t win, uint16_t bw);
void window_move(xcb_window_t win, int16_t x, int16_t y);
void window_resize(xcb_window_t win, uint16_t w, uint16_t h);
void window_move_resize(xcb_window_t win, int16_t x, int16_t y, uint16_t w, uint16_t h);
void window_mirror(xcb_window_t win);
void window_center(monitor_t *m, client_t *c);
void window_stack(xcb_window_t w1, xcb_window_t w2, uint32_t mode);
void window_above(xcb_window_t w1, xcb_window_t w2);
void window_below(xcb_window_t w1, xcb_window_t w2);
void window_lower(xcb_window_t win);
void window_set_visibility(xcb_window_t win, bool visible);
void window_hide(xcb_window_t win);
void window_show(xcb_window_t win);
void window_set_visibility(xcb_window_t win, bool visible, bool move);
void window_hide(xcb_window_t win, bool move);
void window_show(xcb_window_t win, bool move);
void update_input_focus(void);
void set_input_focus(node_t *n);
void clear_input_focus(void);