Heya, it's been a while, but I finally updated these patches :) (yay, first real post in the new ml!) * Thorsten Wißmann <edu _at_ thorsten _minus_ wissmann _dot_ de> [2013-06-24 12:53:26 +0200]: > On Thu, Jun 20, 2013 at 10:38:07PM +0200, Florian Bruhin wrote: > > 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? > > I'd prefer the -1 option (and document it in the manpage) > > You also could add some description of the attributes to the manpage > (there's already a OBJECTS section[1] describing the attributes) Done. > > HSAttribute attributes[] = { > > + ATTRIBUTE_STRING( "tag", client->tag->display_name, ATTR_READ_ONLY), > > This looks wrong, because ATTRIBUTE_STRING remembers the address of the > string you gave it. So in your case this attribute will always give the > name of the tag the client initially was on (and it should crash as soon > as the initial tag is removed). I recommend using a custom string > attribute here. (ATTRIBUTE_STRING only works for strings whose address > is constant during the livetime of the object or client in this case). Also done, didn't know about that, seemed logical like I did it :) I have to apologize about the quality of the previous patches, I was sending out patches to the ML and was like "oh, that's also finished and seems to work, let's send it out" without actually really testing it :-/ Flo -- () ascii ribbon campaign - stop html mail www.asciiribbon.org /\ www.the-compiler.org | I love long mails http://email.is-not-s.ms/ May you die in bed at 95, shot by a jealous spouse.
From 3f8c816a84c15a83c83cec167a57bf90c6d7f29d 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)
---
doc/herbstluftwm.txt | 4 ++++
src/clientlist.c | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index bb2b0a5..054577b 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -1259,6 +1259,10 @@ listed as follows:
|===========================
s - winid , its window id
s - title , its window title
+ s - tag , the tag it's currently on
+ i - pid , the process id of it (-1 if unset)
+ s - class , the class of it (second entry in WM_CLASS)
+ s - instance , the instance of it (first entry in WM_CLASS)
b w fullscreen ,
b w pseudotile ,
b w ewmhrequests , if ewmh requests are permitted for this client
diff --git a/src/clientlist.c b/src/clientlist.c
index 3b7aa2d..134add6 100644
--- a/src/clientlist.c
+++ b/src/clientlist.c
@@ -149,6 +149,25 @@ HSClient* get_client_from_window(Window window) {
} \
while (0);
+static void client_attr_tag(void* data, GString* output) {
+ HSClient* client = (HSClient*) data;
+ g_string_assign(output, client->tag->display_name->str);
+}
+
+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);
}
@@ -229,9 +248,15 @@ HSClient* manage_client(Window win) {
frame_focus_client(client->tag->frame, client);
}
+ client->object.data = client;
+
HSAttribute attributes[] = {
ATTRIBUTE_STRING( "winid", client->window_str,
ATTR_READ_ONLY),
ATTRIBUTE_STRING( "title", client->title,
ATTR_READ_ONLY),
+ ATTRIBUTE_CUSTOM( "tag", client_attr_tag,
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.4
From 59e8f639c449440ea6bcf56bb27989c0c5eea78b 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.
---
doc/herbstluftwm.txt | 1 +
src/monitor.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index 054577b..669dd9b 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -1280,6 +1280,7 @@ listed as follows:
|===========================
s - name , its name
i - index , its index
+ s - tag , the tag currently viewed on it
b - lock_tag ,
|===========================
diff --git a/src/monitor.c b/src/monitor.c
index dd76939..a98262c 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -386,6 +386,11 @@ static int monitor_attr_index(void* data) {
return monitor_index_of(m);
}
+static void monitor_attr_tag(void* data, GString* output) {
+ HSMonitor* m = (HSMonitor*) data;
+ g_string_assign(output, m->tag->display_name->str);
+}
+
HSMonitor* add_monitor(XRectangle rect, HSTag* tag, char* name) {
assert(tag != NULL);
HSMonitor* m = g_new0(HSMonitor, 1);
@@ -409,6 +414,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_CUSTOM( "tag", monitor_attr_tag,ATTR_READ_ONLY ),
ATTRIBUTE_BOOL( "lock_tag", m->lock_tag, ATTR_READ_ONLY ),
ATTRIBUTE_LAST,
};
--
1.8.4
Attachment:
pgp7YhgdTMIP_.pgp
Description: PGP signature
_______________________________________________ hlwm mailing list hlwm _at_ lists _dot_ herbstluftwm _dot_ org https://lists.schokokeks.org/mailman/listinfo.cgi/hlwm