static void focus_delay_dest(gpointer data);
static gboolean focus_delay_cmp(gconstpointer d1, gconstpointer d2);
static gboolean focus_delay_func(gpointer data);
+static gboolean unfocus_delay_func(gpointer data);
static void focus_delay_client_dest(ObClient *client, gpointer data);
Time event_curtime = CurrentTime;
}
}
+void event_leave_client(ObClient *client)
+{
+ g_assert(config_focus_follow);
+
+ if (is_enter_focus_event_ignored(event_curserial)) {
+ ob_debug_type(OB_DEBUG_FOCUS, "Ignoring leave event with serial %lu\n"
+ "on client 0x%x", event_curserial, client->window);
+ return;
+ }
+
+ if (client == focus_client) {
+ if (config_focus_delay) {
+ ObFocusDelayData *data;
+
+ obt_main_loop_timeout_remove(ob_main_loop, unfocus_delay_func);
+
+ data = g_new(ObFocusDelayData, 1);
+ data->client = client;
+ data->time = event_curtime;
+ data->serial = event_curserial;
+
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_focus_delay * 1000,
+ unfocus_delay_func,
+ data, focus_delay_cmp, focus_delay_dest);
+ } else {
+ ObFocusDelayData data;
+ data.client = client;
+ data.time = event_curtime;
+ data.serial = event_curserial;
+ unfocus_delay_func(&data);
+ }
+ }
+}
+
static gboolean *context_to_button(ObFrame *f, ObFrameContext con, gboolean press)
{
if (press) {
e->xcrossing.detail, (client?client->window:0));
if (grab_on_keyboard())
break;
- if (config_focus_follow && config_focus_delay &&
+ if (config_focus_follow &&
/* leave inferior events can happen when the mouse goes onto
the window's border and then into the window before the
delay is up */
e->xcrossing.detail != NotifyInferior)
{
- obt_main_loop_timeout_remove_data(ob_main_loop,
- focus_delay_func,
- client, FALSE);
+ if (config_focus_delay)
+ obt_main_loop_timeout_remove_data(ob_main_loop,
+ focus_delay_func,
+ client, FALSE);
+ if (config_unfocus_leave)
+ event_leave_client(client);
}
break;
default:
e->xcrossing.detail,
e->xcrossing.serial,
(client?client->window:0));
- if (config_focus_follow)
+ if (config_focus_follow) {
+ if (config_focus_delay)
+ obt_main_loop_timeout_remove_data(ob_main_loop,
+ unfocus_delay_func,
+ client, FALSE);
event_enter_client(client);
+ }
}
break;
default:
break;
if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) &&
- (f = find_active_menu()) && f->selected == e &&
- e->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU)
+ (f = find_active_menu()) && f->selected == e)
{
ObMenuEntryFrame *u = menu_entry_frame_under(ev->xcrossing.x_root,
ev->xcrossing.y_root);
ObFocusDelayData *d = data;
Time old = event_curtime;
- /* don't move focus and kill the menu or the move/resize */
- if (menu_frame_visible || moveresize_in_progress) return FALSE;
-
event_curtime = d->time;
event_curserial = d->serial;
if (client_focus(d->client) && config_focus_raise)
return FALSE; /* no repeat */
}
+static gboolean unfocus_delay_func(gpointer data)
+{
+ ObFocusDelayData *d = data;
+ Time old = event_curtime;
+
+ event_curtime = d->time;
+ event_curserial = d->serial;
+ focus_nothing();
+ event_curtime = old;
+ return FALSE; /* no repeat */
+}
+
static void focus_delay_client_dest(ObClient *client, gpointer data)
{
obt_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
client, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop, unfocus_delay_func,
+ client, FALSE);
}
void event_halt_focus_delay(void)
/* ignore all enter events up till the event which caused this to occur */
if (event_curserial) event_ignore_enter_range(1, event_curserial);
obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+ obt_main_loop_timeout_remove(ob_main_loop, unfocus_delay_func);
}
gulong event_start_ignore_all_enters(void)