diff options
author | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2013-01-05 18:22:38 +0100 |
---|---|---|
committer | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2013-02-17 12:23:58 +0100 |
commit | 6f59e6fa50c3a16d5de9b52200aaa5b932e798e0 (patch) | |
tree | 13ac5b85f7fc71bb8d1f7fc288f7f0a13aa41327 | |
parent | 0671096aca0fe5d7f34b88dc9805a5b28befd66a (diff) |
Handle clients in the object tree
-rw-r--r-- | src/clientlist.c | 14 | ||||
-rw-r--r-- | src/clientlist.h | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/clientlist.c b/src/clientlist.c index 6c7ee966..e2630ceb 100644 --- a/src/clientlist.c +++ b/src/clientlist.c @@ -14,6 +14,7 @@ #include "ewmh.h" #include "rules.h" #include "ipc-protocol.h" +#include "object.h" // system #include <glib.h> #include <assert.h> @@ -41,7 +42,8 @@ unsigned long g_window_border_normal_color; unsigned long g_window_border_urgent_color; unsigned long g_window_border_inner_color; -GHashTable* g_clients; // container of all clients +static GHashTable* g_clients; // container of all clients +static HSObject g_client_object; // atoms from dwm.c // default atoms @@ -50,6 +52,7 @@ static Atom g_wmatom[WMLast]; static HSClient* create_client() { HSClient* hc = g_new0(HSClient, 1); + hsobject_init(&hc->object); hc->float_size.width = 100; hc->float_size.height = 100; hc->title = g_string_new(""); @@ -87,6 +90,8 @@ void clientlist_init() { g_wmatom[WMState] = XInternAtom(g_display, "WM_STATE", False); g_wmatom[WMTakeFocus] = XInternAtom(g_display, "WM_TAKE_FOCUS", False); // init actual client list + hsobject_init(&g_client_object); + hsobject_link(hsobject_root(), &g_client_object, "clients"); g_clients = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, (GDestroyNotify)client_destroy); } @@ -114,6 +119,8 @@ void clientlist_destroy() { g_hash_table_foreach(g_clients, client_move_to_floatpos, NULL); g_hash_table_destroy(g_clients); + hsobject_unlink(hsobject_root(), &g_client_object); + hsobject_free(&g_client_object); } @@ -170,6 +177,10 @@ HSClient* manage_client(Window win) { // actually manage it g_hash_table_insert(g_clients, &(client->window), client); + GString* winid_str = g_string_sized_new(10); + g_string_printf(winid_str, "0x%lx", win); + hsobject_link(&g_client_object, &client->object, winid_str->str); + g_string_free(winid_str, true); // insert to layout if (!client->tag) { client->tag = m->tag; @@ -252,6 +263,7 @@ void client_destroy(HSClient* client) { /* free window title */ g_string_free(client->title, true); } + hsobject_unlink(&g_client_object, &client->object); g_free(client); } diff --git a/src/clientlist.h b/src/clientlist.h index 18e40bbe..c19d4866 100644 --- a/src/clientlist.h +++ b/src/clientlist.h @@ -14,6 +14,7 @@ #include <stdbool.h> #include "layout.h" +#include "object.h" struct HSSlice; @@ -32,6 +33,7 @@ typedef struct HSClient { bool ewmhrequests; // accept ewmh-requests for this client bool ewmhnotify; // send ewmh-notifications for this client int pid; + HSObject object; struct HSSlice* slice; } HSClient; |