#include <glib.h>
-#define ACT_START(d) \
- ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \
- grab_pointer(TRUE, OB_CURSOR_NONE), 0 : 0)
+inline void client_action_start(union ActionData *data)
+{
+ if (config_focus_follow)
+ if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
+ grab_pointer(TRUE, OB_CURSOR_NONE);
+}
+
+inline void client_action_end(union ActionData *data)
+{
+ if (config_focus_follow)
+ if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
+ if (!data->any.button) {
+ grab_pointer(FALSE, OB_CURSOR_NONE);
+ } else {
+ ObClient *c;
-#define ACT_END(d) \
- ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \
- grab_pointer(FALSE, OB_CURSOR_NONE), \
- (d->any.button ? focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS), 1 : 0) : \
- 0)
+ if ((c = client_under_pointer()))
+ event_enter_client(c);
+ }
+ }
+}
typedef struct ActionString {
const gchar *name;
}
if (raise) {
- ACT_START(data);
+ client_action_start(data);
stacking_raise(CLIENT_AS_WINDOW(c));
- ACT_END(data);
+ client_action_end(data);
} else {
- ACT_START(data);
+ client_action_start(data);
stacking_lower(CLIENT_AS_WINDOW(c));
- ACT_END(data);
+ client_action_end(data);
}
}
void action_raise(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
- ACT_END(data);
+ client_action_end(data);
}
}
{
if (data->client.any.c) {
if (data->client.any.c->shaded) {
- ACT_START(data);
+ client_action_start(data);
client_shade(data->client.any.c, FALSE);
- ACT_END(data);
+ client_action_end(data);
} else {
- ACT_START(data);
+ client_action_start(data);
stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
- ACT_END(data);
+ client_action_end(data);
}
}
}
if (data->client.any.c->shaded)
stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
else {
- ACT_START(data);
+ client_action_start(data);
client_shade(data->client.any.c, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
}
void action_lower(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
- ACT_END(data);
+ client_action_end(data);
}
}
void action_shade(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_shade(data->client.any.c, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_unshade(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_shade(data->client.any.c, FALSE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_toggle_shade(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_shade(data->client.any.c, !data->client.any.c->shaded);
- ACT_END(data);
+ client_action_end(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- ACT_START(data);
+ client_action_start(data);
client_move(c, c->area.x + data->relative.delta, c->area.y);
- ACT_END(data);
+ client_action_end(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- ACT_START(data);
+ client_action_start(data);
client_move(c, c->area.x, c->area.y + data->relative.delta);
- ACT_END(data);
+ client_action_end(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- ACT_START(data);
+ client_action_start(data);
client_resize(c,
c->area.width + data->relative.delta * c->size_inc.width,
c->area.height);
- ACT_END(data);
+ client_action_end(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c && !c->shaded) {
- ACT_START(data);
+ client_action_start(data);
client_resize(c, c->area.width, c->area.height +
data->relative.delta * c->size_inc.height);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_maximize_full(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, TRUE, 0, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_unmaximize_full(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, FALSE, 0, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_toggle_maximize_full(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c,
!(data->client.any.c->max_horz ||
data->client.any.c->max_vert),
0, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_maximize_horz(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, TRUE, 1, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_unmaximize_horz(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, FALSE, 1, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_toggle_maximize_horz(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c,
!data->client.any.c->max_horz, 1, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_maximize_vert(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, TRUE, 2, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_unmaximize_vert(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c, FALSE, 2, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
void action_toggle_maximize_vert(union ActionData *data)
{
if (data->client.any.c) {
- ACT_START(data);
+ client_action_start(data);
client_maximize(data->client.any.c,
!data->client.any.c->max_vert, 2, TRUE);
- ACT_END(data);
+ client_action_end(data);
}
}
ObClient *c = data->client.any.c;
if (c) {
- ACT_START(data);
+ client_action_start(data);
c->decorate = !c->decorate;
client_setup_decor_and_functions(c);
- ACT_END(data);
+ client_action_end(data);
}
}
g_assert_not_reached();
}
frame_frame_gravity(c->frame, &x, &y);
- ACT_START(data);
+ client_action_start(data);
client_move(c, x, y);
- ACT_END(data);
+ client_action_end(data);
}
frame_frame_gravity(c->frame, &x, &y);
width -= c->frame->size.left + c->frame->size.right;
height -= c->frame->size.top + c->frame->size.bottom;
- ACT_START(data);
+ client_action_start(data);
client_move_resize(c, x, y, width, height);
- ACT_END(data);
+ client_action_end(data);
}
void action_send_to_layer(union ActionData *data)
ObClient *c = data->layer.any.c;
if (c) {
- ACT_START(data);
+ client_action_start(data);
if (data->layer.layer < 0)
client_set_layer(c, c->below ? 0 : -1);
else if (data->layer.layer > 0)
client_set_layer(c, c->above ? 0 : 1);
- ACT_END(data);
+ client_action_end(data);
}
}
static int mask_table_size;
static guint ignore_enter_focus = 0;
-static ObClient *focus_delay_client;
static gboolean menu_can_hide;
event_handle_client(it->data, e);
}
+void event_enter_client(ObClient *client)
+{
+ g_assert(config_focus_follow);
+
+ if (client_normal(client) && client_can_focus(client)) {
+ if (config_focus_delay) {
+ ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+ ob_main_loop_timeout_add(ob_main_loop,
+ config_focus_delay,
+ focus_delay_func,
+ client, NULL);
+ } else {
+ client_focus(client);
+ if (config_focus_raise)
+ stacking_raise(CLIENT_AS_WINDOW(client));
+ }
+ }
+}
+
static void event_handle_client(ObClient *client, XEvent *e)
{
XEvent ce;
frame_adjust_state(client->frame);
break;
case OB_FRAME_CONTEXT_FRAME:
- if (client == focus_delay_client) {
- ob_main_loop_timeout_remove_data(ob_main_loop,
- focus_delay_func,
- focus_delay_client);
- focus_delay_client = NULL;
- }
+ break;
default:
break;
}
frame_adjust_state(client->frame);
break;
case OB_FRAME_CONTEXT_FRAME:
- if (!nofocus && config_focus_follow &&
- client_normal(client) && client_can_focus(client)) {
- if (e->xcrossing.mode == NotifyGrab ||
- e->xcrossing.detail == NotifyInferior ||
- e->xcrossing.mode == NotifyUngrab)
- {
+ if (e->xcrossing.mode == NotifyGrab ||
+ e->xcrossing.detail == NotifyInferior ||
+ e->xcrossing.mode == NotifyUngrab)
+ {
#ifdef DEBUG_FOCUS
- ob_debug("%sNotify mode %d detail %d on %lx IGNORED\n",
- (e->type == EnterNotify ? "Enter" : "Leave"),
- e->xcrossing.mode,
- e->xcrossing.detail, client?client->window:0);
+ ob_debug("%sNotify mode %d detail %d on %lx IGNORED\n",
+ (e->type == EnterNotify ? "Enter" : "Leave"),
+ e->xcrossing.mode,
+ e->xcrossing.detail, client?client->window:0);
#endif
- } else {
+ } else {
#ifdef DEBUG_FOCUS
- ob_debug("%sNotify mode %d detail %d on %lx, "
- "focusing window\n",
- (e->type == EnterNotify ? "Enter" : "Leave"),
- e->xcrossing.mode,
- e->xcrossing.detail, client?client->window:0);
+ ob_debug("%sNotify mode %d detail %d on %lx, "
+ "focusing window\n",
+ (e->type == EnterNotify ? "Enter" : "Leave"),
+ e->xcrossing.mode,
+ e->xcrossing.detail, client?client->window:0);
#endif
- if (config_focus_delay) {
- ob_main_loop_timeout_add(ob_main_loop,
- config_focus_delay,
- focus_delay_func,
- client, NULL);
- focus_delay_client = client;
- } else {
- client_focus(client);
- if (config_focus_raise)
- stacking_raise
- (CLIENT_AS_WINDOW(focus_delay_client));
- }
- }
+ if (!nofocus && config_focus_follow)
+ event_enter_client(client);
}
break;
default:
static gboolean focus_delay_func(gpointer data)
{
- if (data == focus_delay_client) {
- client_focus(focus_delay_client);
- if (config_focus_raise)
- stacking_raise(CLIENT_AS_WINDOW(focus_delay_client));
- }
+ ObClient *c = data;
+
+ client_focus(c);
+ if (config_focus_raise)
+ stacking_raise(CLIENT_AS_WINDOW(c));
return FALSE; /* no repeat */
}
static void focus_delay_client_dest(gpointer data)
{
ObClient *c = data;
- if (c == focus_delay_client) {
- ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
- focus_delay_client);
- focus_delay_client = NULL;
- }
+
+ ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func, c);
}
void event_ignore_enter_focus(guint num)