#include "grab.h"
#include "keyboard.h"
#include "event.h"
+#include "config.h"
#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)
+
+#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)
+
typedef struct ActionString {
const gchar *name;
void (*func)(union ActionData *);
return act;
}
-void action_run_list(GSList *acts, ObClient *c,
+void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
guint state, guint button, gint x, gint y,
gboolean cancel, gboolean done)
{
a = it->data;
a->data.any.c = c;
+ a->data.any.context = context;
a->data.any.x = x;
a->data.any.y = y;
}
}
- if (raise)
+ if (raise) {
+ ACT_START(data);
stacking_raise(CLIENT_AS_WINDOW(c));
- else
+ ACT_END(data);
+ } else {
+ ACT_START(data);
stacking_lower(CLIENT_AS_WINDOW(c));
+ ACT_END(data);
+ }
}
void action_raise(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+ ACT_END(data);
+ }
}
void action_unshaderaise(union ActionData *data)
{
if (data->client.any.c) {
if (data->client.any.c->shaded) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_shade(data->client.any.c, FALSE);
- grab_pointer(FALSE, OB_CURSOR_NONE);
- } else
+ ACT_END(data);
+ } else {
+ ACT_START(data);
stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+ ACT_END(data);
+ }
}
}
if (data->client.any.c->shaded)
stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
else {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_shade(data->client.any.c, TRUE);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
}
void action_lower(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
+ ACT_END(data);
+ }
}
void action_close(union ActionData *data)
void action_shade(union ActionData *data)
{
if (data->client.any.c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_shade(data->client.any.c, TRUE);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
void action_unshade(union ActionData *data)
{
if (data->client.any.c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_shade(data->client.any.c, FALSE);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
void action_toggle_shade(union ActionData *data)
{
if (data->client.any.c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_shade(data->client.any.c, !data->client.any.c->shaded);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_move(c, c->area.x + data->relative.delta, c->area.y);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_move(c, c->area.x, c->area.y + data->relative.delta);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_resize(c,
c->area.width + data->relative.delta * c->size_inc.width,
c->area.height);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
{
ObClient *c = data->relative.any.c;
if (c && !c->shaded) {
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_resize(c, c->area.width, c->area.height +
data->relative.delta * c->size_inc.height);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
}
void action_maximize_full(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, TRUE, 0, TRUE);
+ ACT_END(data);
+ }
}
void action_unmaximize_full(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, FALSE, 0, TRUE);
+ ACT_END(data);
+ }
}
void action_toggle_maximize_full(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_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);
+ }
}
void action_maximize_horz(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, TRUE, 1, TRUE);
+ ACT_END(data);
+ }
}
void action_unmaximize_horz(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, FALSE, 1, TRUE);
+ ACT_END(data);
+ }
}
void action_toggle_maximize_horz(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c,
!data->client.any.c->max_horz, 1, TRUE);
+ ACT_END(data);
+ }
}
void action_maximize_vert(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, TRUE, 2, TRUE);
+ ACT_END(data);
+ }
}
void action_unmaximize_vert(union ActionData *data)
{
- if (data->client.any.c)
+ if (data->client.any.c) {
+ ACT_START(data);
client_maximize(data->client.any.c, FALSE, 2, TRUE);
+ ACT_END(data);
+ }
}
void action_toggle_maximize_vert(union ActionData *data)
{
- if (data->client.any.c)
- client_maximize(data->client.any.c, !data->client.any.c->max_vert, 2, TRUE);
+ if (data->client.any.c) {
+ ACT_START(data);
+ client_maximize(data->client.any.c,
+ !data->client.any.c->max_vert, 2, TRUE);
+ ACT_END(data);
+ }
}
void action_send_to_desktop(union ActionData *data)
{
ObClient *c = data->client.any.c;
- if (!c) return;
-
- c->decorate = !c->decorate;
- client_setup_decor_and_functions(c);
+ if (c) {
+ ACT_START(data);
+ c->decorate = !c->decorate;
+ client_setup_decor_and_functions(c);
+ ACT_END(data);
+ }
}
static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch)
g_assert_not_reached();
}
frame_frame_gravity(c->frame, &x, &y);
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_move(c, x, y);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_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;
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ ACT_START(data);
client_move_resize(c, x, y, width, height);
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ ACT_END(data);
}
void action_send_to_layer(union ActionData *data)
ObClient *c = data->layer.any.c;
if (c) {
+ ACT_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);
}
}
struct AnyAction {
struct _ObClient *c;
+ ObFrameContext context;
gboolean interactive;
gint x;
gint y;
@param done If the action is completing an interactive action. This only
affects interactive actions, but should generally always be FALSE.
*/
-void action_run_list(GSList *acts, struct _ObClient *c,
+void action_run_list(GSList *acts, struct _ObClient *c, ObFrameContext context,
guint state, guint button, gint x, gint y,
gboolean cancel, gboolean done);
-#define action_run_mouse(a, c, s, b, x, y) \
- action_run_list(a, c, s, b, x, y, FALSE, FALSE)
+#define action_run_mouse(a, c, n, s, b, x, y) \
+ action_run_list(a, c, n, s, b, x, y, FALSE, FALSE)
#define action_run_interactive(a, c, s, n, d) \
- action_run_list(a, c, s, 0, -1, -1, n, d)
+ action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, n, d)
#define action_run_key(a, c, s, x, y) \
- action_run_list(a, c, s, 0, x, y, FALSE, FALSE)
+ action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, x, y, FALSE, FALSE)
#define action_run(a, c, s) \
- action_run_list(a, c, s, 0, -1, -1, FALSE, FALSE)
+ action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, FALSE, FALSE)
/* Execute */
void action_execute(union ActionData *data);