diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-08 00:36:47 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-08 00:39:19 -0400 |
commit | b17a26a5c9259c52f81d95bcdac4a0df5c6a5854 (patch) | |
tree | 7d13e6d85981a62075dd97bab72120ec5cb0b775 | |
parent | db4de803acdf72bca4587f448b8f08e8e3b549dd (diff) | |
download | runes-b17a26a5c9259c52f81d95bcdac4a0df5c6a5854.tar.gz runes-b17a26a5c9259c52f81d95bcdac4a0df5c6a5854.zip |
handle most of the rest of the wm properties
-rw-r--r-- | runes.c | 2 | ||||
-rw-r--r-- | term.c | 4 | ||||
-rw-r--r-- | term.h | 2 | ||||
-rw-r--r-- | xlib.c | 40 | ||||
-rw-r--r-- | xlib.h | 7 |
5 files changed, 46 insertions, 9 deletions
@@ -12,7 +12,7 @@ int main (int argc, char *argv[]) setlocale(LC_ALL, ""); - t = runes_term_create(); + t = runes_term_create(argc, argv); runes_display_init(t); @@ -2,13 +2,13 @@ #include "runes.h" -RunesTerm *runes_term_create() +RunesTerm *runes_term_create(int argc, char *argv[]) { RunesTerm *t; t = malloc(sizeof(RunesTerm)); - t->w = runes_window_create(); + t->w = runes_window_create(argc, argv); t->surface = runes_surface_create(t); t->cr = cairo_create(t->surface); t->loop = runes_loop_create(t); @@ -11,7 +11,7 @@ struct runes_term { uv_loop_t *loop; }; -RunesTerm *runes_term_create(); +RunesTerm *runes_term_create(int argc, char *argv[]); void runes_term_destroy(RunesTerm *t); #endif @@ -1,16 +1,49 @@ #include <cairo-xlib.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <X11/Xlib.h> +#include <X11/Xatom.h> +#include <X11/Xutil.h> #include "runes.h" static char *atom_names[RUNES_NUM_ATOMS] = { "WM_DELETE_WINDOW", - "_NET_WM_PING" + "_NET_WM_PING", + "_NET_WM_PID", + "_NET_WM_ICON_NAME", + "_NET_WM_NAME", + "UTF8_STRING" }; -RunesWindow *runes_window_create() +static void runes_init_wm_properties(RunesWindow *w, int argc, char *argv[]) +{ + pid_t pid; + XClassHint class_hints = { "runes", "runes" }; + XWMHints wm_hints; + XSizeHints normal_hints; + + wm_hints.flags = InputHint | StateHint; + wm_hints.input = True; + wm_hints.initial_state = NormalState; + + /* XXX */ + normal_hints.flags = 0; + + XInternAtoms(w->dpy, atom_names, RUNES_NUM_ATOMS, False, w->atoms); + XSetWMProtocols(w->dpy, w->w, w->atoms, RUNES_NUM_PROTOCOL_ATOMS); + + Xutf8SetWMProperties(w->dpy, w->w, "runes", "runes", argv, argc, &normal_hints, &wm_hints, &class_hints); + + pid = getpid(); + XChangeProperty(w->dpy, w->w, w->atoms[RUNES_ATOM_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + + XChangeProperty(w->dpy, w->w, w->atoms[RUNES_ATOM_NET_WM_ICON_NAME], w->atoms[RUNES_ATOM_UTF8_STRING], 8, PropModeReplace, (unsigned char *)"runes", 5); + XChangeProperty(w->dpy, w->w, w->atoms[RUNES_ATOM_NET_WM_NAME], w->atoms[RUNES_ATOM_UTF8_STRING], 8, PropModeReplace, (unsigned char *)"runes", 5); +} + +RunesWindow *runes_window_create(int argc, char *argv[]) { RunesWindow *w; unsigned long white; @@ -53,8 +86,7 @@ RunesWindow *runes_window_create() exit(1); } - XInternAtoms(w->dpy, atom_names, RUNES_NUM_ATOMS, False, w->atoms); - XSetWMProtocols(w->dpy, w->w, w->atoms, RUNES_NUM_ATOMS); + runes_init_wm_properties(w, argc, argv); return w; } @@ -6,6 +6,11 @@ enum runes_atoms { RUNES_ATOM_WM_DELETE_WINDOW, RUNES_ATOM_NET_WM_PING, + RUNES_NUM_PROTOCOL_ATOMS, + RUNES_ATOM_NET_WM_PID = 2, + RUNES_ATOM_NET_WM_ICON_NAME, + RUNES_ATOM_NET_WM_NAME, + RUNES_ATOM_UTF8_STRING, RUNES_NUM_ATOMS }; @@ -23,7 +28,7 @@ struct xlib_loop_data { XEvent e; }; -RunesWindow *runes_window_create(); +RunesWindow *runes_window_create(int argc, char *argv[]); cairo_surface_t *runes_surface_create(RunesTerm *t); void runes_loop_init(RunesTerm *t, uv_loop_t *loop); void runes_window_destroy(RunesWindow *w); |