fix no more crashing in the client menu.

This commit is contained in:
Dana Jansens 2007-05-09 00:11:06 +00:00
parent 1361a87bdf
commit f0fdba8ad3
3 changed files with 29 additions and 46 deletions

View file

@ -100,30 +100,21 @@ static gboolean client_menu_update(ObMenuFrame *frame, gpointer data)
return TRUE; /* show the menu */ return TRUE; /* show the menu */
} }
static void client_menu_execute(ObMenuEntry *e, guint state, gpointer data, static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
ObClient *c, guint state, gpointer data,
Time time) Time time)
{ {
GList *it; GList *it;
ObMenuFrame *f;
ObClient *c;
/* find our frame */ g_assert(c);
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);
c = f->client;
switch (e->id) { switch (e->id) {
case CLIENT_ICONIFY: case CLIENT_ICONIFY:
client_iconify(c, TRUE, FALSE); client_iconify(c, TRUE, FALSE);
/* the client won't be on screen anymore so hide the menu */ /* the client won't be on screen anymore so hide the menu */
menu_frame_hide_all(); menu_frame_hide_all();
return; /* and don't update */ f = NULL; /* and don't update */
break;
case CLIENT_RESTORE: case CLIENT_RESTORE:
client_maximize(c, FALSE, 0); client_maximize(c, FALSE, 0);
break; break;
@ -150,8 +141,10 @@ static void client_menu_execute(ObMenuEntry *e, guint state, gpointer data,
} }
/* update the menu cuz stuff can have changed */ /* update the menu cuz stuff can have changed */
if (f) {
client_menu_update(f, NULL); client_menu_update(f, NULL);
menu_frame_render(f); menu_frame_render(f);
}
} }
static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data) static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data)
@ -186,20 +179,11 @@ static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data)
return TRUE; /* show the menu */ return TRUE; /* show the menu */
} }
static void layer_menu_execute(ObMenuEntry *e, guint state, gpointer data, static void layer_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
ObClient *c, guint state, gpointer data,
Time time) Time time)
{ {
GList *it; g_assert(c);
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);
switch (e->id) { switch (e->id) {
case LAYER_TOP: case LAYER_TOP:
@ -216,8 +200,10 @@ static void layer_menu_execute(ObMenuEntry *e, guint state, gpointer data,
} }
/* update the menu cuz stuff can have changed */ /* update the menu cuz stuff can have changed */
if (f) {
layer_menu_update(f, NULL); layer_menu_update(f, NULL);
menu_frame_render(f); menu_frame_render(f);
}
} }
static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data) static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data)
@ -264,23 +250,15 @@ static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data)
return TRUE; /* show the menu */ return TRUE; /* show the menu */
} }
static void send_to_menu_execute(ObMenuEntry *e, guint state, gpointer data, static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
ObClient *c, guint state, gpointer data,
Time time) Time time)
{ {
GList *it; g_assert(c);
ObMenuFrame *f;
/* find our frame */ client_set_desktop(c, e->id, FALSE);
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);
client_set_desktop(f->client, e->id, FALSE);
/* the client won't even be on the screen anymore, so hide the menu */ /* the client won't even be on the screen anymore, so hide the menu */
if (f)
menu_frame_hide_all(); menu_frame_hide_all();
} }

View file

@ -42,6 +42,8 @@ typedef void (*ObMenuHideFunc)(struct _ObMenuFrame *frame, gpointer data);
typedef gboolean (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, typedef gboolean (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame,
gpointer data); gpointer data);
typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry, typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry,
struct _ObMenuFrame *frame,
ObClient *client,
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);
/*! @param x is the mouse x coordinate. on return it should be the x coordinate /*! @param x is the mouse x coordinate. on return it should be the x coordinate

View file

@ -1169,13 +1169,16 @@ void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state, Time time)
gpointer data = self->frame->menu->data; gpointer data = self->frame->menu->data;
GSList *acts = self->entry->data.normal.actions; GSList *acts = self->entry->data.normal.actions;
ObClient *client = self->frame->client; ObClient *client = self->frame->client;
ObMenuFrame *frame = self->frame;
/* release grabs before executing the shit */ /* release grabs before executing the shit */
if (!(state & ControlMask)) if (!(state & ControlMask)) {
menu_frame_hide_all(); menu_frame_hide_all();
frame = NULL;
}
if (func) if (func)
func(entry, state, data, time); func(entry, frame, client, state, data, time);
else else
action_run(acts, client, state, time); action_run(acts, client, state, time);
} }