add a comparitor to timers. use this in event.c to let you remove timers from the queue selectively for delayed focus
This commit is contained in:
parent
8612fcfb99
commit
939fbcfd31
9 changed files with 49 additions and 32 deletions
|
@ -616,14 +616,14 @@ void dock_hide(gboolean hide)
|
||||||
if (!hide) {
|
if (!hide) {
|
||||||
if (dock->hidden && config_dock_hide) {
|
if (dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_add(ob_main_loop, config_dock_show_delay,
|
ob_main_loop_timeout_add(ob_main_loop, config_dock_show_delay,
|
||||||
show_timeout, NULL, NULL);
|
show_timeout, NULL, g_direct_equal, NULL);
|
||||||
} else if (!dock->hidden && config_dock_hide) {
|
} else if (!dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
|
ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!dock->hidden && config_dock_hide) {
|
if (!dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_add(ob_main_loop, config_dock_hide_delay,
|
ob_main_loop_timeout_add(ob_main_loop, config_dock_hide_delay,
|
||||||
hide_timeout, NULL, NULL);
|
hide_timeout, NULL, g_direct_equal, NULL);
|
||||||
} else if (dock->hidden && config_dock_hide) {
|
} else if (dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
|
ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ static void event_handle_dockapp(ObDockApp *app, XEvent *e);
|
||||||
static void event_handle_client(ObClient *c, XEvent *e);
|
static void event_handle_client(ObClient *c, XEvent *e);
|
||||||
static void event_handle_group(ObGroup *g, XEvent *e);
|
static void event_handle_group(ObGroup *g, XEvent *e);
|
||||||
|
|
||||||
|
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 focus_delay_func(gpointer data);
|
||||||
static void focus_delay_client_dest(ObClient *client, gpointer data);
|
static void focus_delay_client_dest(ObClient *client, gpointer data);
|
||||||
|
|
||||||
|
@ -104,11 +106,6 @@ static guint ignore_enter_focus = 0;
|
||||||
|
|
||||||
static gboolean menu_can_hide;
|
static gboolean menu_can_hide;
|
||||||
|
|
||||||
static ObFocusDelayData focus_delay_data = { .client = NULL,
|
|
||||||
.time = CurrentTime };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_SM
|
#ifdef USE_SM
|
||||||
static void ice_handler(gint fd, gpointer conn)
|
static void ice_handler(gint fd, gpointer conn)
|
||||||
{
|
{
|
||||||
|
@ -542,7 +539,7 @@ static void event_process(const XEvent *ec, gpointer data)
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
ob_main_loop_timeout_add(ob_main_loop,
|
||||||
config_menu_hide_delay * 1000,
|
config_menu_hide_delay * 1000,
|
||||||
menu_hide_delay_func,
|
menu_hide_delay_func,
|
||||||
NULL, NULL);
|
NULL, g_direct_equal, NULL);
|
||||||
|
|
||||||
if (e->type == ButtonPress || e->type == ButtonRelease ||
|
if (e->type == ButtonPress || e->type == ButtonRelease ||
|
||||||
e->type == MotionNotify)
|
e->type == MotionNotify)
|
||||||
|
@ -627,19 +624,23 @@ void event_enter_client(ObClient *client)
|
||||||
|
|
||||||
if (client_normal(client) && client_can_focus(client)) {
|
if (client_normal(client) && client_can_focus(client)) {
|
||||||
if (config_focus_delay) {
|
if (config_focus_delay) {
|
||||||
|
ObFocusDelayData *data;
|
||||||
|
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
||||||
|
|
||||||
focus_delay_data.client = client;
|
data = g_new(ObFocusDelayData, 1);
|
||||||
focus_delay_data.time = event_curtime;
|
data->client = client;
|
||||||
|
data->time = event_curtime;
|
||||||
|
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
ob_main_loop_timeout_add(ob_main_loop,
|
||||||
config_focus_delay,
|
config_focus_delay,
|
||||||
focus_delay_func,
|
focus_delay_func,
|
||||||
NULL, NULL);
|
data, focus_delay_cmp, focus_delay_dest);
|
||||||
} else {
|
} else {
|
||||||
focus_delay_data.client = client;
|
ObFocusDelayData data;
|
||||||
focus_delay_data.time = event_curtime;
|
data.client = client;
|
||||||
focus_delay_func(NULL);
|
data.time = event_curtime;
|
||||||
|
focus_delay_func(&data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -760,11 +761,10 @@ static void event_handle_client(ObClient *client, XEvent *e)
|
||||||
frame_adjust_state(client->frame);
|
frame_adjust_state(client->frame);
|
||||||
break;
|
break;
|
||||||
case OB_FRAME_CONTEXT_FRAME:
|
case OB_FRAME_CONTEXT_FRAME:
|
||||||
if (config_focus_follow && config_focus_delay &&
|
if (config_focus_follow && config_focus_delay)
|
||||||
focus_delay_data.client == client)
|
ob_main_loop_timeout_remove_data(ob_main_loop,
|
||||||
{
|
focus_delay_func,
|
||||||
event_halt_focus_delay();
|
client, FALSE);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1340,13 +1340,26 @@ static gboolean menu_hide_delay_func(gpointer data)
|
||||||
return FALSE; /* no repeat */
|
return FALSE; /* no repeat */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void focus_delay_dest(gpointer data)
|
||||||
|
{
|
||||||
|
g_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean focus_delay_cmp(gconstpointer d1, gconstpointer d2)
|
||||||
|
{
|
||||||
|
const ObFocusDelayData *f1 = d1, *f2 = d2;
|
||||||
|
return f1->client == f2->client;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean focus_delay_func(gpointer data)
|
static gboolean focus_delay_func(gpointer data)
|
||||||
{
|
{
|
||||||
|
ObFocusDelayData *d = data;
|
||||||
Time old = event_curtime;
|
Time old = event_curtime;
|
||||||
event_curtime = focus_delay_data.time;
|
|
||||||
if (focus_client != focus_delay_data.client) {
|
event_curtime = d->time;
|
||||||
if (client_focus(focus_delay_data.client) && config_focus_raise)
|
if (focus_client != d->client) {
|
||||||
client_raise(focus_delay_data.client);
|
if (client_focus(d->client) && config_focus_raise)
|
||||||
|
client_raise(d->client);
|
||||||
}
|
}
|
||||||
event_curtime = old;
|
event_curtime = old;
|
||||||
return FALSE; /* no repeat */
|
return FALSE; /* no repeat */
|
||||||
|
@ -1354,8 +1367,8 @@ static gboolean focus_delay_func(gpointer data)
|
||||||
|
|
||||||
static void focus_delay_client_dest(ObClient *client, gpointer data)
|
static void focus_delay_client_dest(ObClient *client, gpointer data)
|
||||||
{
|
{
|
||||||
if (focus_delay_data.client == client)
|
ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
|
||||||
event_halt_focus_delay();
|
client, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_client_dest(ObClient *client, gpointer data)
|
static void event_client_dest(ObClient *client, gpointer data)
|
||||||
|
@ -1366,7 +1379,6 @@ static void event_client_dest(ObClient *client, gpointer data)
|
||||||
|
|
||||||
void event_halt_focus_delay()
|
void event_halt_focus_delay()
|
||||||
{
|
{
|
||||||
focus_delay_data.client = NULL;
|
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,9 +282,6 @@ void focus_fallback(gboolean allow_refocus)
|
||||||
*/
|
*/
|
||||||
focus_set_client(NULL);
|
focus_set_client(NULL);
|
||||||
|
|
||||||
/* If some delayed focusing is going on, cancel it */
|
|
||||||
event_halt_focus_delay();
|
|
||||||
|
|
||||||
if ((new = focus_fallback_target(allow_refocus, old)))
|
if ((new = focus_fallback_target(allow_refocus, old)))
|
||||||
client_focus(new);
|
client_focus(new);
|
||||||
}
|
}
|
||||||
|
|
|
@ -977,6 +977,7 @@ void frame_flash_start(ObFrame *self)
|
||||||
G_USEC_PER_SEC * 0.6,
|
G_USEC_PER_SEC * 0.6,
|
||||||
flash_timeout,
|
flash_timeout,
|
||||||
self,
|
self,
|
||||||
|
g_direct_equal,
|
||||||
flash_done);
|
flash_done);
|
||||||
g_get_current_time(&self->flash_end);
|
g_get_current_time(&self->flash_end);
|
||||||
g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5);
|
g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5);
|
||||||
|
|
|
@ -271,7 +271,8 @@ void keyboard_event(ObClient *client, const XEvent *e)
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
||||||
/* 5 second timeout for chains */
|
/* 5 second timeout for chains */
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 5 * G_USEC_PER_SEC,
|
ob_main_loop_timeout_add(ob_main_loop, 5 * G_USEC_PER_SEC,
|
||||||
chain_timeout, NULL, NULL);
|
chain_timeout, NULL,
|
||||||
|
g_direct_equal, NULL);
|
||||||
grab_keys(FALSE);
|
grab_keys(FALSE);
|
||||||
curpos = p;
|
curpos = p;
|
||||||
grab_keys(TRUE);
|
grab_keys(TRUE);
|
||||||
|
|
|
@ -99,6 +99,7 @@ struct _ObMainLoopTimer
|
||||||
gulong delay;
|
gulong delay;
|
||||||
GSourceFunc func;
|
GSourceFunc func;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
|
GEqualFunc equal;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
|
|
||||||
/* The timer needs to be freed */
|
/* The timer needs to be freed */
|
||||||
|
@ -585,12 +586,14 @@ void ob_main_loop_timeout_add(ObMainLoop *loop,
|
||||||
gulong microseconds,
|
gulong microseconds,
|
||||||
GSourceFunc handler,
|
GSourceFunc handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
|
GEqualFunc cmp,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
ObMainLoopTimer *t = g_new(ObMainLoopTimer, 1);
|
ObMainLoopTimer *t = g_new(ObMainLoopTimer, 1);
|
||||||
t->delay = microseconds;
|
t->delay = microseconds;
|
||||||
t->func = handler;
|
t->func = handler;
|
||||||
t->data = data;
|
t->data = data;
|
||||||
|
t->equal = cmp;
|
||||||
t->destroy = notify;
|
t->destroy = notify;
|
||||||
t->del_me = FALSE;
|
t->del_me = FALSE;
|
||||||
g_get_current_time(&loop->now);
|
g_get_current_time(&loop->now);
|
||||||
|
@ -619,7 +622,7 @@ void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler,
|
||||||
|
|
||||||
for (it = loop->timers; it; it = g_slist_next(it)) {
|
for (it = loop->timers; it; it = g_slist_next(it)) {
|
||||||
ObMainLoopTimer *t = it->data;
|
ObMainLoopTimer *t = it->data;
|
||||||
if (t->func == handler && t->data == data) {
|
if (t->func == handler && t->equal(t->data, data)) {
|
||||||
t->del_me = TRUE;
|
t->del_me = TRUE;
|
||||||
if (cancel_dest)
|
if (cancel_dest)
|
||||||
t->destroy = NULL;
|
t->destroy = NULL;
|
||||||
|
|
|
@ -61,6 +61,7 @@ void ob_main_loop_timeout_add(ObMainLoop *loop,
|
||||||
gulong microseconds,
|
gulong microseconds,
|
||||||
GSourceFunc handler,
|
GSourceFunc handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
|
GEqualFunc cmp,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
void ob_main_loop_timeout_remove(ObMainLoop *loop,
|
void ob_main_loop_timeout_remove(ObMainLoop *loop,
|
||||||
GSourceFunc handler);
|
GSourceFunc handler);
|
||||||
|
|
|
@ -918,7 +918,7 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry)
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
ob_main_loop_timeout_add(ob_main_loop,
|
||||||
config_submenu_show_delay * 1000,
|
config_submenu_show_delay * 1000,
|
||||||
menu_entry_frame_submenu_timeout,
|
menu_entry_frame_submenu_timeout,
|
||||||
self->selected,
|
self->selected, g_direct_equal,
|
||||||
NULL);
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
menu_entry_frame_show_submenu(self->selected);
|
menu_entry_frame_show_submenu(self->selected);
|
||||||
|
|
|
@ -144,6 +144,7 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data)
|
||||||
have a timeout */
|
have a timeout */
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 30 * G_USEC_PER_SEC,
|
ob_main_loop_timeout_add(ob_main_loop, 30 * G_USEC_PER_SEC,
|
||||||
sn_wait_timeout, seq,
|
sn_wait_timeout, seq,
|
||||||
|
g_direct_equal,
|
||||||
(GDestroyNotify)sn_startup_sequence_unref);
|
(GDestroyNotify)sn_startup_sequence_unref);
|
||||||
change = TRUE;
|
change = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -256,6 +257,7 @@ void sn_setup_spawn_environment(gchar *program, gchar *name,
|
||||||
sn_launcher_context_ref(sn_launcher);
|
sn_launcher_context_ref(sn_launcher);
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 30 * G_USEC_PER_SEC,
|
ob_main_loop_timeout_add(ob_main_loop, 30 * G_USEC_PER_SEC,
|
||||||
sn_launch_wait_timeout, sn_launcher,
|
sn_launch_wait_timeout, sn_launcher,
|
||||||
|
g_direct_equal,
|
||||||
(GDestroyNotify)sn_launcher_context_unref);
|
(GDestroyNotify)sn_launcher_context_unref);
|
||||||
|
|
||||||
setenv("DESKTOP_STARTUP_ID", id, TRUE);
|
setenv("DESKTOP_STARTUP_ID", id, TRUE);
|
||||||
|
|
Loading…
Reference in a new issue