• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kwin
 

kwin

  • kwin
killwindow.cpp
1 /*****************************************************************
2  KWin - the KDE window manager
3  This file is part of the KDE project.
4 
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 
8 You can Freely distribute this program under the GNU General Public
9 License. See the file "COPYING" for the exact licensing terms.
10 ******************************************************************/
11 
12 //#ifndef QT_CLEAN_NAMESPACE
13 //#define QT_CLEAN_NAMESPACE
14 //#endif
15 #include "killwindow.h"
16 #include <tqcursor.h>
17 #include <X11/Xlib.h>
18 #include <X11/keysym.h>
19 #include <X11/keysymdef.h>
20 #include <X11/cursorfont.h>
21 
22 namespace KWinInternal
23 {
24 
25 KillWindow::KillWindow( Workspace* ws )
26  : workspace( ws )
27  {
28  }
29 
30 KillWindow::~KillWindow()
31  {
32  }
33 
34 void KillWindow::start()
35  {
36  static Cursor kill_cursor = 0;
37  if (!kill_cursor)
38  kill_cursor = XCreateFontCursor(qt_xdisplay(), XC_pirate);
39 
40  if (XGrabPointer(qt_xdisplay(), qt_xrootwin(), False,
41  ButtonPressMask | ButtonReleaseMask |
42  PointerMotionMask |
43  EnterWindowMask | LeaveWindowMask,
44  GrabModeAsync, GrabModeAsync, None,
45  kill_cursor, CurrentTime) == GrabSuccess)
46  {
47  XGrabKeyboard(qt_xdisplay(), qt_xrootwin(), False,
48  GrabModeAsync, GrabModeAsync, CurrentTime);
49 
50  XEvent ev;
51  int return_pressed = 0;
52  int escape_pressed = 0;
53  int button_released = 0;
54 
55  grabXServer();
56 
57  while (!return_pressed && !escape_pressed && !button_released)
58  {
59  XMaskEvent(qt_xdisplay(), KeyPressMask | ButtonPressMask |
60  ButtonReleaseMask | PointerMotionMask, &ev);
61 
62  if (ev.type == KeyPress)
63  {
64  int kc = XKeycodeToKeysym(qt_xdisplay(), ev.xkey.keycode, 0);
65  int mx = 0;
66  int my = 0;
67  return_pressed = (kc == XK_Return) || (kc == XK_space);
68  escape_pressed = (kc == XK_Escape);
69  if (kc == XK_Left) mx = -10;
70  if (kc == XK_Right) mx = 10;
71  if (kc == XK_Up) my = -10;
72  if (kc == XK_Down) my = 10;
73  if (ev.xkey.state & ControlMask)
74  {
75  mx /= 10;
76  my /= 10;
77  }
78  TQCursor::setPos(TQCursor::pos()+TQPoint(mx, my));
79  }
80 
81  if (ev.type == ButtonRelease)
82  {
83  button_released = (ev.xbutton.button == Button1);
84  if ( ev.xbutton.button == Button3 )
85  {
86  escape_pressed = TRUE;
87  break;
88  }
89  if( ev.xbutton.button == Button1 || ev.xbutton.button == Button2 )
90  workspace->killWindowId(ev.xbutton.subwindow);
91  }
92  continue;
93  }
94  if (return_pressed)
95  {
96  Window root, child;
97  int dummy1, dummy2, dummy3, dummy4;
98  unsigned int dummy5;
99  if( XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
100  &dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) == true
101  && child != None )
102  workspace->killWindowId( child );
103  }
104 
105  ungrabXServer();
106 
107  XUngrabKeyboard(qt_xdisplay(), CurrentTime);
108  XUngrabPointer(qt_xdisplay(), CurrentTime);
109  }
110  }
111 
112 } // namespace

kwin

Skip menu "kwin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kwin

Skip menu "kwin"
  • kate
  • kwin
  •   lib
  • libkonq
Generated for kwin by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |