diff options
Diffstat (limited to 'twin/events.cpp')
-rw-r--r-- | twin/events.cpp | 167 |
1 files changed, 86 insertions, 81 deletions
diff --git a/twin/events.cpp b/twin/events.cpp index e9f8fd484..5158df40b 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() ); + mouse_emulation = false; + 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: @@ -221,7 +221,7 @@ bool Workspace::workspaceEvent( XEvent * e ) if ( tab_grab || control_grab ) { tab_box->handleMouseEvent( e ); - return TRUE; + return true; } break; case KeyPress: @@ -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,13 +317,13 @@ 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 ); } } - return TRUE; + return true; } return ( e->xunmap.event != e->xunmap.window ); // hide wm typical event from Qt @@ -336,12 +336,12 @@ bool Workspace::workspaceEvent( XEvent * e ) { //do not confuse Qt with these events. After all, _we_ are the //window manager who does the reparenting. - return TRUE; + return true; } case DestroyNotify: { if ( removeSystemTrayWin( e->xdestroywindow.window, false ) ) - return TRUE; + return true; return false; } case MapRequest: @@ -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 @@ -362,9 +362,9 @@ bool Workspace::workspaceEvent( XEvent * e ) // this code doesn't check the parent to be root. // if ( e->xmaprequest.parent == root ) { //###TODO store previously destroyed client ids if ( addSystemTrayWin( e->xmaprequest.window ) ) - return TRUE; + 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; @@ -428,7 +428,7 @@ bool Workspace::workspaceEvent( XEvent * e ) break; case KeyRelease: if ( mouse_emulation ) - return FALSE; + return false; break; case FocusIn: if( e->xfocus.window == rootWin() && TQCString( getenv("TDE_MULTIHEAD")).lower() != "true" @@ -454,13 +454,13 @@ 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: break; } - return FALSE; + return false; } // Some events don't have the actual window which caused the event @@ -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 ); @@ -733,7 +733,7 @@ void Client::destroyNotifyEvent( XDestroyWindowEvent* e ) } -bool blockAnimation = FALSE; +bool blockAnimation = false; /*! Handles client messages for the client window @@ -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,15 +879,15 @@ 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() )); - shadeHoverTimer->start( options->shadeHoverInterval, TRUE ); + connect( shadeHoverTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( shadeHover() )); + shadeHoverTimer->start( options->shadeHoverInterval, true ); } if ( options->focusPolicy == Options::ClickToFocus ) @@ -890,12 +895,12 @@ 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() ) ); - autoRaiseTimer->start( options->autoRaiseInterval, TRUE ); + connect( autoRaiseTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( autoRaise() ) ); + autoRaiseTimer->start( options->autoRaiseInterval, true ); } TQPoint currentPos( e->x_root, e->y_root ); @@ -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, @@ -974,13 +979,13 @@ void Client::grabButton( int modifier ) ++i ) XGrabButton( tqt_xdisplay(), AnyButton, modifier | mods[ i ], - wrapperId(), FALSE, ButtonPressMask, + wrapperId(), false, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None ); } 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(); @@ -1420,7 +1425,7 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in bool replay = performMouseCommand( com, TQPoint( x_root, y_root), perform_handled ); if ( isSpecialWindow()) - replay = TRUE; + replay = true; if( w == wrapperId()) // these can come only from a grab XAllowEvents(tqt_xdisplay(), replay? ReplayPointer : SyncPointer, CurrentTime ); //tqt_x_time); @@ -1448,7 +1453,7 @@ void Client::processDecorationButtonPress( int button, int /*state*/, int x, int Options::MouseCommand com = Options::MouseNothing; bool active = isActive(); if ( !wantsInput() ) // we cannot be active, use it anyway - active = TRUE; + active = true; if ( button == Button1 ) com = active ? options->commandActiveTitlebar1() : options->commandInactiveTitlebar1(); @@ -1461,7 +1466,7 @@ void Client::processDecorationButtonPress( int button, int /*state*/, int x, int && com != Options::MouseMinimize ) // mouse release event { mode = mousePosition( TQPoint( x, y )); - buttonDown = TRUE; + buttonDown = true; moveOffset = TQPoint( x, y ); invertedMoveOffset = rect().bottomRight() - moveOffset; unrestrictedMoveResize = false; @@ -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: @@ -1512,8 +1517,8 @@ bool Client::buttonReleaseEvent( Window w, int /*button*/, int state, int x, int y = this->y(); if ( (state & ( Button1Mask & Button2Mask & Button3Mask )) == 0 ) { - buttonDown = FALSE; - if ( moveResizeMode ) + buttonDown = false; + 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 ) @@ -1599,7 +1604,7 @@ void Client::focusInEvent( XFocusInEvent* e ) bool activate = workspace()->allowClientActivation( this, -1U, true ); workspace()->gotFocusIn( this ); // remove from should_get_focus list if( activate ) - setActive( TRUE ); + setActive( true ); else { workspace()->restoreFocus(); @@ -1668,7 +1673,7 @@ void Client::focusOutEvent( XFocusOutEvent* e ) if ( TQApplication::activePopupWidget() ) return; if( !check_follows_focusin( this )) - setActive( FALSE ); + setActive( false ); } // performs _NET_WM_MOVERESIZE @@ -1679,10 +1684,10 @@ void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction ) else if( moveResizeMode && direction == NET::MoveResizeCancel ) { finishMoveResize( true ); - buttonDown = FALSE; + buttonDown = false; setCursor( mode ); } - else if( direction >= NET::TopLeft && direction <= NET::Left ) + else if( direction >= NET::TopLeft && direction <= NET::Left ) { static const Position convert[] = { @@ -1699,7 +1704,7 @@ void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction ) return; if( moveResizeMode ) finishMoveResize( false ); - buttonDown = TRUE; + buttonDown = true; moveOffset = TQPoint( x_root - x(), y_root - y()); // map from global invertedMoveOffset = rect().bottomRight() - moveOffset; unrestrictedMoveResize = false; @@ -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; @@ -1751,12 +1756,12 @@ void Client::keyPressEvent( uint key_code ) case Key_Return: case Key_Enter: finishMoveResize( false ); - buttonDown = FALSE; + buttonDown = false; setCursor( mode ); break; case Key_Escape: finishMoveResize( true ); - buttonDown = FALSE; + buttonDown = false; setCursor( mode ); break; default: |