diff options
Diffstat (limited to 'twin/events.cpp')
-rw-r--r-- | twin/events.cpp | 123 |
1 files changed, 64 insertions, 59 deletions
diff --git a/twin/events.cpp b/twin/events.cpp index e9f8fd484..3d3ba999c 100644 --- a/twin/events.cpp +++ b/twin/events.cpp @@ -194,10 +194,10 @@ void RootInfo::changeShowingDesktop( bool showing ) */ bool Workspace::workspaceEvent( XEvent * e ) { - if ( mouse_emulation && (e->type == ButtonPress || e->type == ButtonRelease ) ) + if ( mouse_emulation && (e->type == ButtonPress || e->type == ButtonRelease ) ) { mouse_emulation = FALSE; - XUngrabKeyboard( tqt_xdisplay(), GET_QT_X_TIME() ); + XUngrabKeyboard( tqt_xdisplay(), get_tqt_x_time() ); } if( e->type == PropertyNotify || e->type == ClientMessage ) @@ -211,7 +211,7 @@ bool Workspace::workspaceEvent( XEvent * e ) } // events that should be handled before Clients can get them - switch (e->type) + switch (e->type) { case ButtonPress: case ButtonRelease: @@ -284,7 +284,7 @@ bool Workspace::workspaceEvent( XEvent * e ) return true; } - switch (e->type) + switch (e->type) { case CreateNotify: if ( e->xcreatewindow.parent == root && @@ -292,18 +292,18 @@ bool Workspace::workspaceEvent( XEvent * e ) !e->xcreatewindow.override_redirect ) { // see comments for allowClientActivation() - Time my_qtx_time = GET_QT_X_TIME(); + Time my_qtx_time = get_tqt_x_time(); XChangeProperty(tqt_xdisplay(), e->xcreatewindow.window, atoms->kde_net_wm_user_creation_time, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&my_qtx_time, 1); - SET_QT_X_TIME(my_qtx_time); + set_tqt_x_time(my_qtx_time); } break; case UnmapNotify: { // check for system tray windows - if ( removeSystemTrayWin( e->xunmap.window, true ) ) + if ( removeSystemTrayWin( e->xunmap.window, true ) ) { // If the system tray gets destroyed, the system tray // icons automatically get unmapped, reparented and mapped @@ -317,7 +317,7 @@ bool Workspace::workspaceEvent( XEvent * e ) if ( XCheckTypedWindowEvent (tqt_xdisplay(), w, ReparentNotify, &ev) ) { - if ( ev.xreparent.parent != root ) + if ( ev.xreparent.parent != root ) { XReparentWindow( tqt_xdisplay(), w, root, 0, 0 ); addSystemTrayWin( w ); @@ -351,7 +351,7 @@ bool Workspace::workspaceEvent( XEvent * e ) // e->xmaprequest.window is different from e->xany.window // TODO this shouldn't be necessary now Client* c = findClient( WindowMatchPredicate( e->xmaprequest.window )); - if ( !c ) + if ( !c ) { // don't check for the parent being the root window, this breaks when some app unmaps // a window, changes something and immediately maps it back, without giving KWin @@ -364,7 +364,7 @@ bool Workspace::workspaceEvent( XEvent * e ) if ( addSystemTrayWin( e->xmaprequest.window ) ) return TRUE; c = createClient( e->xmaprequest.window, false ); - if ( c != NULL && root != tqt_xrootwin() ) + if ( c != NULL && root != tqt_xrootwin() ) { // TODO what is this? // TODO may use TQWidget::create XReparentWindow( tqt_xdisplay(), c->frameId(), root, 0, 0 ); @@ -389,7 +389,7 @@ bool Workspace::workspaceEvent( XEvent * e ) if ( w ) TQWhatsThis::leaveWhatsThisMode(); } - if( electricBorder(e)) + if (activeBorderEvent(e)) return true; break; } @@ -405,7 +405,7 @@ bool Workspace::workspaceEvent( XEvent * e ) } case ConfigureRequest: { - if ( e->xconfigurerequest.parent == root ) + if ( e->xconfigurerequest.parent == root ) { XWindowChanges wc; wc.border_width = e->xconfigurerequest.border_width; @@ -454,7 +454,7 @@ bool Workspace::workspaceEvent( XEvent * e ) case FocusOut: return true; // always eat these, they would tell Qt that KWin is the active app case ClientMessage: - if( electricBorder( e )) + if (activeBorderEvent(e)) return true; break; default: @@ -542,7 +542,7 @@ bool Client::windowEvent( XEvent* e ) } // TODO move all focus handling stuff to separate file? - switch (e->type) + switch (e->type) { case UnmapNotify: unmapNotifyEvent( &e->xunmap ); @@ -785,8 +785,13 @@ void Client::configureRequestEvent( XConfigureRequestEvent* e ) { if( e->window != window()) return; // ignore frame/wrapper - if ( isResize() || isMove()) + if ( isResize() || isMove() || inhibitConfigureRequests) + { + // Send a synthetic configure notification to make sure the + // window contents get updated by the application + sendSyntheticConfigureNotify(); return; // we have better things to do right now + } if( fullscreen_mode == FullScreenNormal ) // refuse resizing of fullscreen windows { // but allow resizing fullscreen hacks in order to let them cancel fullscreen mode @@ -800,7 +805,7 @@ void Client::configureRequestEvent( XConfigureRequestEvent* e ) return; } - if ( e->value_mask & CWBorderWidth ) + if ( e->value_mask & CWBorderWidth ) { // first, get rid of a window border XWindowChanges wc; @@ -818,7 +823,7 @@ void Client::configureRequestEvent( XConfigureRequestEvent* e ) restackWindow( e->above, e->detail, NET::FromApplication, userTime(), false ); // TODO sending a synthetic configure notify always is fine, even in cases where - // the ICCCM doesn't require this - it can be though of as 'the WM decided to move + // the ICCCM doesn't require this - it can be thought of as 'the WM decided to move // the window later'. The client should not cause that many configure request, // so this should not have any significant impact. With user moving/resizing // the it should be optimized though (see also Client::setGeometry()/plainResize()/move()). @@ -836,7 +841,7 @@ void Client::propertyNotifyEvent( XPropertyEvent* e ) { if( e->window != window()) return; // ignore frame/wrapper - switch ( e->atom ) + switch ( e->atom ) { case XA_WM_NORMAL_HINTS: getWmNormalHints(); @@ -874,14 +879,14 @@ void Client::enterNotifyEvent( XCrossingEvent* e ) return; // care only about entering the whole frame if( e->mode == NotifyNormal || ( !options->focusPolicyIsReasonable() && - e->mode == NotifyUngrab ) ) + e->mode == NotifyUngrab ) ) { - if (options->shadeHover && isShade()) + if (options->shadeHover && isShade()) { delete shadeHoverTimer; shadeHoverTimer = new TQTimer( this ); - connect( shadeHoverTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( shadeHover() )); + connect( shadeHoverTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( shadeHover() )); shadeHoverTimer->start( options->shadeHoverInterval, TRUE ); } @@ -890,11 +895,11 @@ void Client::enterNotifyEvent( XCrossingEvent* e ) if ( options->autoRaise && !isDesktop() && !isDock() && !isTopMenu() && workspace()->focusChangeEnabled() && - workspace()->topClientOnDesktop( workspace()->currentDesktop()) != this ) + workspace()->topClientOnDesktop( workspace()->currentDesktop()) != this ) { delete autoRaiseTimer; autoRaiseTimer = new TQTimer( this ); - connect( autoRaiseTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( autoRaise() ) ); + connect( autoRaiseTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( autoRaise() ) ); autoRaiseTimer->start( options->autoRaiseInterval, TRUE ); } @@ -919,12 +924,12 @@ void Client::leaveNotifyEvent( XCrossingEvent* e ) { if( e->window != frameId()) return; // care only about leaving the whole frame - if ( e->mode == NotifyNormal ) + if ( e->mode == NotifyNormal ) { - if ( !buttonDown ) + if ( !buttonDown ) { mode = PositionCenter; - setCursor( tqarrowCursor ); + setCursor( TQt::arrowCursor ); } bool lostMouse = !rect().contains( TQPoint( e->x, e->y ) ); // 'lostMouse' wouldn't work with e.g. B2 or Keramik, which have non-rectangular decorations @@ -934,7 +939,7 @@ void Client::leaveNotifyEvent( XCrossingEvent* e ) // TODO this still sucks if a window appears above this one - it should lose the mouse // if this window is another client, but not if it's a popup ... maybe after KDE3.1 :( // (repeat after me 'AARGHL!') - if ( !lostMouse && e->detail != NotifyInferior ) + if ( !lostMouse && e->detail != NotifyInferior ) { int d1, d2, d3, d4; unsigned int d5; @@ -943,7 +948,7 @@ void Client::leaveNotifyEvent( XCrossingEvent* e ) || child == None ) lostMouse = true; // really lost the mouse } - if ( lostMouse ) + if ( lostMouse ) { cancelAutoRaise(); workspace()->cancelDelayFocus(); @@ -963,7 +968,7 @@ void Client::leaveNotifyEvent( XCrossingEvent* e ) #define XScrL KKeyNative::modXScrollLock() void Client::grabButton( int modifier ) { - unsigned int mods[ 8 ] = + unsigned int mods[ 8 ] = { 0, XCapL, XNumL, XNumL | XCapL, XScrL, XScrL | XCapL, @@ -980,7 +985,7 @@ void Client::grabButton( int modifier ) void Client::ungrabButton( int modifier ) { - unsigned int mods[ 8 ] = + unsigned int mods[ 8 ] = { 0, XCapL, XNumL, XNumL | XCapL, XScrL, XScrL | XCapL, @@ -1046,23 +1051,23 @@ void Client::updateMouseGrab() int qtToX11Button( TQt::ButtonState button ) { - if( button == Qt::LeftButton ) + if( button == TQt::LeftButton ) return Button1; - else if( button == Qt::MidButton ) + else if( button == TQt::MidButton ) return Button2; - else if( button == Qt::RightButton ) + else if( button == TQt::RightButton ) return Button3; return AnyButton; } - + int qtToX11State( TQt::ButtonState state ) { int ret = 0; - if( state & Qt::LeftButton ) + if( state & TQt::LeftButton ) ret |= Button1Mask; - if( state & Qt::MidButton ) + if( state & TQt::MidButton ) ret |= Button2Mask; - if( state & Qt::RightButton ) + if( state & TQt::RightButton ) ret |= Button3Mask; if( state & TQt::ShiftButton ) ret |= ShiftMask; @@ -1079,7 +1084,7 @@ int qtToX11State( TQt::ButtonState state ) // for the decoration window cannot be (easily) intercepted as X11 events bool Client::eventFilter( TQObject* o, TQEvent* e ) { - if (TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(shadowWidget)) + if (o == shadowWidget) { if (e->type() == TQEvent::MouseButtonRelease) { @@ -1092,11 +1097,11 @@ bool Client::eventFilter( TQObject* o, TQEvent* e ) removeShadow(); switch (qe->button()) { - case Qt::MidButton: + case TQt::MidButton: buttonMask = Button2Mask; buttonPressed = Button2; break; - case Qt::RightButton: + case TQt::RightButton: buttonMask = Button3Mask; buttonPressed = Button3; break; @@ -1291,29 +1296,29 @@ bool Client::eventFilter( TQObject* o, TQEvent* e ) } } if( decoration == NULL - || TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(decoration->widget())) + || o != decoration->widget()) return false; if( e->type() == TQEvent::MouseButtonPress ) { - TQMouseEvent* ev = TQT_TQMOUSEEVENT( e ); + TQMouseEvent* ev = static_cast<TQMouseEvent*>( e ); return buttonPressEvent( decorationId(), qtToX11Button( ev->button()), qtToX11State( ev->state()), ev->x(), ev->y(), ev->globalX(), ev->globalY() ); } if( e->type() == TQEvent::MouseButtonRelease ) { - TQMouseEvent* ev = TQT_TQMOUSEEVENT( e ); + TQMouseEvent* ev = static_cast<TQMouseEvent*>( e ); return buttonReleaseEvent( decorationId(), qtToX11Button( ev->button()), qtToX11State( ev->state()), ev->x(), ev->y(), ev->globalX(), ev->globalY() ); } if( e->type() == TQEvent::MouseMove ) // FRAME i fake z enter/leave? { - TQMouseEvent* ev = TQT_TQMOUSEEVENT( e ); + TQMouseEvent* ev = static_cast<TQMouseEvent*>( e ); return motionNotifyEvent( decorationId(), qtToX11State( ev->state()), ev->x(), ev->y(), ev->globalX(), ev->globalY() ); } if( e->type() == TQEvent::Wheel ) { - TQWheelEvent* ev = TQT_TQWHEELEVENT( e ); + TQWheelEvent* ev = static_cast<TQWheelEvent*>( e ); bool r = buttonPressEvent( decorationId(), ev->delta() > 0 ? Button4 : Button5, qtToX11State( ev->state()), ev->x(), ev->y(), ev->globalX(), ev->globalY() ); r = r || buttonReleaseEvent( decorationId(), ev->delta() > 0 ? Button4 : Button5, qtToX11State( ev->state()), @@ -1322,7 +1327,7 @@ bool Client::eventFilter( TQObject* o, TQEvent* e ) } if( e->type() == TQEvent::Resize ) { - TQResizeEvent* ev = TQT_TQRESIZEEVENT( e ); + TQResizeEvent* ev = static_cast<TQResizeEvent*>( e ); // Filter out resize events that inform about size different than frame size. // This will ensure that decoration->width() etc. and decoration->widget()->width() will be in sync. // These events only seem to be delayed events from initial resizing before show() was called @@ -1348,7 +1353,7 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in // FRAME something out of this would be processed before it gets decorations updateUserTime(); workspace()->setWasUserInteraction(); - uint keyModX = (options->keyCmdAllModKey() == Qt::Key_Meta) ? + uint keyModX = (options->keyCmdAllModKey() == TQt::Key_Meta) ? KKeyNative::modX(KKey::WIN) : KKeyNative::modX(KKey::ALT); bool bModKeyHeld = keyModX != 0 && ( state & KKeyNative::accelModMaskX()) == keyModX; @@ -1368,7 +1373,7 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in if ( bModKeyHeld ) { was_action = true; - switch (button) + switch (button) { case Button1: com = options->commandAll1(); @@ -1391,7 +1396,7 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in { was_action = true; perform_handled = true; - switch (button) + switch (button) { case Button1: com = options->commandWindow1(); @@ -1481,13 +1486,13 @@ void Client::processMousePressEvent( TQMouseEvent* e ) int button; switch( e->button()) { - case Qt::LeftButton: + case TQt::LeftButton: button = Button1; break; - case Qt::MidButton: + case TQt::MidButton: button = Button2; break; - case Qt::RightButton: + case TQt::RightButton: button = Button3; break; default: @@ -1513,7 +1518,7 @@ bool Client::buttonReleaseEvent( Window w, int /*button*/, int state, int x, int if ( (state & ( Button1Mask & Button2Mask & Button3Mask )) == 0 ) { buttonDown = FALSE; - if ( moveResizeMode ) + if ( moveResizeMode ) { finishMoveResize( false ); // mouse position is still relative to old Client position, adjust it @@ -1550,7 +1555,7 @@ static bool waitingMotionEvent() // of processes events reaches the timestamp of the last suitable // MotionNotify event in the queue. if( next_motion_time != CurrentTime - && timestampCompare( GET_QT_X_TIME(), next_motion_time ) < 0 ) + && timestampCompare( get_tqt_x_time(), next_motion_time ) < 0 ) return true; was_motion = false; XSync( tqt_xdisplay(), False ); // this helps to discard more MotionNotify events @@ -1564,7 +1569,7 @@ bool Client::motionNotifyEvent( Window w, int /*state*/, int x, int y, int x_roo { if( w != frameId() && w != decorationId() && w != moveResizeGrabWindow()) return true; // care only about the whole frame - if ( !buttonDown ) + if ( !buttonDown ) { Position newmode = mousePosition( TQPoint( x, y )); if( newmode != mode ) @@ -1682,7 +1687,7 @@ void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction ) buttonDown = FALSE; setCursor( mode ); } - else if( direction >= NET::TopLeft && direction <= NET::Left ) + else if( direction >= NET::TopLeft && direction <= NET::Left ) { static const Position convert[] = { @@ -1728,12 +1733,12 @@ void Client::keyPressEvent( uint key_code ) updateUserTime(); if ( !isMove() && !isResize() ) return; - bool is_control = key_code & Qt::CTRL; - bool is_alt = key_code & Qt::ALT; + bool is_control = key_code & TQt::CTRL; + bool is_alt = key_code & TQt::ALT; key_code = key_code & 0xffff; int delta = is_control?1:is_alt?32:8; TQPoint pos = TQCursor::pos(); - switch ( key_code ) + switch ( key_code ) { case Key_Left: pos.rx() -= delta; |