15
#include <sys/resource.h>
20
YXApplication *xapp = 0;
22
YDesktop *desktop = 0;
23
XContext windowContext;
25
YCursor YXApplication::leftPointer;
26
YCursor YXApplication::rightPointer;
27
YCursor YXApplication::movePointer;
29
Atom _XA_WM_PROTOCOLS;
30
Atom _XA_WM_TAKE_FOCUS;
31
Atom _XA_WM_DELETE_WINDOW;
33
Atom _XA_WM_CHANGE_STATE;
34
Atom _XATOM_MWM_HINTS;
35
//Atom _XA_MOTIF_WM_INFO;!!!
36
Atom _XA_WM_COLORMAP_WINDOWS;
37
Atom _XA_WM_CLIENT_LEADER;
38
Atom _XA_WM_WINDOW_ROLE;
40
Atom _XA_SM_CLIENT_ID;
41
Atom _XA_ICEWM_ACTION;
46
Atom _XA_WIN_PROTOCOLS;
47
Atom _XA_WIN_WORKSPACE;
48
Atom _XA_WIN_WORKSPACE_COUNT;
49
Atom _XA_WIN_WORKSPACE_NAMES;
50
Atom _XA_WIN_WORKAREA;
58
Atom _XA_WIN_SUPPORTING_WM_CHECK;
59
Atom _XA_WIN_CLIENT_LIST;
60
Atom _XA_WIN_DESKTOP_BUTTON_PROXY;
62
Atom _XA_WIN_AREA_COUNT;
64
Atom _XA_NET_SUPPORTED;
65
Atom _XA_NET_SUPPORTING_WM_CHECK;
66
Atom _XA_NET_CLIENT_LIST;
67
Atom _XA_NET_CLIENT_LIST_STACKING;
68
Atom _XA_NET_NUMBER_OF_DESKTOPS;
69
Atom _XA_NET_CURRENT_DESKTOP;
70
//Atom _XA_NET_WORKAREA;
71
Atom _XA_NET_WM_MOVERESIZE;
73
Atom _XA_NET_WM_STRUT;
74
Atom _XA_NET_WM_DESKTOP;
75
Atom _XA_NET_CLOSE_WINDOW;
76
Atom _XA_NET_ACTIVE_WINDOW;
77
Atom _XA_NET_WM_STATE;
79
Atom _XA_NET_WM_STATE_SHADED;
80
Atom _XA_NET_WM_STATE_MAXIMIZED_VERT;
81
Atom _XA_NET_WM_STATE_MAXIMIZED_HORZ;
82
Atom _XA_NET_WM_STATE_SKIP_TASKBAR;
83
Atom _XA_NET_WM_STATE_HIDDEN;
84
Atom _XA_NET_WM_STATE_FULLSCREEN;
85
Atom _XA_NET_WM_STATE_ABOVE;
86
Atom _XA_NET_WM_STATE_BELOW;
87
Atom _XA_NET_WM_STATE_MODAL;
88
Atom _XA_NET_WM_WINDOW_TYPE;
89
Atom _XA_NET_WM_WINDOW_TYPE_DOCK;
90
Atom _XA_NET_WM_WINDOW_TYPE_DESKTOP;
91
Atom _XA_NET_WM_WINDOW_TYPE_SPLASH;
97
Atom _XA_NET_WM_USER_TIME;
98
Atom _XA_NET_WM_STATE_DEMANDS_ATTENTION;
100
Atom _XA_KWM_WIN_ICON;
101
Atom _XA_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR = 0;
106
Atom XA_XdndPosition;
109
Atom XA_XdndFinished;
111
YColor *YColor::black(NULL);
112
YColor *YColor::white(NULL);
114
ref<YPixmap> buttonIPixmap;
115
ref<YPixmap> buttonAPixmap;
117
ref<YPixmap> logoutPixmap;
118
ref<YPixmap> switchbackPixmap;
119
ref<YPixmap> listbackPixmap;
120
ref<YPixmap> dialogbackPixmap;
122
ref<YPixmap> menubackPixmap;
123
ref<YPixmap> menusepPixmap;
124
ref<YPixmap> menuselPixmap;
126
#ifdef CONFIG_GRADIENTS
127
ref<YImage> buttonIPixbuf;
128
ref<YImage> buttonAPixbuf;
130
ref<YImage> logoutPixbuf;
131
ref<YImage> switchbackPixbuf;
132
ref<YImage> listbackPixbuf;
133
ref<YImage> dialogbackPixbuf;
135
ref<YImage> menubackPixbuf;
136
ref<YImage> menuselPixbuf;
137
ref<YImage> menusepPixbuf;
141
ref<YPixmap> closePixmap[3];
142
ref<YPixmap> minimizePixmap[3];
143
ref<YPixmap> maximizePixmap[3];
144
ref<YPixmap> restorePixmap[3];
145
ref<YPixmap> hidePixmap[3];
146
ref<YPixmap> rollupPixmap[3];
147
ref<YPixmap> rolldownPixmap[3];
148
ref<YPixmap> depthPixmap[3];
152
int shapeEventBase, shapeErrorBase;
157
bool xrandr12 = false;
158
int xrandrEventBase, xrandrErrorBase;
165
class YClipboard: public YWindow {
167
YClipboard(): YWindow() {
178
void setData(const char *data, int len) {
182
fData = new char[len];
184
memcpy(fData, data, len);
186
clearSelection(false);
188
acquireSelection(false);
190
void handleSelectionClear(const XSelectionClearEvent &clear) {
191
if (clear.selection == _XA_CLIPBOARD) {
198
void handleSelectionRequest(const XSelectionRequestEvent &request) {
199
if (request.selection == _XA_CLIPBOARD) {
200
XSelectionEvent notify;
202
notify.type = SelectionNotify;
203
notify.requestor = request.requestor;
204
notify.selection = request.selection;
205
notify.target = request.target;
206
notify.time = request.time;
207
notify.property = request.property;
209
if (request.selection == _XA_CLIPBOARD &&
210
request.target == XA_STRING &&
213
XChangeProperty(xapp->display(),
218
(unsigned char *)(fData ? fData : ""),
220
} else if (request.selection == _XA_CLIPBOARD &&
221
request.target == _XA_TARGETS &&
224
Atom type = XA_STRING;
226
XChangeProperty(xapp->display(),
231
(unsigned char *)&type, 1);
233
notify.property = None;
236
XSendEvent(xapp->display(), notify.requestor, False, 0L, (XEvent *)¬ify);
246
static void initAtoms() {
251
{ &_XA_WM_PROTOCOLS, "WM_PROTOCOLS" },
252
{ &_XA_WM_TAKE_FOCUS, "WM_TAKE_FOCUS" },
253
{ &_XA_WM_DELETE_WINDOW, "WM_DELETE_WINDOW" },
254
{ &_XA_WM_STATE, "WM_STATE" },
255
{ &_XA_WM_CHANGE_STATE, "WM_CHANGE_STATE" },
256
{ &_XA_WM_COLORMAP_WINDOWS, "WM_COLORMAP_WINDOWS" },
257
{ &_XA_WM_CLIENT_LEADER, "WM_CLIENT_LEADER" },
258
{ &_XA_WINDOW_ROLE, "WINDOW_ROLE" },
259
{ &_XA_WM_WINDOW_ROLE, "WM_WINDOW_ROLE" },
260
{ &_XA_SM_CLIENT_ID, "SM_CLIENT_ID" },
261
{ &_XA_ICEWM_ACTION, "_ICEWM_ACTION" },
262
{ &_XATOM_MWM_HINTS, _XA_MOTIF_WM_HINTS },
263
{ &_XA_KWM_WIN_ICON, "KWM_WIN_ICON" },
264
{ &_XA_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR" },
265
{ &_XA_WIN_WORKSPACE, XA_WIN_WORKSPACE },
266
{ &_XA_WIN_WORKSPACE_COUNT, XA_WIN_WORKSPACE_COUNT },
267
{ &_XA_WIN_WORKSPACE_NAMES, XA_WIN_WORKSPACE_NAMES },
268
{ &_XA_WIN_WORKAREA, XA_WIN_WORKAREA },
269
{ &_XA_WIN_ICONS, XA_WIN_ICONS },
270
{ &_XA_WIN_LAYER, XA_WIN_LAYER },
272
{ &_XA_WIN_TRAY, XA_WIN_TRAY },
274
{ &_XA_WIN_STATE, XA_WIN_STATE },
275
{ &_XA_WIN_HINTS, XA_WIN_HINTS },
276
{ &_XA_WIN_PROTOCOLS, XA_WIN_PROTOCOLS },
277
{ &_XA_WIN_SUPPORTING_WM_CHECK, XA_WIN_SUPPORTING_WM_CHECK },
278
{ &_XA_WIN_CLIENT_LIST, XA_WIN_CLIENT_LIST },
279
{ &_XA_WIN_DESKTOP_BUTTON_PROXY, XA_WIN_DESKTOP_BUTTON_PROXY },
280
{ &_XA_WIN_AREA, XA_WIN_AREA },
281
{ &_XA_WIN_AREA_COUNT, XA_WIN_AREA_COUNT },
283
{ &_XA_NET_SUPPORTED, "_NET_SUPPORTED" },
284
{ &_XA_NET_SUPPORTING_WM_CHECK, "_NET_SUPPORTING_WM_CHECK" },
285
{ &_XA_NET_CLIENT_LIST, "_NET_CLIENT_LIST" },
286
{ &_XA_NET_CLIENT_LIST_STACKING, "_NET_CLIENT_LIST_STACKING" },
287
{ &_XA_NET_NUMBER_OF_DESKTOPS, "_NET_NUMBER_OF_DESKTOPS" },
288
{ &_XA_NET_CURRENT_DESKTOP, "_NET_CURRENT_DESKTOP" },
289
// { &_XA_NET_WORKAREA, "_NET_WORKAREA" },
290
{ &_XA_NET_WM_MOVERESIZE, "_NET_WM_MOVERESIZE" },
292
{ &_XA_NET_WM_STRUT, "_NET_WM_STRUT" },
293
{ &_XA_NET_WM_DESKTOP, "_NET_WM_DESKTOP" },
294
{ &_XA_NET_CLOSE_WINDOW, "_NET_CLOSE_WINDOW" },
295
{ &_XA_NET_ACTIVE_WINDOW, "_NET_ACTIVE_WINDOW" },
296
{ &_XA_NET_WM_STATE, "_NET_WM_STATE" },
298
{ &_XA_NET_WM_STATE_SHADED, "_NET_WM_STATE_SHADED" },
299
{ &_XA_NET_WM_STATE_MAXIMIZED_VERT, "_NET_WM_STATE_MAXIMIZED_VERT" },
300
{ &_XA_NET_WM_STATE_MAXIMIZED_HORZ, "_NET_WM_STATE_MAXIMIZED_HORZ" },
301
{ &_XA_NET_WM_STATE_SKIP_TASKBAR, "_NET_WM_STATE_SKIP_TASKBAR" },
302
{ &_XA_NET_WM_STATE_HIDDEN, "_NET_WM_STATE_HIDDEN" },
303
{ &_XA_NET_WM_STATE_FULLSCREEN, "_NET_WM_STATE_FULLSCREEN" },
304
{ &_XA_NET_WM_STATE_ABOVE, "_NET_WM_STATE_ABOVE" },
305
{ &_XA_NET_WM_STATE_BELOW, "_NET_WM_STATE_BELOW" },
306
{ &_XA_NET_WM_STATE_MODAL, "_NET_WM_STATE_MODAL" },
307
{ &_XA_NET_WM_WINDOW_TYPE, "_NET_WM_WINDOW_TYPE" },
308
{ &_XA_NET_WM_WINDOW_TYPE_DOCK, "_NET_WM_WINDOW_TYPE_DOCK" },
309
{ &_XA_NET_WM_WINDOW_TYPE_DESKTOP, "_NET_WM_WINDOW_TYPE_DESKTOP" },
310
{ &_XA_NET_WM_WINDOW_TYPE_SPLASH, "_NET_WM_WINDOW_TYPE_SPLASH" },
312
{ &_XA_NET_WM_NAME, "_NET_WM_NAME" },
313
{ &_XA_NET_WM_ICON, "_NET_WM_ICON" },
314
{ &_XA_NET_WM_PID, "_NET_WM_PID" },
315
{ &_XA_NET_WM_USER_TIME, "_NET_WM_USER_TIME" },
316
{ &_XA_NET_WM_STATE_DEMANDS_ATTENTION, "_NET_WM_STATE_DEMANDS_ATTENTION" },
318
{ &_XA_CLIPBOARD, "CLIPBOARD" },
319
{ &_XA_XEMBED_INFO, "_XEMBED_INFO" },
320
{ &_XA_TARGETS, "TARGETS" },
321
{ &XA_XdndAware, "XdndAware" },
322
{ &XA_XdndEnter, "XdndEnter" },
323
{ &XA_XdndLeave, "XdndLeave" },
324
{ &XA_XdndPosition, "XdndPosition" },
325
{ &XA_XdndStatus, "XdndStatus" },
326
{ &XA_XdndDrop, "XdndDrop" },
327
{ &XA_XdndFinished, "XdndFinished" }
331
#ifdef HAVE_XINTERNATOMS
332
const char *names[ACOUNT(atom_info)];
333
Atom atoms[ACOUNT(atom_info)];
335
for (i = 0; i < ACOUNT(atom_info); i++)
336
names[i] = atom_info[i].name;
338
XInternAtoms(xapp->display(), (char **)names, ACOUNT(atom_info), False, atoms);
340
for (i = 0; i < ACOUNT(atom_info); i++)
341
*(atom_info[i].atom) = atoms[i];
343
for (i = 0; i < ACOUNT(atom_info); i++)
344
*(atom_info[i].atom) = XInternAtom(xapp->display(),
345
atom_info[i].name, False);
349
static void initPointers() {
350
YXApplication::leftPointer.load("left.xpm", XC_left_ptr);
351
YXApplication::rightPointer.load("right.xpm", XC_right_ptr);
352
YXApplication::movePointer.load("move.xpm", XC_fleur);
355
static void initColors() {
356
YColor::black = new YColor("rgb:00/00/00");
357
YColor::white = new YColor("rgb:FF/FF/FF");
360
void YXApplication::initModifiers() {
361
XModifierKeymap *xmk = XGetModifierMapping(xapp->display());
362
AltMask = MetaMask = WinMask = SuperMask = HyperMask =
363
NumLockMask = ScrollLockMask = ModeSwitchMask = 0;
366
KeyCode *c = xmk->modifiermap;
368
for (int m = 0; m < 8; m++)
369
for (int k = 0; k < xmk->max_keypermod; k++, c++) {
372
KeySym kc = XKeycodeToKeysym(xapp->display(), *c, 0);
374
kc = XKeycodeToKeysym(xapp->display(), *c, 1);
375
if (kc == XK_Num_Lock && NumLockMask == 0)
376
NumLockMask = (1 << m);
377
if (kc == XK_Scroll_Lock && ScrollLockMask == 0)
378
ScrollLockMask = (1 << m);
379
if ((kc == XK_Alt_L || kc == XK_Alt_R) && AltMask == 0)
381
if ((kc == XK_Meta_L || kc == XK_Meta_R) && MetaMask == 0)
383
if ((kc == XK_Super_L || kc == XK_Super_R) && SuperMask == 0)
384
SuperMask = (1 << m);
385
if ((kc == XK_Hyper_L || kc == XK_Hyper_R) && HyperMask == 0)
386
HyperMask = (1 << m);
387
if ((kc == XK_Mode_switch || kc == XK_ISO_Level3_Shift) && ModeSwitchMask == 0)
388
ModeSwitchMask = (1 << m);
391
XFreeModifiermap(xmk);
393
if (MetaMask == AltMask)
396
MSG(("alt:%d meta:%d super:%d hyper:%d mode:%d num:%d scroll:%d",
397
AltMask, MetaMask, SuperMask, HyperMask, ModeSwitchMask,
398
NumLockMask, ScrollLockMask));
400
// some hacks for "broken" modifier configurations
401
if (HyperMask == SuperMask)
404
// this basically does what <0.9.13 versions did
405
if (AltMask != 0 && MetaMask == Mod1Mask) {
410
if (AltMask == 0 && MetaMask != 0) {
411
if (MetaMask != Mod1Mask) {
423
if (ModeSwitchMask & (AltMask | MetaMask | SuperMask | HyperMask))
426
PRECONDITION(xapp->AltMask != 0);
427
PRECONDITION(xapp->AltMask != ShiftMask);
428
PRECONDITION(xapp->AltMask != ControlMask);
429
PRECONDITION(xapp->AltMask != xapp->MetaMask);
447
ButtonKeyMask = KeyMask | ButtonMask;
450
KeySym wl = XKeycodeToKeysym(app->display(), 115, 0);
451
KeySym wr = XKeycodeToKeysym(app->display(), 116, 0);
453
if (wl == XK_Super_L) {
454
} else if (wl == XK_Meta_L) {
457
// this will do for now, but we should actualy check the keycodes
460
if (SuperMask != 0) {
466
MSG(("alt:%d meta:%d super:%d hyper:%d win:%d mode:%d num:%d scroll:%d",
467
AltMask, MetaMask, SuperMask, HyperMask, WinMask, ModeSwitchMask,
468
NumLockMask, ScrollLockMask));
472
void YXApplication::dispatchEvent(YWindow *win, XEvent &xev) {
473
if (xev.type == KeyPress || xev.type == KeyRelease) {
476
if (!(fGrabWindow != 0 && !fGrabTree)) {
480
if (w->getFocusWindow() != 0)
481
w = w->getFocusWindow();
484
while (w && (w->handleKey(xev.xkey) == false)) {
485
if (fGrabTree && w == fXGrabWindow)
492
if (xev.type == MotionNotify) {
493
if (xev.xmotion.window != win->handle()) {
494
if (XTranslateCoordinates(xapp->display(),
495
xev.xany.window, win->handle(),
496
xev.xmotion.x, xev.xmotion.y,
497
&xev.xmotion.x, &xev.xmotion.y, &child) == True)
498
xev.xmotion.window = win->handle();
502
} else if (xev.type == ButtonPress || xev.type == ButtonRelease ||
503
xev.type == EnterNotify || xev.type == LeaveNotify)
505
if (xev.xbutton.window != win->handle()) {
506
if (XTranslateCoordinates(xapp->display(),
507
xev.xany.window, win->handle(),
508
xev.xbutton.x, xev.xbutton.y,
509
&xev.xbutton.x, &xev.xbutton.y, &child) == True)
510
xev.xbutton.window = win->handle();
514
} else if (xev.type == KeyPress || xev.type == KeyRelease) {
515
if (xev.xkey.window != win->handle()) {
516
if (XTranslateCoordinates(xapp->display(),
517
xev.xany.window, win->handle(),
518
xev.xkey.x, xev.xkey.y,
519
&xev.xkey.x, &xev.xkey.y, &child) == True)
520
xev.xkey.window = win->handle();
525
win->handleEvent(xev);
529
void YXApplication::handleGrabEvent(YWindow *winx, XEvent &xev) {
535
PRECONDITION(win.ptr != 0);
537
if (xev.xbutton.subwindow != None) {
538
if (XFindContext(display(),
539
xev.xbutton.subwindow,
543
if (xev.type == EnterNotify || xev.type == LeaveNotify)
546
win.ptr = fGrabWindow;
549
if (XFindContext(display(),
554
if (xev.type == EnterNotify || xev.type == LeaveNotify)
557
win.ptr = fGrabWindow;
563
YWindow *p = win.ptr;
565
if (p == fXGrabWindow)
570
if (xev.type == EnterNotify || xev.type == LeaveNotify)
573
win.ptr = fGrabWindow;
576
if (xev.type == EnterNotify || xev.type == LeaveNotify)
577
if (win.ptr != fGrabWindow)
579
if (fGrabWindow != fXGrabWindow)
580
win.ptr = fGrabWindow;
582
dispatchEvent(win.ptr, xev);
585
void YXApplication::replayEvent() {
588
XAllowEvents(xapp->display(), ReplayPointer, CurrentTime);
592
void YXApplication::captureGrabEvents(YWindow *win) {
593
if (fGrabWindow == fXGrabWindow && fGrabTree) {
598
void YXApplication::releaseGrabEvents(YWindow *win) {
599
if (win == fGrabWindow && fGrabTree) {
600
fGrabWindow = fXGrabWindow;
604
int YXApplication::grabEvents(YWindow *win, Cursor ptr, unsigned int eventMask, int grabMouse, int grabKeyboard, int grabTree) {
607
if (fGrabWindow != 0)
613
fGrabTree = grabTree;
616
rc = XGrabPointer(display(), win->handle(),
617
grabTree ? True : False,
619
GrabModeSync, GrabModeAsync,
620
None, ptr, CurrentTime);
623
MSG(("grab status = %d\x7", rc));
629
XChangeActivePointerGrab(display(),
635
rc = XGrabKeyboard(display(), win->handle(),
637
grabTree ? True : False,
638
GrabModeSync, GrabModeAsync, CurrentTime);
639
if (rc != Success && grabMouse) {
640
MSG(("grab status = %d\x7", rc));
641
XUngrabPointer(display(), CurrentTime);
645
XAllowEvents(xapp->display(), SyncPointer, CurrentTime);
647
desktop->resetColormapFocus(false);
654
int YXApplication::releaseEvents() {
655
if (fGrabWindow == 0)
661
XUngrabPointer(display(), CurrentTime);
664
XUngrabKeyboard(display(), CurrentTime);
665
desktop->resetColormapFocus(true);
669
void YXApplication::afterWindowEvent(XEvent & /*xev*/) {
672
bool YXApplication::filterEvent(const XEvent &xev) {
673
if (xev.type == MappingNotify) {
674
msg("MappingNotify");
675
XMappingEvent xmapping = xev.xmapping;
676
XRefreshKeyboardMapping(&xmapping);
686
void YXApplication::saveEventTime(const XEvent &xev) {
690
lastEventTime = xev.xbutton.time;
694
lastEventTime = xev.xmotion.time;
699
lastEventTime = xev.xkey.time;
704
lastEventTime = xev.xcrossing.time;
708
lastEventTime = xev.xproperty.time;
712
lastEventTime = xev.xselectionclear.time;
715
case SelectionRequest:
716
lastEventTime = xev.xselectionrequest.time;
719
case SelectionNotify:
720
lastEventTime = xev.xselection.time;
725
Time YXApplication::getEventTime(const char */*debug*/) const {
726
return lastEventTime;
730
extern void logEvent(const XEvent &xev);
733
bool YXApplication::hasColormap() {
735
pattern.screen = DefaultScreen(display());
740
XVisualInfo *first_visual(XGetVisualInfo(display(), VisualScreenMask,
741
&pattern, &nVisuals));
742
XVisualInfo *visual = first_visual;
744
while(visual && nVisuals--) {
745
if (visual->c_class & 1)
757
void YXApplication::alert() {
758
XBell(display(), 100);
761
void YXApplication::setClipboardText(const ustring &data) {
763
fClip = new YClipboard();
767
fClip->setData(s.c_str(), s.c_str_len());
770
YXApplication::YXApplication(int *argc, char ***argv, const char *displayName):
771
YApplication(argc, argv)
774
lastEventTime = CurrentTime;
781
fReplayEvent = false;
783
bool runSynchronized(false);
785
for (char ** arg = *argv + 1; arg < *argv + *argc; ++arg) {
789
if ((value = GET_LONG_ARGUMENT("display")) != NULL)
791
else if (IS_LONG_SWITCH("sync"))
792
runSynchronized = true;
796
if (displayName == 0)
797
displayName = getenv("DISPLAY");
799
static char disp[256] = "DISPLAY=";
800
strcat(disp, displayName);
804
if (!(fDisplay = XOpenDisplay(displayName)))
805
die(1, _("Can't open display: %s. X must be running and $DISPLAY set."),
806
displayName ? displayName : _("<none>"));
809
XSynchronize(display(), True);
811
xfd.registerPoll(this, ConnectionNumber(display()));
813
windowContext = XUniqueContext();
815
new YDesktop(0, RootWindow(display(), DefaultScreen(display())));
816
extern void image_init();
825
shapesSupported = XShapeQueryExtension(display(),
826
&shapeEventBase, &shapeErrorBase);
829
xrandrSupported = XRRQueryExtension(display(),
830
&xrandrEventBase, &xrandrErrorBase);
834
XRRQueryVersion(display(), &major, &minor);
836
MSG(("XRRVersion: %d %d", major, minor));
837
if (major > 1 || (major == 1 && minor >= 2)) {
845
YXApplication::~YXApplication() {
846
xfd.unregisterPoll();
847
XCloseDisplay(display());
852
bool YXApplication::handleXEvents() {
853
if (XPending(display()) > 0) {
856
XNextEvent(display(), &xev);
860
//msg("%d", xev.type);
867
if (filterEvent(xev)) {
870
int ge = (xev.type == ButtonPress ||
871
xev.type == ButtonRelease ||
872
xev.type == MotionNotify ||
873
xev.type == KeyPress ||
874
xev.type == KeyRelease /*||
875
xev.type == EnterNotify ||
876
xev.type == LeaveNotify*/) ? 1 : 0;
878
fReplayEvent = false;
881
handleGrabEvent(fPopup, xev);
882
} else if (fGrabWindow && ge) {
883
handleGrabEvent(fGrabWindow, xev);
885
handleWindowEvent(xev.xany.window, xev);
888
if (xev.type == ButtonPress || xev.type == ButtonRelease || xev.type == MotionNotify)
891
XAllowEvents(xapp->display(), SyncPointer, CurrentTime);
902
bool YXApplication::handleIdle() {
903
return handleXEvents();
906
void YXApplication::handleWindowEvent(Window xwindow, XEvent &xev) {
913
if ((rc = XFindContext(display(),
916
&(window.xptr))) == 0)
918
if ((xev.type == KeyPress || xev.type == KeyRelease)
919
&& window.ptr->toplevel() != 0)
921
YWindow *w = window.ptr;
925
if (w->getFocusWindow() != 0)
926
w = w->getFocusWindow();
928
dispatchEvent(w, xev);
930
window.ptr->handleEvent(xev);
933
if (xev.type == MapRequest) {
934
// !!! java seems to do this ugliness
935
//YFrameWindow *f = getFrame(xev.xany.window);
936
msg("APP BUG? mapRequest for window %lX sent to destroyed frame %lX!",
937
xev.xmaprequest.parent,
938
xev.xmaprequest.window);
939
desktop->handleEvent(xev);
940
} else if (xev.type == ConfigureRequest) {
941
msg("APP BUG? configureRequest for window %lX sent to destroyed frame %lX!",
942
xev.xmaprequest.parent,
943
xev.xmaprequest.window);
944
desktop->handleEvent(xev);
945
} else if (xev.type != DestroyNotify) {
946
MSG(("unknown window 0x%lX event=%d", xev.xany.window, xev.type));
949
if (xev.type == KeyPress || xev.type == KeyRelease) ///!!!
950
afterWindowEvent(xev);
953
void YXApplication::flushXEvents() {
954
XSync(display(), False);
957
void YXPoll::notifyRead() {
958
owner()->handleXEvents();
961
void YXPoll::notifyWrite() { }
963
bool YXPoll::forRead() {
967
bool YXPoll::forWrite() { return false; }