Skip to content

Commit

Permalink
Set the input focus before unmapping windows
Browse files Browse the repository at this point in the history
Fixes #811.
  • Loading branch information
baskerville committed Aug 3, 2020
1 parent 2492695 commit d4dee39
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
18 changes: 0 additions & 18 deletions src/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@
#include "subscribe.h"
#include "settings.h"

void focus_desktop(monitor_t *m, desktop_t *d)
{
bool changed = (m != mon || m->desk != d);

focus_monitor(m);

if (m->desk != d) {
show_desktop(d);
hide_desktop(m->desk);
m->desk = d;
}

if (changed) {
ewmh_update_current_desktop();
put_status(SBSC_MASK_DESKTOP_FOCUS, "desktop_focus 0x%08X 0x%08X\n", m->id, d->id);
}
}

bool activate_desktop(monitor_t *m, desktop_t *d)
{
if (d != NULL && m == mon) {
Expand Down
1 change: 0 additions & 1 deletion src/desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#define DEFAULT_DESK_NAME "Desktop"

void focus_desktop(monitor_t *m, desktop_t *d);
bool activate_desktop(monitor_t *m, desktop_t *d);
bool find_closest_desktop(coordinates_t *ref, coordinates_t *dst, cycle_dir_t dir, desktop_select_t *sel);
bool find_any_desktop(coordinates_t *ref, coordinates_t *dst, desktop_select_t *sel);
Expand Down
15 changes: 0 additions & 15 deletions src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,6 @@ void adapt_geometry(xcb_rectangle_t *rs, xcb_rectangle_t *rd, node_t *n)
}
}

void focus_monitor(monitor_t *m)
{
if (mon == m) {
return;
}

mon = m;

if (pointer_follows_monitor) {
center_pointer(m->rectangle);
}

put_status(SBSC_MASK_MONITOR_FOCUS, "monitor_focus 0x%08X\n", m->id);
}

void add_monitor(monitor_t *m)
{
xcb_rectangle_t r = m->rectangle;
Expand Down
1 change: 0 additions & 1 deletion src/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ monitor_t *find_monitor(uint32_t id);
monitor_t *get_monitor_by_randr_id(xcb_randr_output_t id);
void embrace_client(monitor_t *m, client_t *c);
void adapt_geometry(xcb_rectangle_t *rs, xcb_rectangle_t *rd, node_t *n);
void focus_monitor(monitor_t *m);
void add_monitor(monitor_t *m);
void unlink_monitor(monitor_t *m);
void remove_monitor(monitor_t *m);
Expand Down
30 changes: 28 additions & 2 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,36 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)

draw_border(n, true, true);

focus_desktop(m, d);
bool desk_changed = (m != mon || m->desk != d);
bool has_input_focus = false;

if (mon != m) {
mon = m;

if (pointer_follows_monitor) {
center_pointer(m->rectangle);
}

put_status(SBSC_MASK_MONITOR_FOCUS, "monitor_focus 0x%08X\n", m->id);
}

if (m->desk != d) {
show_desktop(d);
set_input_focus(n);
has_input_focus = true;
hide_desktop(m->desk);
m->desk = d;
}

if (desk_changed) {
ewmh_update_current_desktop();
put_status(SBSC_MASK_DESKTOP_FOCUS, "desktop_focus 0x%08X 0x%08X\n", m->id, d->id);
}

d->focus = n;
if (!has_input_focus) {
set_input_focus(n);
}
ewmh_update_active_window();
history_add(m, d, n, true);

Expand All @@ -627,7 +654,6 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
put_status(SBSC_MASK_NODE_FOCUS, "node_focus 0x%08X 0x%08X 0x%08X\n", m->id, d->id, n->id);

stack(d, n, true);
set_input_focus(n);

if (pointer_follows_focus) {
center_pointer(get_rectangle(m, d, n));
Expand Down

0 comments on commit d4dee39

Please sign in to comment.