12 #include "killwindow.h"
15 #include <X11/XKBlib.h>
16 #include <X11/keysym.h>
17 #include <X11/keysymdef.h>
18 #include <X11/cursorfont.h>
20 namespace KWinInternal
23 KillWindow::KillWindow( Workspace* ws )
28 KillWindow::~KillWindow()
32 void KillWindow::start()
34 static Cursor kill_cursor = 0;
36 kill_cursor = XCreateFontCursor(tqt_xdisplay(), XC_pirate);
38 if (XGrabPointer(tqt_xdisplay(), tqt_xrootwin(), False,
39 ButtonPressMask | ButtonReleaseMask |
41 EnterWindowMask | LeaveWindowMask,
42 GrabModeAsync, GrabModeAsync, None,
43 kill_cursor, CurrentTime) == GrabSuccess)
45 XGrabKeyboard(tqt_xdisplay(), tqt_xrootwin(), False,
46 GrabModeAsync, GrabModeAsync, CurrentTime);
49 int return_pressed = 0;
50 int escape_pressed = 0;
51 int button_released = 0;
55 while (!return_pressed && !escape_pressed && !button_released)
57 XMaskEvent(tqt_xdisplay(), KeyPressMask | ButtonPressMask |
58 ButtonReleaseMask | PointerMotionMask, &ev);
60 if (ev.type == KeyPress)
62 int kc = XkbKeycodeToKeysym(tqt_xdisplay(), ev.xkey.keycode, 0, 0);
65 return_pressed = (kc == XK_Return) || (kc == XK_space);
66 escape_pressed = (kc == XK_Escape);
67 if (kc == XK_Left) mx = -10;
68 if (kc == XK_Right) mx = 10;
69 if (kc == XK_Up) my = -10;
70 if (kc == XK_Down) my = 10;
71 if (ev.xkey.state & ControlMask)
76 TQCursor::setPos(TQCursor::pos()+TQPoint(mx, my));
79 if (ev.type == ButtonRelease)
81 button_released = (ev.xbutton.button == Button1);
82 if ( ev.xbutton.button == Button3 )
84 escape_pressed = TRUE;
87 if( ev.xbutton.button == Button1 || ev.xbutton.button == Button2 )
88 workspace->killWindowId(ev.xbutton.subwindow);
95 int dummy1, dummy2, dummy3, dummy4;
97 if( XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
98 &dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) ==
true
100 workspace->killWindowId( child );
105 XUngrabKeyboard(tqt_xdisplay(), CurrentTime);
106 XUngrabPointer(tqt_xdisplay(), CurrentTime);