#include "debug.h"
#include "menu.h"
#include "menuframe.h"
+#include "config.h"
#include "screen.h"
#include "client.h"
#include "openbox.h"
#include "frame.h"
#include "moveresize.h"
+#include "event.h"
#include "prop.h"
#include "gettext.h"
*en = c->functions & OB_CLIENT_FUNC_CLOSE;
break;
case CLIENT_DECORATE:
- *en = client_normal(c);
+ *en = c->functions & OB_CLIENT_FUNC_UNDECORATE;
break;
default:
*en = TRUE;
return TRUE; /* show the menu */
}
-static void client_menu_execute(ObMenuEntry *e, guint state, gpointer data,
- Time time)
+static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+ ObClient *c, guint state, gpointer data)
{
- GList *it;
- ObMenuFrame *f;
- ObClient *c;
-
- /* find our frame */
- for (it = menu_frame_visible; it; it = g_list_next(it)) {
- f = it->data;
- /* yay this is our menu frame */
- if (f->menu == e->menu)
- break;
- }
- g_assert(it);
+ gint x, y;
+ gulong ignore_start;
+
+ g_assert(c);
- c = f->client;
+ if (!config_focus_under_mouse)
+ ignore_start = event_start_ignore_all_enters();
switch (e->id) {
case CLIENT_ICONIFY:
- client_iconify(c, TRUE, FALSE);
/* the client won't be on screen anymore so hide the menu */
menu_frame_hide_all();
- return; /* and don't update */
+ f = NULL; /* and don't update */
+
+ client_iconify(c, TRUE, FALSE, FALSE);
+ break;
case CLIENT_RESTORE:
client_maximize(c, FALSE, 0);
break;
client_set_undecorated(c, !c->undecorated);
break;
case CLIENT_MOVE:
- moveresize_start(c,0,0,0, prop_atoms.net_wm_moveresize_move_keyboard);
+ /* this needs to grab the keyboard so hide the menu */
+ menu_frame_hide_all();
+ f = NULL; /* and don't update */
+
+ screen_pointer_pos(&x, &y);
+ moveresize_start(c, x, y, 0,
+ prop_atoms.net_wm_moveresize_move_keyboard);
break;
case CLIENT_RESIZE:
- moveresize_start(c,0,0,0,prop_atoms.net_wm_moveresize_size_keyboard);
+ /* this needs to grab the keyboard so hide the menu */
+ menu_frame_hide_all();
+ f = NULL; /* and don't update */
+
+ screen_pointer_pos(&x, &y);
+ moveresize_start(c, x, y, 0,
+ prop_atoms.net_wm_moveresize_size_keyboard);
break;
case CLIENT_CLOSE:
client_close(c);
g_assert_not_reached();
}
+ if (!config_focus_under_mouse)
+ event_end_ignore_all_enters(ignore_start);
+
/* update the menu cuz stuff can have changed */
- client_menu_update(f, NULL);
- menu_frame_render(f);
+ if (f) {
+ client_menu_update(f, NULL);
+ menu_frame_render(f);
+ }
}
static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data)
if (e->type == OB_MENU_ENTRY_TYPE_NORMAL) {
switch (e->id) {
case LAYER_TOP:
- *en = !c->above;
+ *en = !c->above && (c->functions & OB_CLIENT_FUNC_ABOVE);
break;
case LAYER_NORMAL:
*en = c->above || c->below;
break;
case LAYER_BOTTOM:
- *en = !c->below;
+ *en = !c->below && (c->functions & OB_CLIENT_FUNC_BELOW);
break;
default:
*en = TRUE;
return TRUE; /* show the menu */
}
-static void layer_menu_execute(ObMenuEntry *e, guint state, gpointer data,
- Time time)
+static void layer_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+ ObClient *c, guint state, gpointer data)
{
- GList *it;
- ObMenuFrame *f;
-
- /* find our frame */
- for (it = menu_frame_visible; it; it = g_list_next(it)) {
- f = it->data;
- /* yay this is our menu frame */
- if (f->menu == e->menu)
- break;
- }
- g_assert(it);
+ gulong ignore_start;
+
+ g_assert(c);
+
+ if (!config_focus_under_mouse)
+ ignore_start = event_start_ignore_all_enters();
switch (e->id) {
case LAYER_TOP:
- client_set_layer(f->client, 1);
+ client_set_layer(c, 1);
break;
case LAYER_NORMAL:
- client_set_layer(f->client, 0);
+ client_set_layer(c, 0);
break;
case LAYER_BOTTOM:
- client_set_layer(f->client, -1);
+ client_set_layer(c, -1);
break;
default:
g_assert_not_reached();
}
+ if (!config_focus_under_mouse)
+ event_end_ignore_all_enters(ignore_start);
+
/* update the menu cuz stuff can have changed */
- layer_menu_update(f, NULL);
- menu_frame_render(f);
+ if (f) {
+ layer_menu_update(f, NULL);
+ menu_frame_render(f);
+ }
}
static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data)
return TRUE; /* show the menu */
}
-static void send_to_menu_execute(ObMenuEntry *e, guint state, gpointer data,
- Time time)
+static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+ ObClient *c, guint state, gpointer data)
{
- GList *it;
- ObMenuFrame *f;
-
- /* find our frame */
- for (it = menu_frame_visible; it; it = g_list_next(it)) {
- f = it->data;
- /* yay this is our menu frame */
- if (f->menu == e->menu)
- break;
- }
- g_assert(it);
+ g_assert(c);
- client_set_desktop(f->client, e->id, FALSE);
+ client_set_desktop(c, e->id, FALSE, FALSE);
/* the client won't even be on the screen anymore, so hide the menu */
- menu_frame_hide_all();
+ if (f)
+ menu_frame_hide_all();
}
static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y,
- gint button, gpointer data)
+ gboolean mouse, gpointer data)
{
gint dx, dy;
- if (button == 0 && frame->client) {
+ if (!mouse && frame->client) {
*x = frame->client->frame->area.x;
/* try below the titlebar */
}
}
-void client_menu_startup()
+void client_menu_startup(void)
{
ObMenu *menu;
ObMenuEntry *e;
- menu = menu_new(LAYER_MENU_NAME, _("&Layer"), TRUE, NULL);
+ menu = menu_new(LAYER_MENU_NAME, _("_Layer"), TRUE, NULL);
menu_show_all_shortcuts(menu, TRUE);
menu_set_update_func(menu, layer_menu_update);
menu_set_execute_func(menu, layer_menu_execute);
- menu_add_normal(menu, LAYER_TOP, _("Always on &top"), NULL, TRUE);
- menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), NULL, TRUE);
- menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),NULL, TRUE);
+ menu_add_normal(menu, LAYER_TOP, _("Always on _top"), NULL, TRUE);
+ menu_add_normal(menu, LAYER_NORMAL, _("_Normal"), NULL, TRUE);
+ menu_add_normal(menu, LAYER_BOTTOM, _("Always on _bottom"),NULL, TRUE);
- menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), TRUE, NULL);
+ menu = menu_new(SEND_TO_MENU_NAME, _("_Send to desktop"), TRUE, NULL);
menu_set_update_func(menu, send_to_menu_update);
menu_set_execute_func(menu, send_to_menu_execute);
menu_set_place_func(menu, client_menu_place);
menu_set_execute_func(menu, client_menu_execute);
- e = menu_add_normal(menu, CLIENT_RESTORE, _("R&estore"), NULL, TRUE);
- e->data.normal.mask = ob_rr_theme->max_toggled_mask;
+ menu_add_submenu(menu, CLIENT_SEND_TO, SEND_TO_MENU_NAME);
+
+ menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME);
+
+ e = menu_add_normal(menu, CLIENT_RESTORE, _("R_estore"), NULL, TRUE);
+ e->data.normal.mask = ob_rr_theme->max_toggled_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- menu_add_normal(menu, CLIENT_MOVE, _("&Move"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_MOVE, _("_Move"), NULL, TRUE);
- menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_RESIZE, _("Resi_ze"), NULL, TRUE);
- e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico_nify"), NULL, TRUE);
e->data.normal.mask = ob_rr_theme->iconify_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Ma&ximize"), NULL, TRUE);
- e->data.normal.mask = ob_rr_theme->max_mask;
+ e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Ma_ximize"), NULL, TRUE);
+ e->data.normal.mask = ob_rr_theme->max_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- e = menu_add_normal(menu, CLIENT_SHADE, _("&Roll up/down"), NULL, TRUE);
- e->data.normal.mask = ob_rr_theme->shade_mask;
- e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
- e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
- e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
- e->data.normal.mask_disabled_selected_color =
- ob_rr_theme->menu_disabled_selected_color;
-
- menu_add_normal(menu, CLIENT_DECORATE, _("Un/&Decorate"), NULL, TRUE);
-
- menu_add_separator(menu, -1, NULL);
-
- menu_add_submenu(menu, CLIENT_SEND_TO, SEND_TO_MENU_NAME);
+ menu_add_normal(menu, CLIENT_SHADE, _("_Roll up/down"), NULL, TRUE);
- menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME);
+ menu_add_normal(menu, CLIENT_DECORATE, _("Un/_Decorate"), NULL, TRUE);
menu_add_separator(menu, -1, NULL);
- e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_CLOSE, _("_Close"), NULL, TRUE);
e->data.normal.mask = ob_rr_theme->close_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;