The attached two patches add some new attributes to clients and
monitors, see commit message for details.
The pid attribute will be -1 if the client didn't set it, I'm not sure
if this is the best solution, or if I should handle this attribute as
a custom string instead, and return an empty string if there is no pid
set. Opinions?
Florian
--
() ascii ribbon campaign - stop html mail www.asciiribbon.org
/\ www.the-compiler.org | I love long mails http://email.is-not-s.ms/
Hating the Yankees is as American as pizza pie, unwed mothers and cheating on
your income tax. -- Mike Royko
From a9d08046ff3ebeb152baaabf51b242358d6e3cbc Mon Sep 17 00:00:00 2001 From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org> Date: Tue, 18 Jun 2013 22:44:24 +0200 Subject: [PATCH 1/2] Add some new client attributes This adds the following new attributes: tag: The tag the client is on (as string, readonly) pid: The pid of the client (-1 if not set, readonly) class: The class of the window (empty if not set, readonly) instance: The instance of the window (empty if not set, readonly) --- src/clientlist.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/clientlist.c b/src/clientlist.c index 363b3b5..b60a4d1 100644 --- a/src/clientlist.c +++ b/src/clientlist.c @@ -141,6 +141,20 @@ HSClient* get_client_from_window(Window window) { } \ while (0); +static void client_attr_class(void* data, GString* output) { + HSClient* client = (HSClient*) data; + GString* ret = window_class_to_g_string(g_display, client->window); + g_string_assign(output, ret->str); + g_string_free(ret, true); +} + +static void client_attr_instance(void* data, GString* output) { + HSClient* client = (HSClient*) data; + GString* ret = window_instance_to_g_string(g_display, client->window); + g_string_assign(output, ret->str); + g_string_free(ret, true); +} + static GString* client_attr_fullscreen(HSAttribute* attr) { CLIENT_UPDATE_ATTR(client_set_fullscreen, fullscreen); } @@ -221,9 +235,15 @@ HSClient* manage_client(Window win) { frame_focus_window(client->tag->frame, win); } + client->object.data = client; + HSAttribute attributes[] = { ATTRIBUTE_STRING( "winid", client->window_str, ATTR_READ_ONLY), ATTRIBUTE_STRING( "title", client->title, ATTR_READ_ONLY), + ATTRIBUTE_STRING( "tag", client->tag->display_name, ATTR_READ_ONLY), + ATTRIBUTE_INT( "pid", client->pid, ATTR_READ_ONLY), + ATTRIBUTE_CUSTOM( "class", client_attr_class, ATTR_READ_ONLY), + ATTRIBUTE_CUSTOM( "instance", client_attr_instance, ATTR_READ_ONLY), ATTRIBUTE_BOOL( "fullscreen", client->fullscreen, client_attr_fullscreen), ATTRIBUTE_BOOL( "pseudotile", client->pseudotile, client_attr_pseudotile), ATTRIBUTE_BOOL( "ewmhrequests", client->ewmhrequests, ATTR_ACCEPT_ALL), -- 1.8.3.1
From 6a398af50b3934c30e999d291a41cf9a9aaa6646 Mon Sep 17 00:00:00 2001 From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org> Date: Tue, 18 Jun 2013 23:19:41 +0200 Subject: [PATCH 2/2] Add tag attribute to monitor object This adds an attribute "tag" to each monitor object which is the tag shown on the monitor as a string. --- src/monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/monitor.c b/src/monitor.c index 918c91e..ca614bb 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -409,6 +409,7 @@ HSMonitor* add_monitor(XRectangle rect, HSTag* tag, char* name) { HSAttribute attributes[] = { ATTRIBUTE_STRING( "name", m->display_name,ATTR_READ_ONLY ), ATTRIBUTE_CUSTOM_INT("index", monitor_attr_index,ATTR_READ_ONLY ), + ATTRIBUTE_STRING( "tag", m->tag->display_name,ATTR_READ_ONLY ), ATTRIBUTE_BOOL( "lock_tag", m->lock_tag, ATTR_READ_ONLY ), ATTRIBUTE_LAST, }; -- 1.8.3.1
Attachment:
pgpTrSYnmz1tx.pgp
Description: PGP signature
Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev