]>
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
, FocusChangeMask
);
51 XMapWindow(display
, win
);
52 XMapWindow(display
, child
);
55 const char *mode
, *detail
;
57 XNextEvent(display
, &report
);
59 switch (report
.type
) {
61 printf("button press\n");
62 printf("type : %d\n", report
.xbutton
.type
);
63 printf("serial : %d\n", report
.xbutton
.serial
);
64 printf("send_event : %d\n", report
.xbutton
.send_event
);
65 printf("display : 0x%x\n", report
.xbutton
.display
);
66 printf("window : 0x%x\n", report
.xbutton
.window
);
67 printf("root : 0x%x\n", report
.xbutton
.root
);
68 printf("subwindow : 0x%x\n", report
.xbutton
.subwindow
);
69 printf("time : %d\n", report
.xbutton
.time
);
70 printf("x, y : %d, %d\n", report
.xbutton
.x
,
72 printf("rootx, rooty: %d, %d\n", report
.xbutton
.x_root
,
73 report
.xbutton
.y_root
);
74 printf("state : 0x%x\n", report
.xbutton
.state
);
75 printf("button : %d\n", report
.xbutton
.button
);
76 printf("same_screen : %d\n", report
.xbutton
.same_screen
);
81 printf("type : %d\n", report
.xmotion
.type
);
82 printf("serial : %d\n", report
.xmotion
.serial
);
83 printf("send_event : %d\n", report
.xmotion
.send_event
);
84 printf("display : 0x%x\n", report
.xmotion
.display
);
85 printf("window : 0x%x\n", report
.xmotion
.window
);
86 printf("root : 0x%x\n", report
.xmotion
.root
);
87 printf("subwindow : 0x%x\n", report
.xmotion
.subwindow
);
88 printf("time : %d\n", report
.xmotion
.time
);
89 printf("x, y : %d, %d\n", report
.xmotion
.x
,
91 printf("rootx, rooty: %d, %d\n", report
.xmotion
.x_root
,
92 report
.xmotion
.y_root
);
93 printf("state : 0x%x\n", report
.xmotion
.state
);
94 printf("is_hint : %d\n", report
.xmotion
.is_hint
);
95 printf("same_screen : %d\n", report
.xmotion
.same_screen
);
97 if (XGrabPointer(display
, win
, False
, ButtonReleaseMask
,
98 GrabModeAsync
, GrabModeAsync
, None
, None
,
99 report
.xmotion
.time
) == GrabSuccess
)
100 printf("GrabSuccess\n");
102 printf("GrabFail\n");
105 XUngrabPointer(display
, report
.xbutton
.time
);
108 switch (report
.xfocus
.mode
) {
109 case NotifyNormal
: mode
= "NotifyNormal"; break;
110 case NotifyGrab
: mode
= "NotifyGrab"; break;
111 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
114 switch (report
.xfocus
.detail
) {
115 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
116 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
117 case NotifyInferior
: detail
= "NotifyInferior"; break;
118 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
119 case NotifyNonlinearVirtual
: detail
= "NotifyNonlinearVirtual"; break;
120 case NotifyPointer
: detail
= "NotifyPointer"; break;
121 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
122 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
125 printf("type : %d\n", report
.xfocus
.type
);
126 printf("serial : %d\n", report
.xfocus
.serial
);
127 printf("send_event: %d\n", report
.xfocus
.send_event
);
128 printf("display : 0x%x\n", report
.xfocus
.display
);
129 printf("window : 0x%x\n", report
.xfocus
.window
);
130 printf("mode : %s\n", mode
);
131 printf("detail : %s\n", detail
);
135 switch (report
.xfocus
.mode
) {
136 case NotifyNormal
: mode
= "NotifyNormal"; break;
137 case NotifyGrab
: mode
= "NotifyGrab"; break;
138 case NotifyUngrab
: mode
= "NotifyUngrab"; break;
141 switch (report
.xfocus
.detail
) {
142 case NotifyAncestor
: detail
= "NotifyAncestor"; break;
143 case NotifyVirtual
: detail
= "NotifyVirtual"; break;
144 case NotifyInferior
: detail
= "NotifyInferior"; break;
145 case NotifyNonlinear
: detail
= "NotifyNonlinear"; break;
146 case NotifyNonlinearVirtual
: detail
= "NotifyNonlinearVirtual"; break;
147 case NotifyPointer
: detail
= "NotifyPointer"; break;
148 case NotifyPointerRoot
: detail
= "NotifyPointerRoot"; break;
149 case NotifyDetailNone
: detail
= "NotifyDetailNone"; break;
151 printf("focusout\n");
152 printf("type : %d\n", report
.xfocus
.type
);
153 printf("serial : %d\n", report
.xfocus
.serial
);
154 printf("send_event: %d\n", report
.xfocus
.send_event
);
155 printf("display : 0x%x\n", report
.xfocus
.display
);
156 printf("window : 0x%x\n", report
.xfocus
.window
);
157 printf("mode : %s\n", mode
);
158 printf("detail : %s\n", detail
);
This page took 0.046474 seconds and 4 git commands to generate.