Created
April 27, 2024 01:56
-
-
Save ortango/91561d7b75db521877498295b66316fb to your computer and use it in GitHub Desktop.
hide by moving branch vs af3bd8b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN a/src/desktop.c b/src/desktop.c | |
--- a/src/desktop.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/desktop.c 2024-04-26 21:47:45.922352820 -0400 | |
@@ -531,7 +531,7 @@ | |
if (d == NULL) { | |
return; | |
} | |
- show_node(d, d->root); | |
+ show_node(d, d->root, hide_by_moving); | |
} | |
void hide_desktop(desktop_t *d) | |
@@ -539,7 +539,7 @@ | |
if (d == NULL) { | |
return; | |
} | |
- hide_node(d, d->root); | |
+ hide_node(d, d->root, hide_by_moving); | |
} | |
bool is_urgent(desktop_t *d) | |
diff -ruN a/src/messages.c b/src/messages.c | |
--- a/src/messages.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/messages.c 2024-04-26 21:47:45.922352820 -0400 | |
@@ -1760,9 +1760,9 @@ | |
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); | |
@@ -1792,6 +1792,7 @@ | |
SET_BOOL(pointer_follows_focus) | |
SET_BOOL(pointer_follows_monitor) | |
SET_BOOL(ignore_ewmh_focus) | |
+ SET_BOOL(hide_by_moving) | |
SET_BOOL(ignore_ewmh_struts) | |
SET_BOOL(center_pseudo_tiled) | |
SET_BOOL(removal_adjustment) | |
@@ -1924,6 +1925,7 @@ | |
GET_BOOL(pointer_follows_focus) | |
GET_BOOL(pointer_follows_monitor) | |
GET_BOOL(ignore_ewmh_focus) | |
+ GET_BOOL(hide_by_moving) | |
GET_BOOL(ignore_ewmh_struts) | |
GET_BOOL(center_pseudo_tiled) | |
GET_BOOL(removal_adjustment) | |
diff -ruN a/src/monitor.c b/src/monitor.c | |
--- a/src/monitor.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/monitor.c 2024-04-26 21:47:45.922352820 -0400 | |
@@ -77,7 +77,7 @@ | |
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); | |
diff -ruN a/src/settings.c b/src/settings.c | |
--- a/src/settings.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/settings.c 2024-04-26 21:50:53.489017214 -0400 | |
@@ -63,6 +63,7 @@ | |
int8_t click_to_focus; | |
bool swallow_first_click; | |
bool ignore_ewmh_focus; | |
+bool hide_by_moving; | |
bool ignore_ewmh_struts; | |
state_transition_t ignore_ewmh_fullscreen; | |
@@ -129,6 +130,7 @@ | |
ignore_ewmh_fullscreen = IGNORE_EWMH_FULLSCREEN; | |
ignore_ewmh_struts = IGNORE_EWMH_STRUTS; | |
+ hide_by_moving = HIDE_BY_MOVING; | |
center_pseudo_tiled = CENTER_PSEUDO_TILED; | |
honor_size_hints = HONOR_SIZE_HINTS; | |
diff -ruN a/src/settings.h b/src/settings.h | |
--- a/src/settings.h 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/settings.h 2024-04-26 21:47:45.922352820 -0400 | |
@@ -60,6 +60,7 @@ | |
#define IGNORE_EWMH_FULLSCREEN 0 | |
#define IGNORE_EWMH_STRUTS false | |
+#define HIDE_BY_MOVING false | |
#define CENTER_PSEUDO_TILED true | |
#define HONOR_SIZE_HINTS HONOR_SIZE_HINTS_NO | |
#define MAPPING_EVENTS_COUNT 1 | |
@@ -106,6 +107,7 @@ | |
extern bool ignore_ewmh_struts; | |
extern state_transition_t ignore_ewmh_fullscreen; | |
+extern bool hide_by_moving; | |
extern bool center_pseudo_tiled; | |
extern honor_size_hints_mode_t honor_size_hints; | |
diff -ruN a/src/tree.c b/src/tree.c | |
--- a/src/tree.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/tree.c 2024-04-26 21:47:45.922352820 -0400 | |
@@ -78,6 +78,10 @@ | |
n->rectangle = rect; | |
+ if (n->hidden) { | |
+ return; | |
+ } | |
+ | |
if (n->presel != NULL) { | |
draw_presel_feedback(m, d, n); | |
} | |
@@ -131,7 +135,12 @@ | |
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); | |
} | |
@@ -684,45 +693,45 @@ | |
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 || (!hide_sticky && n->sticky)) { | |
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); | |
} | |
} | |
@@ -1559,15 +1568,15 @@ | |
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 (single_monocle) { | |
@@ -1663,9 +1672,9 @@ | |
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); | |
} | |
} | |
} | |
@@ -2104,7 +2113,7 @@ | |
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)) { | |
diff -ruN a/src/tree.h b/src/tree.h | |
--- a/src/tree.h 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/tree.h 2024-04-26 21:47:45.922352820 -0400 | |
@@ -43,8 +43,8 @@ | |
bool activate_node(monitor_t *m, desktop_t *d, node_t *n); | |
void transfer_sticky_nodes(monitor_t *ms, desktop_t *ds, monitor_t *md, 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); | |
diff -ruN a/src/window.c b/src/window.c | |
--- a/src/window.c 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/window.c 2024-04-26 21:47:45.922352820 -0400 | |
@@ -49,9 +49,10 @@ | |
if (wa != NULL) { | |
override_redirect = wa->override_redirect; | |
- free(wa); | |
} | |
+ free(wa); | |
+ | |
if (override_redirect || locate_window(win, &loc)) { | |
return; | |
} | |
@@ -90,7 +91,7 @@ | |
if (!csq->manage) { | |
free(csq->layer); | |
free(csq->state); | |
- window_show(win); | |
+ xcb_map_window(dpy, win); | |
return false; | |
} | |
@@ -203,9 +204,9 @@ | |
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); | |
} | |
ewmh_update_client_list(false); | |
@@ -329,7 +330,7 @@ | |
presel_rect.width, presel_rect.height); | |
if (!exists && m->desk == d) { | |
- window_show(p->feedback); | |
+ window_show(p->feedback, false); | |
} | |
} | |
@@ -352,7 +353,7 @@ | |
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); | |
@@ -365,7 +366,7 @@ | |
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); | |
@@ -391,8 +392,8 @@ | |
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) { | |
@@ -725,7 +726,7 @@ | |
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); | |
@@ -769,7 +770,7 @@ | |
free(qpr); | |
if (motion_recorder.enabled) { | |
- window_show(motion_recorder.id); | |
+ window_show(motion_recorder.id, false); | |
} | |
} | |
@@ -801,13 +802,14 @@ | |
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); | |
@@ -818,11 +820,12 @@ | |
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); | |
@@ -846,6 +849,26 @@ | |
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; | |
@@ -892,29 +915,37 @@ | |
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) | |
diff -ruN a/src/window.h b/src/window.h | |
--- a/src/window.h 2024-04-26 21:51:35.689016703 -0400 | |
+++ b/src/window.h 2024-04-26 21:47:45.922352820 -0400 | |
@@ -56,18 +56,19 @@ | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment