summaryrefslogtreecommitdiffstats
path: root/twin/killwindow.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-07 21:50:33 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-07 21:50:33 -0600
commit0b6057404f65218182ab27a9483a21065ef61fca (patch)
treeb8b06dfa2deb965bebfbe131a772124e3e693a96 /twin/killwindow.cpp
parent43d99cc2477266cb9072e179137f0e8485370b3d (diff)
downloadtdebase-0b6057404f65218182ab27a9483a21065ef61fca.tar.gz
tdebase-0b6057404f65218182ab27a9483a21065ef61fca.zip
Rename kwin to twin (Part 2 of 2)
Diffstat (limited to 'twin/killwindow.cpp')
-rw-r--r--twin/killwindow.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/twin/killwindow.cpp b/twin/killwindow.cpp
new file mode 100644
index 000000000..7dc6504f9
--- /dev/null
+++ b/twin/killwindow.cpp
@@ -0,0 +1,112 @@
+/*****************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
+Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
+
+You can Freely distribute this program under the GNU General Public
+License. See the file "COPYING" for the exact licensing terms.
+******************************************************************/
+
+//#ifndef QT_CLEAN_NAMESPACE
+//#define QT_CLEAN_NAMESPACE
+//#endif
+#include "killwindow.h"
+#include <tqcursor.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/keysymdef.h>
+#include <X11/cursorfont.h>
+
+namespace KWinInternal
+{
+
+KillWindow::KillWindow( Workspace* ws )
+ : workspace( ws )
+ {
+ }
+
+KillWindow::~KillWindow()
+ {
+ }
+
+void KillWindow::start()
+ {
+ static Cursor kill_cursor = 0;
+ if (!kill_cursor)
+ kill_cursor = XCreateFontCursor(qt_xdisplay(), XC_pirate);
+
+ if (XGrabPointer(qt_xdisplay(), qt_xrootwin(), False,
+ ButtonPressMask | ButtonReleaseMask |
+ PointerMotionMask |
+ EnterWindowMask | LeaveWindowMask,
+ GrabModeAsync, GrabModeAsync, None,
+ kill_cursor, CurrentTime) == GrabSuccess)
+ {
+ XGrabKeyboard(qt_xdisplay(), qt_xrootwin(), False,
+ GrabModeAsync, GrabModeAsync, CurrentTime);
+
+ XEvent ev;
+ int return_pressed = 0;
+ int escape_pressed = 0;
+ int button_released = 0;
+
+ grabXServer();
+
+ while (!return_pressed && !escape_pressed && !button_released)
+ {
+ XMaskEvent(qt_xdisplay(), KeyPressMask | ButtonPressMask |
+ ButtonReleaseMask | PointerMotionMask, &ev);
+
+ if (ev.type == KeyPress)
+ {
+ int kc = XKeycodeToKeysym(qt_xdisplay(), ev.xkey.keycode, 0);
+ int mx = 0;
+ int my = 0;
+ return_pressed = (kc == XK_Return) || (kc == XK_space);
+ escape_pressed = (kc == XK_Escape);
+ if (kc == XK_Left) mx = -10;
+ if (kc == XK_Right) mx = 10;
+ if (kc == XK_Up) my = -10;
+ if (kc == XK_Down) my = 10;
+ if (ev.xkey.state & ControlMask)
+ {
+ mx /= 10;
+ my /= 10;
+ }
+ TQCursor::setPos(TQCursor::pos()+TQPoint(mx, my));
+ }
+
+ if (ev.type == ButtonRelease)
+ {
+ button_released = (ev.xbutton.button == Button1);
+ if ( ev.xbutton.button == Button3 )
+ {
+ escape_pressed = TRUE;
+ break;
+ }
+ if( ev.xbutton.button == Button1 || ev.xbutton.button == Button2 )
+ workspace->killWindowId(ev.xbutton.subwindow);
+ }
+ continue;
+ }
+ if (return_pressed)
+ {
+ Window root, child;
+ int dummy1, dummy2, dummy3, dummy4;
+ unsigned int dummy5;
+ if( XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
+ &dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) == true
+ && child != None )
+ workspace->killWindowId( child );
+ }
+
+ ungrabXServer();
+
+ XUngrabKeyboard(qt_xdisplay(), CurrentTime);
+ XUngrabPointer(qt_xdisplay(), CurrentTime);
+ }
+ }
+
+} // namespace