summaryrefslogtreecommitdiff
path: root/test-name.c
blob: d084044d798952debee2da98fef2c60485a254bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* gcc test-name.c -o test-name.exe -lX11 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>

#define NAME_1 "Test 1: WM_NAME"
#define NAME_2 "Test 2: _NET_WM_NAME"

int main(int argc, char **argv)
{
    Display *d = XOpenDisplay(0);
    int s = DefaultScreen(d);

    Atom wm_name = XInternAtom(d, "WM_NAME", False);
    Atom net_wm_name = XInternAtom(d, "_NET_WM_NAME", False);
    Atom utf8 = XInternAtom(d, "UTF8_STRING", False);

    Window w;
    XEvent e;
    w = XCreateWindow(d, RootWindow(d, s), 0, 0, 200, 200, 0,
                      CopyFromParent, InputOutput, CopyFromParent, 0, 0);

    XMapWindow(d, w);
    XFlush(d);
    sleep(10);

    printf("Updating name WM_NAME\n");
    XStoreName(d, w, NAME_1);
    XFlush(d);
    sleep(10);

    printf("Updating name _NET_WM_NAME\n");
    XChangeProperty(d, w, net_wm_name, utf8, 8,
                    PropModeReplace, NAME_2, strlen(NAME_2));
    XFlush(d);
    sleep(10);

    while(1) XNextEvent(d, &e);
}