don't show the client menu when its for an invalid window

This commit is contained in:
Dana Jansens 2007-05-03 20:39:26 +00:00
parent 53975abf12
commit e0e1d4ba7e
5 changed files with 39 additions and 30 deletions

View file

@ -33,7 +33,7 @@
ObMenu *combined_menu; ObMenu *combined_menu;
static void self_update(ObMenuFrame *frame, gpointer data) static gboolean self_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
ObMenuEntry *e; ObMenuEntry *e;
@ -104,6 +104,7 @@ static void self_update(ObMenuFrame *frame, gpointer data)
e->data.normal.enabled = FALSE; e->data.normal.enabled = FALSE;
} }
} }
return TRUE; /* always show the menu */
} }
/* executes it using the client in the actions, since we set that /* executes it using the client in the actions, since we set that

View file

@ -38,7 +38,7 @@ typedef struct
guint desktop; guint desktop;
} DesktopData; } DesktopData;
static void desk_menu_update(ObMenuFrame *frame, gpointer data) static gboolean desk_menu_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
DesktopData *d = data; DesktopData *d = data;
@ -105,6 +105,7 @@ static void desk_menu_update(ObMenuFrame *frame, gpointer data)
if (d->desktop == screen_desktop) if (d->desktop == screen_desktop)
e->data.normal.enabled = FALSE; e->data.normal.enabled = FALSE;
} }
return TRUE; /* always show */
} }
/* executes it using the client in the actions, since we set that /* executes it using the client in the actions, since we set that
@ -129,7 +130,7 @@ static void desk_menu_destroy(ObMenu *menu, gpointer data)
desktop_menus = g_slist_remove(desktop_menus, menu); desktop_menus = g_slist_remove(desktop_menus, menu);
} }
static void self_update(ObMenuFrame *frame, gpointer data) static gboolean self_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
guint i; guint i;
@ -162,6 +163,8 @@ static void self_update(ObMenuFrame *frame, gpointer data)
desktop_menus = g_slist_delete_link(desktop_menus, it); desktop_menus = g_slist_delete_link(desktop_menus, it);
menu_entry_remove(menu_find_entry_id(menu, i)); menu_entry_remove(menu_find_entry_id(menu, i));
} }
return TRUE; /* always show */
} }
static void client_dest(ObClient *client, gpointer data) static void client_dest(ObClient *client, gpointer data)

View file

