add destructor functions for clients that you acn subscribe with, and use these instead of hardcoding special cases in the unmanage code
This commit is contained in:
parent
2c6c0757fa
commit
8e76e32863
4 changed files with 43 additions and 8 deletions
|
@ -32,7 +32,8 @@
|
||||||
#define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
|
#define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
|
||||||
ButtonMotionMask)
|
ButtonMotionMask)
|
||||||
|
|
||||||
GList *client_list = NULL;
|
GList *client_list = NULL;
|
||||||
|
GSList *client_destructors = NULL;
|
||||||
|
|
||||||
static void client_get_all(ObClient *self);
|
static void client_get_all(ObClient *self);
|
||||||
static void client_toggle_border(ObClient *self, gboolean show);
|
static void client_toggle_border(ObClient *self, gboolean show);
|
||||||
|
@ -58,6 +59,16 @@ void client_shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_add_destructor(ObClientDestructorFunc func)
|
||||||
|
{
|
||||||
|
client_destructors = g_slist_prepend(client_destructors, (gpointer)func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void client_remove_destructor(ObClientDestructorFunc func)
|
||||||
|
{
|
||||||
|
client_destructors = g_slist_remove(client_destructors, (gpointer)func);
|
||||||
|
}
|
||||||
|
|
||||||
void client_set_list()
|
void client_set_list()
|
||||||
{
|
{
|
||||||
Window *windows, *win_it;
|
Window *windows, *win_it;
|
||||||
|
@ -414,13 +425,11 @@ void client_unmanage(ObClient *self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveresize_client == self)
|
for (it = client_destructors; it; it = g_slist_next(it)) {
|
||||||
moveresize_end(TRUE);
|
ObClientDestructorFunc func = (ObClientDestructorFunc) it->data;
|
||||||
|
func(self);
|
||||||
/* menus can be associated with a client, so close any that are since
|
}
|
||||||
we are disappearing now */
|
|
||||||
menu_frame_hide_all_client(self);
|
|
||||||
|
|
||||||
if (focus_client == self) {
|
if (focus_client == self) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,11 @@ extern GList *client_list;
|
||||||
void client_startup();
|
void client_startup();
|
||||||
void client_shutdown();
|
void client_shutdown();
|
||||||
|
|
||||||
|
typedef void (*ObClientDestructorFunc)(ObClient *c);
|
||||||
|
|
||||||
|
void client_add_destructor(ObClientDestructorFunc func);
|
||||||
|
void client_remove_destructor(ObClientDestructorFunc func);
|
||||||
|
|
||||||
/*! Manages all existing windows */
|
/*! Manages all existing windows */
|
||||||
void client_manage_all();
|
void client_manage_all();
|
||||||
/*! Manages a given window */
|
/*! Manages a given window */
|
||||||
|
|
|
@ -55,6 +55,13 @@ static gboolean menu_open(gchar *file, xmlDocPtr *doc, xmlNodePtr *node)
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void client_dest(ObClient *c)
|
||||||
|
{
|
||||||
|
/* menus can be associated with a client, so close any that are since
|
||||||
|
we are disappearing now */
|
||||||
|
menu_frame_hide_all_client(c);
|
||||||
|
}
|
||||||
|
|
||||||
void menu_startup()
|
void menu_startup()
|
||||||
{
|
{
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
|
@ -91,10 +98,14 @@ void menu_startup()
|
||||||
|
|
||||||
g_assert(menu_parse_state.menus == NULL);
|
g_assert(menu_parse_state.menus == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client_add_destructor(client_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_shutdown()
|
void menu_shutdown()
|
||||||
{
|
{
|
||||||
|
client_remove_destructor(client_dest);
|
||||||
|
|
||||||
parse_shutdown(menu_parse_inst);
|
parse_shutdown(menu_parse_inst);
|
||||||
menu_parse_inst = NULL;
|
menu_parse_inst = NULL;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ static Popup *popup = NULL;
|
||||||
#define POPUP_X (10)
|
#define POPUP_X (10)
|
||||||
#define POPUP_Y (10)
|
#define POPUP_Y (10)
|
||||||
|
|
||||||
|
static void client_dest(ObClient *c)
|
||||||
|
{
|
||||||
|
if (moveresize_client == c)
|
||||||
|
moveresize_end(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void moveresize_startup()
|
void moveresize_startup()
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
|
@ -38,10 +44,14 @@ void moveresize_startup()
|
||||||
popup_size_to_string(popup, "W: 0000 W: 0000");
|
popup_size_to_string(popup, "W: 0000 W: 0000");
|
||||||
|
|
||||||
attrib.save_under = True;
|
attrib.save_under = True;
|
||||||
|
|
||||||
|
client_add_destructor(client_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveresize_shutdown()
|
void moveresize_shutdown()
|
||||||
{
|
{
|
||||||
|
client_remove_destructor(client_dest);
|
||||||
|
|
||||||
popup_free(popup);
|
popup_free(popup);
|
||||||
popup = NULL;
|
popup = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue