]>
Dogcows Code - chaz/openbox/blob - tests/focusout.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 focusout.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
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.
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.
16 See the COPYING file for a copy of the GNU General Public License.
22 #include <X11/Xutil.h>
28 Atom _net_fs
, _net_state
;
30 int x
=50,y
=50,h
=100,w
=400;
33 display
= XOpenDisplay(NULL
);
35 if (display
== NULL
) {
36 fprintf(stderr
, "couldn't connect to X server :0\n");
40 win
= XCreateWindow(display
, RootWindow(display
, 0),
41 x
, y
, w
, h
, 10, CopyFromParent
, CopyFromParent
,
42 CopyFromParent
, 0, NULL
);
43 child
= XCreateWindow(display
, win
,
44 10, 10, w
-20, h
-20, 0, CopyFromParent
, CopyFromParent
,
45 CopyFromParent
, 0, NULL
);
47 XSetWindowBackground(display
,win
,WhitePixel(display
,0));
48 XSetWindowBackground(display
,child
,BlackPixel(display
,0));
50 XSelectInput(display
, win
,
51 FocusChangeMask
|EnterWindowMask
|LeaveWindowMask
);
52 XMapWindow(display
, win
);
53 XMapWindow(display
, child
);
56 const char *mode
, *detail
;
58 XNextEvent(display
, &report
);
60 switch (report
.type
) {
62 printf("button press\n");
63 printf("type : %d\n", report
.xbutton
.type
);
64 printf("serial : %d\n", report
.xbutton
.serial
);
65 printf("send_event : %d\n", report
.xbutton
.send_event
);
66 printf("display : 0x%x\n", report
.xbutton
.display
);
67 printf("window : 0x%x\n", report
.xbutton
.window
);
68 printf("root : 0x%x\n", report
.xbutton
.root
);
69 printf("subwindow : 0x%x\n", report
.xbutton
.subwindow
);
70 printf("time : %d\n", report
.xbutton
.time
);
71 printf("x, y : %d, %d\n", report
.xbutton
.x
,
73 printf("rootx, rooty: %d, %d\n", report
.xbutton
.x_root
,
74 report
.xbutton
.y_root
);
75 printf("state : 0x%x\n", report
.xbutton
.state
);
76 printf("button : %d\n", report
.xbutton
.button
);
77 printf("same_screen : %d\n", report
.xbutton
.same_screen
);
82 printf("type : %d\n", report
.xmotion
.type
);
83 printf("serial : %d\n", report
.xmotion
.serial
);
84 printf("send_event : %d\n", report
.xmotion
.send_event
);
85 printf("display : 0x%x\n", report
.xmotion
.display
);
86 printf("window : 0x%x\n", report
.xmotion
.window
);
87 printf("root : 0x%x\n", report
.xmotion
.root
);
88 printf("subwindow : 0x%x\n", report
.xmotion
.subwindow
);
89 printf("time : %d\n", report
.xmotion
.time
);
90 printf("x, y : %d, %d\n", report
.xmotion
.x
,
92 printf("rootx, rooty: %d, %d\n", report
.xmotion
.x_root
,
93 report
.xmotion
.y_root
);
94 printf("state : 0x%x\n", report
.xmotion
.state
);
95 printf("is_hint : %d\n", report
.xmotion
.is_hint
);
96 printf("same_screen : %d\n", report
.xmotion
.same_screen
);
98 if (XGrabPointer(display
, win
, False
, ButtonReleaseMask
,
99 GrabModeAsync
, GrabModeAsync
, None
, None
,
100 report
.xmotion
.time
) == GrabSuccess
)
101 printf("GrabSuccess\n");
103 printf("GrabFail\n");
106 XUngrabPointer(display
, report
.xbutton
.time
);
109 switch (report
.xfocus
.mode
) {
110 case NotifyNormal
: mode
= "NotifyNormal"; break;
111 case NotifyGrab
: mode
= "NotifyGrab"; break;
112 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
115 switch (report
.xfocus
.detail
) {
116 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
117 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
118 case NotifyInferior
: detail
= "NotifyInferior"; break;
119 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
120 case NotifyNonlinearVirtual
:
121 detail
= "NotifyNonlinearVirtual"; break;
122 case NotifyPointer
: detail
= "NotifyPointer"; break;
123 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
124 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
127 printf("type : %d\n", report
.xfocus
.type
);
128 printf("serial : %d\n", report
.xfocus
.serial
);
129 printf("send_event: %d\n", report
.xfocus
.send_event
);
130 printf("display : 0x%x\n", report
.xfocus
.display
);
131 printf("window : 0x%x\n", report
.xfocus
.window
);
132 printf("mode : %s\n", mode
);
133 printf("detail : %s\n", detail
);
137 switch (report
.xfocus
.mode
) {
138 case NotifyNormal
: mode
= "NotifyNormal"; break;
139 case NotifyGrab
: mode
= "NotifyGrab"; break;
140 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
143 switch (report
.xfocus
.detail
) {
144 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
145 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
146 case NotifyInferior
: detail
= "NotifyInferior"; break;
147 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
148 case NotifyNonlinearVirtual
:
149 detail
= "NotifyNonlinearVirtual"; break;
150 case NotifyPointer
: detail
= "NotifyPointer"; break;
151 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
152 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
154 printf("focusout\n");
155 printf("type : %d\n", report
.xfocus
.type
);
156 printf("serial : %d\n", report
.xfocus
.serial
);
157 printf("send_event: %d\n", report
.xfocus
.send_event
);
158 printf("display : 0x%x\n", report
.xfocus
.display
);
159 printf("window : 0x%x\n", report
.xfocus
.window
);
160 printf("mode : %s\n", mode
);
161 printf("detail : %s\n", detail
);
165 switch (report
.xcrossing
.mode
) {
166 case NotifyNormal
: mode
= "NotifyNormal"; break;
167 case NotifyGrab
: mode
= "NotifyGrab"; break;
168 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
171 switch (report
.xcrossing
.detail
) {
172 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
173 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
174 case NotifyInferior
: detail
= "NotifyInferior"; break;
175 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
176 case NotifyNonlinearVirtual
:
177 detail
= "NotifyNonlinearVirtual"; break;
178 case NotifyPointer
: detail
= "NotifyPointer"; break;
179 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
180 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
182 printf("enternotify\n");
183 printf("type : %d\n", report
.xcrossing
.type
);
184 printf("serial : %d\n", report
.xcrossing
.serial
);
185 printf("send_event: %d\n", report
.xcrossing
.send_event
);
186 printf("display : 0x%x\n", report
.xcrossing
.display
);
187 printf("window : 0x%x\n", report
.xcrossing
.window
);
188 printf("mode : %s\n", mode
);
189 printf("detail : %s\n", detail
);
193 switch (report
.xcrossing
.mode
) {
194 case NotifyNormal
: mode
= "NotifyNormal"; break;
195 case NotifyGrab
: mode
= "NotifyGrab"; break;
196 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
199 switch (report
.xcrossing
.detail
) {
200 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
201 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
202 case NotifyInferior
: detail
= "NotifyInferior"; break;
203 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
204 case NotifyNonlinearVirtual
:
205 detail
= "NotifyNonlinearVirtual"; break;
206 case NotifyPointer
: detail
= "NotifyPointer"; break;
207 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
208 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
210 printf("leavenotify\n");
211 printf("type : %d\n", report
.xcrossing
.type
);
212 printf("serial : %d\n", report
.xcrossing
.serial
);
213 printf("send_event: %d\n", report
.xcrossing
.send_event
);
214 printf("display : 0x%x\n", report
.xcrossing
.display
);
215 printf("window : 0x%x\n", report
.xcrossing
.window
);
216 printf("mode : %s\n", mode
);
217 printf("detail : %s\n", detail
);
This page took 0.044512 seconds and 4 git commands to generate.