@ -51,21 +51,21 @@ enum {
CLIENT_CLOSE CLIENT_CLOSE
}; };
static void client_update(ObMenuFrame *frame, gpointer data) static gboolean client_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
ObMenuEntry *e; ObMenuEntry *e;
GList *it; GList *it;
if (frame->client == NULL || !client_normal(frame->client))
return FALSE; /* don't show the menu */
for (it = menu->entries; it; it = g_list_next(it)) { for (it = menu->entries; it; it = g_list_next(it)) {
e = it->data; e = it->data;
if (e->type == OB_MENU_ENTRY_TYPE_NORMAL) if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
e->data.normal.enabled = !!frame->client; e->data.normal.enabled = TRUE;
} }
if (!frame->client)
return;
e = menu_find_entry_id(menu, CLIENT_ICONIFY); e = menu_find_entry_id(menu, CLIENT_ICONIFY);
e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_ICONIFY; e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_ICONIFY;
@ -91,23 +91,24 @@ static void client_update(ObMenuFrame *frame, gpointer data)
e = menu_find_entry_id(menu, CLIENT_DECORATE); e = menu_find_entry_id(menu, CLIENT_DECORATE);
e->data.normal.enabled = client_normal(frame->client); e->data.normal.enabled = client_normal(frame->client);
return TRUE; /* show the menu */
} }
static void layer_update(ObMenuFrame *frame, gpointer data) static gboolean layer_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
ObMenuEntry *e; ObMenuEntry *e;
GList *it; GList *it;
if (frame->client == NULL || !client_normal(frame->client))
return FALSE; /* don't show the menu */
for (it = menu->entries; it; it = g_list_next(it)) { for (it = menu->entries; it; it = g_list_next(it)) {
e = it->data; e = it->data;
if (e->type == OB_MENU_ENTRY_TYPE_NORMAL) if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
e->data.normal.enabled = !!frame->client; e->data.normal.enabled = TRUE;
} }
if (!frame->client)
return;
e = menu_find_entry_id(menu, LAYER_TOP); e = menu_find_entry_id(menu, LAYER_TOP);
e->data.normal.enabled = !frame->client->above; e->data.normal.enabled = !frame->client->above;
@ -116,9 +117,10 @@ static void layer_update(ObMenuFrame *frame, gpointer data)
e = menu_find_entry_id(menu, LAYER_BOTTOM); e = menu_find_entry_id(menu, LAYER_BOTTOM);
e->data.normal.enabled = !frame->client->below; e->data.normal.enabled = !frame->client->below;
return TRUE; /* show the menu */
} }
static void send_to_update(ObMenuFrame *frame, gpointer data) static gboolean send_to_update(ObMenuFrame *frame, gpointer data)
{ {
ObMenu *menu = frame->menu; ObMenu *menu = frame->menu;
guint i; guint i;
@ -128,8 +130,8 @@ static void send_to_update(ObMenuFrame *frame, gpointer data)
menu_clear_entries(menu); menu_clear_entries(menu);
if (!frame->client) if (frame->client == NULL || !client_normal(frame->client))
return; return FALSE; /* don't show the menu */
for (i = 0; i <= screen_num_desktops; ++i) { for (i = 0; i <= screen_num_desktops; ++i) {
const gchar *name; const gchar *name;
@ -155,6 +157,7 @@ static void send_to_update(ObMenuFrame *frame, gpointer data)
if (frame->client->desktop == desk) if (frame->client->desktop == desk)
e->data.normal.enabled = FALSE; e->data.normal.enabled = FALSE;
} }
return TRUE; /* show the menu */
} }
static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y, static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y,
@ -269,7 +272,7 @@ void client_menu_startup()
acts = g_slist_prepend(NULL, action_from_string acts = g_slist_prepend(NULL, action_from_string
("ToggleMaximizeFull", ("ToggleMaximizeFull",
OB_USER_ACTION_MENU_SELECTION)); OB_USER_ACTION_MENU_SELECTION));
e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts, TRUE); e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Maximiz&e"), acts, TRUE);
e->data.normal.mask = ob_rr_theme->max_mask; e->data.normal.mask = ob_rr_theme->max_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
@ -285,7 +288,7 @@ void client_menu_startup()
acts = g_slist_prepend(NULL, action_from_string acts = g_slist_prepend(NULL, action_from_string
("ToggleShade", OB_USER_ACTION_MENU_SELECTION)); ("ToggleShade", OB_USER_ACTION_MENU_SELECTION));
e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts, TRUE); e = menu_add_normal(menu, CLIENT_SHADE, _("&Roll up"), acts, TRUE);
e->data.normal.mask = ob_rr_theme->shade_mask; e->data.normal.mask = ob_rr_theme->shade_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;

View file

@ -37,7 +37,8 @@ typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry; typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry; typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
typedef void (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, gpointer data); typedef gboolean (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame,
gpointer data);
typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry, typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry,
guint state, gpointer data, Time time); guint state, gpointer data, Time time);
typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data); typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data);

View file

@ -751,16 +751,6 @@ static gboolean menu_frame_show(ObMenuFrame *self)
{ {
GList *it; GList *it;
if (menu_frame_visible == NULL) {
/* no menus shown yet */
if (!grab_pointer(TRUE, TRUE, OB_CURSOR_POINTER))
return FALSE;
if (!grab_keyboard(TRUE)) {
grab_pointer(FALSE, TRUE, OB_CURSOR_POINTER);
return FALSE;
}
}
/* determine if the underlying menu is already visible */ /* determine if the underlying menu is already visible */
for (it = menu_frame_visible; it; it = g_list_next(it)) { for (it = menu_frame_visible; it; it = g_list_next(it)) {
ObMenuFrame *f = it->data; ObMenuFrame *f = it->data;
@ -769,7 +759,18 @@ static gboolean menu_frame_show(ObMenuFrame *self)
} }
if (!it) { if (!it) {
if (self->menu->update_func) if (self->menu->update_func)
self->menu->update_func(self, self->menu->data); if (!self->menu->update_func(self, self->menu->data))
return FALSE;
}
if (menu_frame_visible == NULL) {
/* no menus shown yet */
if (!grab_pointer(TRUE, TRUE, OB_CURSOR_POINTER))
return FALSE;
if (!grab_keyboard(TRUE)) {
grab_pointer(FALSE, TRUE, OB_CURSOR_POINTER);
return FALSE;
}
} }
menu_frame_update(self); menu_frame_update(self);