]> icculus.org git repositories - dana/openbox.git/blob - tests/confignotifymax.c
fix XSYNCronization of resizes (especially with two monitors).
[dana/openbox.git] / tests / confignotifymax.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    confignotify.c for the Openbox window manager
4    Copyright (c) 2003-2007   Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <X11/Xlib.h>
22 #include <X11/Xatom.h>
23
24 int main () {
25     Display   *display;
26     Window     win;
27     XEvent     report;
28     XEvent     msg;
29     Atom       _net_max[2],_net_state;
30     int        x=10,y=10,h=100,w=100;
31
32     display = XOpenDisplay(NULL);
33
34     if (display == NULL) {
35         fprintf(stderr, "couldn't connect to X server :0\n");
36         return 0;
37     }
38
39     _net_state = XInternAtom(display, "_NET_WM_STATE", False);
40     _net_max[0] = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
41     _net_max[1] = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
42
43     win = XCreateWindow(display, RootWindow(display, 0),
44                         x, y, w, h, 0, CopyFromParent, CopyFromParent,
45                         CopyFromParent, 0, NULL);
46
47     XSetWindowBackground(display,win,WhitePixel(display,0));
48     XChangeProperty(display, win, _net_state, XA_ATOM, 32,
49                     PropModeReplace, (unsigned char*)&_net_max, 2);
50
51     XSelectInput(display, win, (ExposureMask | StructureNotifyMask |
52                                 GravityNotify));
53
54     XMapWindow(display, win);
55     XFlush(display);
56
57     //sleep(1);
58     //XResizeWindow(display, win, w+5, h+5);
59     //XMoveWindow(display, win, x, y);
60
61     while (1) {
62         XNextEvent(display, &report);
63
64         switch (report.type) {
65         case MapNotify:
66             printf("map notify\n");
67             break;
68         case Expose:
69             printf("exposed\n");
70             break;
71         case GravityNotify:
72             printf("gravity notify event 0x%x window 0x%x x %d y %d\n",
73                    report.xgravity.event, report.xgravity.window,
74                    report.xgravity.x, report.xgravity.y);
75             break;
76         case ConfigureNotify: {
77             int se = report.xconfigure.send_event;
78             int event = report.xconfigure.event;
79             int window = report.xconfigure.window;
80             int x = report.xconfigure.x;
81             int y = report.xconfigure.y;
82             int w = report.xconfigure.width;
83             int h = report.xconfigure.height;
84             int bw = report.xconfigure.border_width;
85             int above = report.xconfigure.above;
86             int or = report.xconfigure.override_redirect;
87             printf("confignotify send %d ev 0x%x win 0x%x %i,%i-%ix%i bw %i\n"
88                    "             above 0x%x ovrd %d\n",
89                    se,event,window,x,y,w,h,bw,above,or);
90             break;
91         }
92         }
93
94     }
95
96     return 1;
97 }