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

twin

  • twin
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 #include "killwindow.h"
13 #include <tqcursor.h>
14 #include <X11/Xlib.h>
15 #include <X11/XKBlib.h>
16 #include <X11/keysym.h>
17 #include <X11/keysymdef.h>
18 #include <X11/cursorfont.h>
19 
20 namespace KWinInternal
21 {
22 
23 KillWindow::KillWindow( Workspace* ws )
24  : workspace( ws )
25  {
26  }
27 
28 KillWindow::~KillWindow()
29  {
30  }
31 
32 void KillWindow::start()
33  {
34  static Cursor kill_cursor = 0;
35  if (!kill_cursor)
36  kill_cursor = XCreateFontCursor(tqt_xdisplay(), XC_pirate);
37 
38  if (XGrabPointer(tqt_xdisplay(), tqt_xrootwin(), False,
39  ButtonPressMask | ButtonReleaseMask |
40  PointerMotionMask |
41  EnterWindowMask | LeaveWindowMask,
42  GrabModeAsync, GrabModeAsync, None,
43  kill_cursor, CurrentTime) == GrabSuccess)
44  {
45  XGrabKeyboard(tqt_xdisplay(), tqt_xrootwin(), False,
46  GrabModeAsync, GrabModeAsync, CurrentTime);
47 
48  XEvent ev;
49  int return_pressed = 0;
50  int escape_pressed = 0;
51  int button_released = 0;
52 
53  grabXServer();
54 
55  while (!return_pressed && !escape_pressed && !button_released)
56  {
57  XMaskEvent(tqt_xdisplay(), KeyPressMask | ButtonPressMask |
58  ButtonReleaseMask | PointerMotionMask, &ev);
59 
60  if (ev.type == KeyPress)
61  {
62  int kc = XkbKeycodeToKeysym(tqt_xdisplay(), ev.xkey.keycode, 0, 0);
63  int mx = 0;
64  int my = 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)
72  {
73  mx /= 10;
74  my /= 10;
75  }
76  TQCursor::setPos(TQCursor::pos()+TQPoint(mx, my));
77  }
78 
79  if (ev.type == ButtonRelease)
80  {
81  button_released = (ev.xbutton.button == Button1);
82  if ( ev.xbutton.button == Button3 )
83  {
84  escape_pressed = TRUE;
85  break;
86  }
87  if( ev.xbutton.button == Button1 || ev.xbutton.button == Button2 )
88  workspace->killWindowId(ev.xbutton.subwindow);
89  }
90  continue;
91  }
92  if (return_pressed)
93  {
94  Window root, child;
95  int dummy1, dummy2, dummy3, dummy4;
96  unsigned int dummy5;
97  if( XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
98  &dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) == true
99  && child != None )
100  workspace->killWindowId( child );
101  }
102 
103  ungrabXServer();
104 
105  XUngrabKeyboard(tqt_xdisplay(), CurrentTime);
106  XUngrabPointer(tqt_xdisplay(), CurrentTime);
107  }
108  }
109 
110 } // namespace

twin

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

twin

Skip menu "twin"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin by doxygen 1.9.1
This website is maintained by Timothy Pearson.