add pid field to client
This commit is contained in:
parent
f14a75b83e
commit
62bf51d706
20
src/client.c
20
src/client.c
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "client.h"
|
||||
#include "util.h"
|
||||
#include "wm.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -74,6 +75,7 @@ Client* wm_client_create(Wm *wm, Window w)
|
||||
c->hidden = true;
|
||||
c->is_floating = false;
|
||||
c->name = NULL;
|
||||
c->is_pid_set = false;
|
||||
|
||||
if (xtp.value) {
|
||||
strln = strlen((char*)xtp.value);
|
||||
@ -88,8 +90,21 @@ Client* wm_client_create(Wm *wm, Window w)
|
||||
wm_client_set_atom(wm, c, "_NET_WM_DESKTOP", (unsigned char*)&c->ws->index,
|
||||
XA_CARDINAL, 1);
|
||||
|
||||
unsigned char *prop_ret = NULL;
|
||||
unsigned long nitems_ret;
|
||||
Atom type;
|
||||
bool is_normal = false;
|
||||
|
||||
type = wm_client_get_atom(wm, c, "_NET_WM_PID", &prop_ret, &nitems_ret);
|
||||
if (!nitems_ret || !prop_ret) goto ret;
|
||||
|
||||
c->pid = *((int*)prop_ret);
|
||||
DEBUG_PRINT("pid: %d\n", c->pid);
|
||||
c->is_pid_set = true;
|
||||
|
||||
ret:
|
||||
XFree(xtp.value);
|
||||
if (prop_ret) XFree(prop_ret);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -308,11 +323,6 @@ Atom wm_client_get_atom(Wm *wm, Client *c, const char *name, unsigned char **ato
|
||||
DEBUG_PRINT("actual format return: %d\n", format_ret)
|
||||
DEBUG_PRINT("actual number of items return: %ld\n", *nitems_ret)
|
||||
DEBUG_PRINT("bytes remaining: %ld\n", *nitems_ret)
|
||||
for (int i = 0; i < *nitems_ret; i++) {
|
||||
char *atom_name = XGetAtomName(wm->display, ((Atom*)*atom_ret)[i]);
|
||||
printf("property return str: %s\n", atom_name);
|
||||
XFree(atom_name);
|
||||
}
|
||||
|
||||
return type_ret;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ struct Client {
|
||||
bool focused;
|
||||
bool has_border;
|
||||
bool is_floating;
|
||||
pid_t pid;
|
||||
bool is_pid_set;
|
||||
};
|
||||
|
||||
XWindowChanges wm_client_to_xwchanges(Client *c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user