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

twin

killwindow.cpp
00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
00006 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
00007 
00008 You can Freely distribute this program under the GNU General Public
00009 License. See the file "COPYING" for the exact licensing terms.
00010 ******************************************************************/
00011 
00012 #include "killwindow.h"
00013 #include <tqcursor.h>
00014 #include <X11/Xlib.h>
00015 #include <X11/XKBlib.h>
00016 #include <X11/keysym.h>
00017 #include <X11/keysymdef.h>
00018 #include <X11/cursorfont.h>
00019 
00020 namespace KWinInternal
00021 {
00022 
00023 KillWindow::KillWindow( Workspace* ws )
00024     : workspace( ws )
00025     {
00026     }
00027 
00028 KillWindow::~KillWindow()
00029     {
00030     }
00031 
00032 void KillWindow::start() 
00033     {
00034     static Cursor kill_cursor = 0;
00035     if (!kill_cursor)
00036         kill_cursor = XCreateFontCursor(tqt_xdisplay(), XC_pirate);
00037 
00038     if (XGrabPointer(tqt_xdisplay(), tqt_xrootwin(), False,
00039                      ButtonPressMask | ButtonReleaseMask |
00040                      PointerMotionMask |
00041                      EnterWindowMask | LeaveWindowMask,
00042                      GrabModeAsync, GrabModeAsync, None,
00043                      kill_cursor, CurrentTime) == GrabSuccess) 
00044         {
00045         XGrabKeyboard(tqt_xdisplay(), tqt_xrootwin(), False,
00046                       GrabModeAsync, GrabModeAsync, CurrentTime);
00047 
00048         XEvent ev;
00049         int return_pressed  = 0;
00050         int escape_pressed  = 0;
00051         int button_released = 0;
00052 
00053         grabXServer();
00054 
00055         while (!return_pressed && !escape_pressed && !button_released) 
00056             {
00057             XMaskEvent(tqt_xdisplay(), KeyPressMask | ButtonPressMask |
00058                        ButtonReleaseMask | PointerMotionMask, &ev);
00059 
00060             if (ev.type == KeyPress)    
00061                 {
00062                 int kc = XkbKeycodeToKeysym(tqt_xdisplay(), ev.xkey.keycode, 0, 0);
00063                 int mx = 0;
00064                 int my = 0;
00065                 return_pressed = (kc == XK_Return) || (kc == XK_space);
00066                 escape_pressed = (kc == XK_Escape);
00067                 if (kc == XK_Left)  mx = -10;
00068                 if (kc == XK_Right) mx = 10;
00069                 if (kc == XK_Up)    my = -10;
00070                 if (kc == XK_Down)  my = 10;
00071                 if (ev.xkey.state & ControlMask) 
00072                     {
00073                     mx /= 10;
00074                     my /= 10;
00075                     }
00076                 TQCursor::setPos(TQCursor::pos()+TQPoint(mx, my));
00077                 }
00078 
00079             if (ev.type == ButtonRelease) 
00080                 {
00081                 button_released = (ev.xbutton.button == Button1);
00082                 if ( ev.xbutton.button == Button3 ) 
00083                     {
00084                     escape_pressed = TRUE;
00085                     break;
00086                     }
00087                 if( ev.xbutton.button == Button1 || ev.xbutton.button == Button2 )
00088                     workspace->killWindowId(ev.xbutton.subwindow);
00089                 }
00090             continue;
00091             }
00092         if (return_pressed) 
00093             {
00094             Window root, child;
00095             int dummy1, dummy2, dummy3, dummy4;
00096             unsigned int dummy5;
00097             if( XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
00098                 &dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) == true
00099                 && child != None )
00100                 workspace->killWindowId( child );
00101             }
00102 
00103         ungrabXServer();
00104 
00105         XUngrabKeyboard(tqt_xdisplay(), CurrentTime);
00106         XUngrabPointer(tqt_xdisplay(), CurrentTime);
00107         }
00108     }
00109 
00110 } // 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.7.6.1
This website is maintained by Timothy Pearson.