diff --git a/bridge.cpp b/bridge.cpp index 8520dc703d..6b37c0eaad 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -123,6 +123,11 @@ void Bridge::titlebarDblClickOperation() c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick()); } +void Bridge::titlebarMouseWheelOperation( int delta ) + { + c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), QCursor::pos()); + } + void Bridge::setShade( bool set ) { c->setShade( set ? ShadeNormal : ShadeNone ); diff --git a/bridge.h b/bridge.h index 49a4208839..155970f04a 100644 --- a/bridge.h +++ b/bridge.h @@ -57,6 +57,7 @@ class Bridge : public KDecorationBridge virtual void showContextHelp(); virtual void setDesktop( int desktop ); virtual void titlebarDblClickOperation(); + virtual void titlebarMouseWheelOperation( int delta ); virtual void setShade( bool set ); virtual void setKeepAbove( bool ); virtual void setKeepBelow( bool ); diff --git a/client.cpp b/client.cpp index 61c70db1b8..67c166a7ec 100644 --- a/client.cpp +++ b/client.cpp @@ -810,6 +810,11 @@ void Client::setShade( ShadeMode mode ) void Client::shadeHover() { setShade( ShadeHover ); + cancelShadeHover(); + } + +void Client::cancelShadeHover() + { delete shadeHoverTimer; shadeHoverTimer = 0; } diff --git a/client.h b/client.h index f0b4f2ab61..aff36dc2d0 100644 --- a/client.h +++ b/client.h @@ -275,6 +275,7 @@ class Client : public QObject, public KDecorationDefines void maximize( MaximizeMode ); void toggleShade(); void showContextHelp(); + void cancelShadeHover(); void cancelAutoRaise(); void destroyClient(); void checkActiveModal(); diff --git a/clients/PORTING b/clients/PORTING index 1699c7929a..9a5fb9f6b3 100644 --- a/clients/PORTING +++ b/clients/PORTING @@ -49,6 +49,10 @@ bool MyClient::eventFilter( QObject* o, QEvent* e ) mouseDoubleClickEvent( static_cast< QMouseEvent* >( e ) ); return true; + case QEvent::Wheel: + wheelEvent( static_cast< QWheelEvent* >( e )); + return true; + case QEvent::MouseButtonPress: processMousePressEvent( static_cast< QMouseEvent* >( e ) ); return true; diff --git a/events.cpp b/events.cpp index ae8ec7f123..03539965d1 100644 --- a/events.cpp +++ b/events.cpp @@ -939,8 +939,7 @@ void Client::leaveNotifyEvent( XCrossingEvent* e ) { cancelAutoRaise(); workspace()->cancelDelayFocus(); - delete shadeHoverTimer; - shadeHoverTimer = 0; + cancelShadeHover(); if ( shade_mode == ShadeHover && !moveResizeMode && !buttonDown ) setShade( ShadeNormal ); } @@ -1076,6 +1075,15 @@ bool Client::eventFilter( QObject* o, QEvent* e ) return motionNotifyEvent( decorationId(), qtToX11State( ev->state()), ev->x(), ev->y(), ev->globalX(), ev->globalY() ); } + if( e->type() == QEvent::Wheel ) + { + QWheelEvent* ev = static_cast< QWheelEvent* >( 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()), + ev->x(), ev->y(), ev->globalX(), ev->globalY() ); + return r; + } if( e->type() == QEvent::Resize ) { QResizeEvent* ev = static_cast< QResizeEvent* >( e ); @@ -1120,35 +1128,7 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in Options::MouseCommand com = Options::MouseNothing; bool was_action = false; bool perform_handled = false; - if (keyModX != 0 && (state & keyModX) && (state & ControlMask)) - { - switch (button) - { - case Button5: - if (opacity_ > 0) - { - setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0); - custom_opacity = true; - } - XAllowEvents(qt_xdisplay(), SyncPointer, CurrentTime ); - return true; - case Button4: - if (opacity_ < 0xFFFFFFFF) - { - if (opacity_ < 0xF3333333){ - setOpacity(TRUE, opacity_ + 0xCCCCCCC); - custom_opacity = true; - } - else{ - setOpacity(FALSE, 0xFFFFFFFF); - custom_opacity = false; - } - } - XAllowEvents(qt_xdisplay(), SyncPointer, CurrentTime ); - return true; - } - } - else if ( bModKeyHeld ) + if ( bModKeyHeld ) { was_action = true; switch (button) @@ -1162,6 +1142,10 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in case Button3: com = options->commandAll3(); break; + case Button4: + case Button5: + com = options->operationWindowMouseWheel( button == Button4 ? 120 : -120 ); + break; } } else @@ -1201,8 +1185,8 @@ bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, in if ( isSpecialWindow() && !isOverride()) replay = TRUE; - if( w == wrapperId()) // these can come only from a grab - XAllowEvents(qt_xdisplay(), replay? ReplayPointer : SyncPointer, CurrentTime ); //qt_x_time); + if( w == wrapperId()) // these can come only from a grab + XAllowEvents(qt_xdisplay(), replay? ReplayPointer : SyncPointer, CurrentTime ); //qt_x_time); return true; } } diff --git a/kcmkwin/kwindecoration/preview.cpp b/kcmkwin/kwindecoration/preview.cpp index 29e9fa7e21..917b968eb3 100644 --- a/kcmkwin/kwindecoration/preview.cpp +++ b/kcmkwin/kwindecoration/preview.cpp @@ -404,6 +404,10 @@ void KDecorationPreviewBridge::titlebarDblClickOperation() { } +void KDecorationPreviewBridge::titlebarMouseWheelOperation( int ) + { + } + void KDecorationPreviewBridge::setShade( bool ) { } diff --git a/kcmkwin/kwindecoration/preview.h b/kcmkwin/kwindecoration/preview.h index c0573a4d47..bf6d66f2d6 100644 --- a/kcmkwin/kwindecoration/preview.h +++ b/kcmkwin/kwindecoration/preview.h @@ -100,6 +100,7 @@ class KDecorationPreviewBridge virtual void showContextHelp(); virtual void setDesktop( int desktop ); virtual void titlebarDblClickOperation(); + virtual void titlebarMouseWheelOperation( int delta ); virtual void setShade( bool set ); virtual void setKeepAbove( bool ); virtual void setKeepBelow( bool ); diff --git a/kcmkwin/kwinoptions/mouse.cpp b/kcmkwin/kwinoptions/mouse.cpp index dadf813fe7..be9de1718a 100644 --- a/kcmkwin/kwinoptions/mouse.cpp +++ b/kcmkwin/kwinoptions/mouse.cpp @@ -140,8 +140,8 @@ KTitleBarActionsConfig::KTitleBarActionsConfig (bool _standAlone, KConfig *_conf QGrid *grid; QGroupBox *box; QLabel *label; - QString strMouseButton1, strMouseButton3; - QString txtButton1, txtButton3; + QString strMouseButton1, strMouseButton3, strMouseWheel; + QString txtButton1, txtButton3, txtButton4; QStringList items; bool leftHandedMouse = ( KGlobalSettings::mouseSettings().handed == KGlobalSettings::KMouseSettings::LeftHanded); @@ -171,6 +171,30 @@ KTitleBarActionsConfig::KTitleBarActionsConfig (bool _standAlone, KConfig *_conf label->setBuddy(combo); +/** Mouse Wheel Events **************/ + QHBoxLayout *hlayoutW = new QHBoxLayout(layout); + strMouseWheel = i18n("Titlebar wheel event:"); + label = new QLabel(strMouseWheel, this); + hlayoutW->addWidget(label); + txtButton4 = i18n("Handle mouse wheel events"); + QWhatsThis::add( label, txtButton4); + + // Titlebar and frame mouse Wheel + QComboBox* comboW = new QComboBox(this); + comboW->insertItem(i18n("Raise/Lower")); + comboW->insertItem(i18n("Shade/Unshade")); + comboW->insertItem(i18n("Maximize/Restore")); + comboW->insertItem(i18n("Keep Above/Below")); + comboW->insertItem(i18n("Move to Previous/Next Desktop")); + comboW->insertItem(i18n("Change Opacity")); + comboW->insertItem(i18n("Nothing")); + comboW->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); + connect(comboW, SIGNAL(activated(int)), SLOT(changed())); + hlayoutW->addWidget(comboW); + coTiAct4 = comboW; + QWhatsThis::add(comboW, txtButton4); + label->setBuddy(comboW); + /** Titlebar and frame **************/ box = new QVGroupBox( i18n("Titlebar && Frame"), this, "Titlebar and Frame"); @@ -412,6 +436,26 @@ const char* const tbl_All[] = { "Nothing", "" }; +const char* tbl_TiWAc[] = { + "Raise/Lower", + "Shade/Unshade", + "Maximize/Restore", + "Above/Below", + "Previous/Next Desktop", + "Change Opacity", + "Nothing", + "" }; + +const char* tbl_AllW[] = { + "Raise/Lower", + "Shade/Unshade", + "Maximize/Restore", + "Above/Below", + "Previous/Next Desktop", + "Change Opacity", + "Nothing", + "" }; + static const char* tbl_num_lookup( const char* const arr[], int pos ) { for( int i = 0; @@ -447,6 +491,8 @@ void KTitleBarActionsConfig::setComboText( QComboBox* combo, const char*txt ) combo->setCurrentItem( tbl_txt_lookup( tbl_TiAc, txt )); else if( combo == coTiInAct1 || combo == coTiInAct2 || combo == coTiInAct3 ) combo->setCurrentItem( tbl_txt_lookup( tbl_TiInAc, txt )); + else if( combo == coTiAct4 ) + combo->setCurrentItem( tbl_txt_lookup( tbl_TiWAc, txt )); else if( combo == coMax[0] || combo == coMax[1] || combo == coMax[2] ) { combo->setCurrentItem( tbl_txt_lookup( tbl_Max, txt )); @@ -471,6 +517,11 @@ const char* KTitleBarActionsConfig::functionTiInAc( int i ) return tbl_num_lookup( tbl_TiInAc, i ); } +const char* KTitleBarActionsConfig::functionTiWAc(int i) +{ + return tbl_num_lookup( tbl_TiWAc, i ); +} + const char* KTitleBarActionsConfig::functionMax( int i ) { return tbl_num_lookup( tbl_Max, i ); @@ -487,6 +538,7 @@ void KTitleBarActionsConfig::load() setComboText(coTiAct1,config->readEntry("CommandActiveTitlebar1","Raise").ascii()); setComboText(coTiAct2,config->readEntry("CommandActiveTitlebar2","Lower").ascii()); setComboText(coTiAct3,config->readEntry("CommandActiveTitlebar3","Operations menu").ascii()); + setComboText(coTiAct4,config->readEntry("CommandTitlebarWheel","Nothing").ascii()); setComboText(coTiInAct1,config->readEntry("CommandInactiveTitlebar1","Activate and raise").ascii()); setComboText(coTiInAct2,config->readEntry("CommandInactiveTitlebar2","Activate and lower").ascii()); setComboText(coTiInAct3,config->readEntry("CommandInactiveTitlebar3","Operations menu").ascii()); @@ -504,6 +556,7 @@ void KTitleBarActionsConfig::save() config->writeEntry("CommandActiveTitlebar2", functionTiAc(coTiAct2->currentItem())); config->writeEntry("CommandActiveTitlebar3", functionTiAc(coTiAct3->currentItem())); config->writeEntry("CommandInactiveTitlebar1", functionTiInAc(coTiInAct1->currentItem())); + config->writeEntry("CommandTitlebarWheel", functionTiWAc(coTiAct4->currentItem())); config->writeEntry("CommandInactiveTitlebar2", functionTiInAc(coTiInAct2->currentItem())); config->writeEntry("CommandInactiveTitlebar3", functionTiInAc(coTiInAct3->currentItem())); @@ -522,6 +575,7 @@ void KTitleBarActionsConfig::defaults() setComboText(coTiAct1,"Raise"); setComboText(coTiAct2,"Lower"); setComboText(coTiAct3,"Operations menu"); + setComboText(coTiAct4,"Nothing"); setComboText(coTiInAct1,"Activate and raise"); setComboText(coTiInAct2,"Activate and lower"); setComboText(coTiInAct3,"Operations menu"); @@ -533,7 +587,7 @@ void KTitleBarActionsConfig::defaults() KWindowActionsConfig::KWindowActionsConfig (bool _standAlone, KConfig *_config, QWidget * parent, const char *) : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone) { - QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3; + QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3, strAllW; QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint()); QGrid *grid; QGroupBox *box; @@ -622,7 +676,7 @@ KWindowActionsConfig::KWindowActionsConfig (bool _standAlone, KConfig *_config, QWhatsThis::add( box, i18n("Here you can customize KDE's behavior when clicking somewhere into" " a window while pressing a modifier key.")); - grid = new QGrid(4, Qt::Vertical, box); + grid = new QGrid(5, Qt::Vertical, box); // Labels label = new QLabel(i18n("Modifier key:"), grid); @@ -657,6 +711,11 @@ KWindowActionsConfig::KWindowActionsConfig (bool _standAlone, KConfig *_config, label = new QLabel(strMouseButton3, grid); QWhatsThis::add( label, strAll3); + label = new QLabel(i18n("Modifier key + mouse wheel:"), grid); + strAllW = i18n("Here you can customize KDE's behavior when scrolling with the mouse wheel" + " in a window while pressing the modifier key."); + QWhatsThis::add( label, strAllW); + // Combo's combo = new QComboBox(grid); combo->insertItem(i18n("Meta")); @@ -693,6 +752,18 @@ KWindowActionsConfig::KWindowActionsConfig (bool _standAlone, KConfig *_config, coAll3 = combo; QWhatsThis::add( combo, strAll3 ); + combo = new QComboBox(grid); + combo->insertItem(i18n("Raise/Lower")); + combo->insertItem(i18n("Shade/Unshade")); + combo->insertItem(i18n("Maximize/Restore")); + combo->insertItem(i18n("Keep Above/Below")); + combo->insertItem(i18n("Move to Previous/Next Desktop")); + combo->insertItem(i18n("Change Opacity")); + combo->insertItem(i18n("Nothing")); + connect(combo, SIGNAL(activated(int)), SLOT(changed())); + coAllW = combo; + QWhatsThis::add( combo, strAllW ); + layout->addStretch(); load(); @@ -712,6 +783,8 @@ void KWindowActionsConfig::setComboText( QComboBox* combo, const char*txt ) combo->setCurrentItem( tbl_txt_lookup( tbl_AllKey, txt )); else if( combo == coAll1 || combo == coAll2 || combo == coAll3 ) combo->setCurrentItem( tbl_txt_lookup( tbl_All, txt )); + else if( combo == coAllW ) + combo->setCurrentItem( tbl_txt_lookup( tbl_AllW, txt )); else abort(); } @@ -731,6 +804,11 @@ const char* KWindowActionsConfig::functionAll( int i ) return tbl_num_lookup( tbl_All, i ); } +const char* KWindowActionsConfig::functionAllW(int i) +{ + return tbl_num_lookup( tbl_AllW, i ); +} + void KWindowActionsConfig::load() { config->setGroup( "MouseBindings"); @@ -741,6 +819,7 @@ void KWindowActionsConfig::load() setComboText(coAll1,config->readEntry("CommandAll1","Move").ascii()); setComboText(coAll2,config->readEntry("CommandAll2","Toggle raise and lower").ascii()); setComboText(coAll3,config->readEntry("CommandAll3","Resize").ascii()); + setComboText(coAllW,config->readEntry("CommandAllWheel","Nothing").ascii()); } void KWindowActionsConfig::save() @@ -753,6 +832,7 @@ void KWindowActionsConfig::save() config->writeEntry("CommandAll1", functionAll(coAll1->currentItem())); config->writeEntry("CommandAll2", functionAll(coAll2->currentItem())); config->writeEntry("CommandAll3", functionAll(coAll3->currentItem())); + config->writeEntry("CommandAllWheel", functionAllW(coAllW->currentItem())); if (standAlone) { @@ -772,4 +852,5 @@ void KWindowActionsConfig::defaults() setComboText (coAll1,"Move"); setComboText(coAll2,"Toggle raise and lower"); setComboText(coAll3,"Resize"); + setComboText(coAllW,"Nothing"); } diff --git a/kcmkwin/kwinoptions/mouse.h b/kcmkwin/kwinoptions/mouse.h index 2eb31b2e69..33d4c790c8 100644 --- a/kcmkwin/kwinoptions/mouse.h +++ b/kcmkwin/kwinoptions/mouse.h @@ -70,6 +70,7 @@ private: QComboBox* coTiAct1; QComboBox* coTiAct2; QComboBox* coTiAct3; + QComboBox* coTiAct4; QComboBox* coTiInAct1; QComboBox* coTiInAct2; QComboBox* coTiInAct3; @@ -81,6 +82,7 @@ private: const char* functionTiDbl(int); const char* functionTiAc(int); + const char* functionTiWAc(int); const char* functionTiInAc(int); const char* functionMax(int); @@ -117,6 +119,7 @@ private: QComboBox* coAll1; QComboBox* coAll2; QComboBox* coAll3; + QComboBox* coAllW; KConfig *config; bool standAlone; @@ -124,6 +127,7 @@ private: const char* functionWin(int); const char* functionAllKey(int); const char* functionAll(int); + const char* functionAllW(int); void setComboText(QComboBox* combo, const char* text); const char* fixup( const char* s ); diff --git a/lib/kcommondecoration.cpp b/lib/kcommondecoration.cpp index ba5a8a3f41..344ea1380d 100644 --- a/lib/kcommondecoration.cpp +++ b/lib/kcommondecoration.cpp @@ -29,7 +29,7 @@ #include #include -// #include +#include #include #include @@ -694,6 +694,13 @@ void KCommonDecoration::mouseDoubleClickEvent(QMouseEvent *e) titlebarDblClickOperation(); } +void KCommonDecoration::wheelEvent(QWheelEvent *e) +{ + int tb = layoutMetric(LM_TitleEdgeTop)+layoutMetric(LM_TitleHeight)+layoutMetric(LM_TitleEdgeBottom); + if (isSetShade() || e->pos().y() <= tb ) + titlebarMouseWheelOperation( e->delta()); +} + KCommonDecoration::Position KCommonDecoration::mousePosition(const QPoint &point) const { const int corner = 18+3*layoutMetric(LM_BorderBottom, false)/2; @@ -827,6 +834,9 @@ bool KCommonDecoration::eventFilter( QObject* o, QEvent* e ) case QEvent::MouseButtonPress: processMousePressEvent( static_cast< QMouseEvent* >( e )); return true; + case QEvent::Wheel: + wheelEvent( static_cast< QWheelEvent* >( e )); + return true; default: return false; } diff --git a/lib/kcommondecoration.h b/lib/kcommondecoration.h index 28de313a18..80b30548cb 100644 --- a/lib/kcommondecoration.h +++ b/lib/kcommondecoration.h @@ -255,6 +255,7 @@ class KWIN_EXPORT KCommonDecoration : public KDecoration virtual bool eventFilter( QObject* o, QEvent* e ); virtual void resizeEvent(QResizeEvent *e); virtual void mouseDoubleClickEvent(QMouseEvent *e); + virtual void wheelEvent(QWheelEvent *e); private: void resetLayout(); diff --git a/lib/kdecoration.cpp b/lib/kdecoration.cpp index 1b367a7d85..c7b3d69291 100644 --- a/lib/kdecoration.cpp +++ b/lib/kdecoration.cpp @@ -274,6 +274,11 @@ void KDecoration::titlebarDblClickOperation() bridge_->titlebarDblClickOperation(); } +void KDecoration::titlebarMouseWheelOperation( int delta ) + { + bridge_->titlebarMouseWheelOperation( delta ); + } + void KDecoration::setShade( bool set ) { bridge_->setShade( set ); diff --git a/lib/kdecoration.h b/lib/kdecoration.h index a3a082eb51..eae4622a34 100644 --- a/lib/kdecoration.h +++ b/lib/kdecoration.h @@ -796,6 +796,13 @@ class KWIN_EXPORT KDecoration * operation. */ void titlebarDblClickOperation(); + /** + * This function performs the operation configured as titlebar wheel mouse + * operation. + * @param delta the mouse wheel delta + * @since 3.5 + */ + void titlebarMouseWheelOperation( int delta ); /** * Shades or unshades the decorated window. * @param set Whether the window should be shaded diff --git a/lib/kdecoration_p.h b/lib/kdecoration_p.h index a864ca47a2..8d0e5e15af 100644 --- a/lib/kdecoration_p.h +++ b/lib/kdecoration_p.h @@ -96,6 +96,7 @@ class KDecorationBridge : public KDecorationDefines virtual void showContextHelp() = 0; virtual void setDesktop( int desktop ) = 0; virtual void titlebarDblClickOperation() = 0; + virtual void titlebarMouseWheelOperation( int delta ) = 0; virtual void setShade( bool set ) = 0; virtual void setKeepAbove( bool ) = 0; virtual void setKeepBelow( bool ) = 0; diff --git a/options.cpp b/options.cpp index e523e505b3..e3bba65aa3 100644 --- a/options.cpp +++ b/options.cpp @@ -160,6 +160,7 @@ unsigned long Options::updateSettings() CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true ); CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true ); CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true ); + CmdTitlebarWheel = mouseWheelCommand(config->readEntry("CommandTitlebarWheel","Nothing")); CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false ); CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false ); CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false ); @@ -167,6 +168,7 @@ unsigned long Options::updateSettings() CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false ); CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false ); CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false ); + CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing")); //translucency settings config->setGroup( "Notification Messages" ); @@ -266,6 +268,18 @@ Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted return MouseNothing; } +Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name) + { + QString lowerName = name.lower(); + if (lowerName == "raise/lower") return MouseWheelRaiseLower; + if (lowerName == "shade/unshade") return MouseWheelShadeUnshade; + if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore; + if (lowerName == "above/below") return MouseWheelAboveBelow; + if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop; + if (lowerName == "change opacity") return MouseWheelChangeOpacity; + return MouseWheelNothing; + } + bool Options::showGeometryTip() { return show_geometry_tip; @@ -285,6 +299,27 @@ bool Options::checkIgnoreFocusStealing( const Client* c ) { return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass())); } + +Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta ) + { + switch( com ) + { + case MouseWheelRaiseLower: + return delta > 0 ? MouseRaise : MouseLower; + case MouseWheelShadeUnshade: + return delta > 0 ? MouseSetShade : MouseUnsetShade; + case MouseWheelMaximizeRestore: + return delta > 0 ? MouseMaximize : MouseRestore; + case MouseWheelAboveBelow: + return delta > 0 ? MouseAbove : MouseBelow; + case MouseWheelPreviousNextDesktop: + return delta > 0 ? MousePreviousDesktop : MouseNextDesktop; + case MouseWheelChangeOpacity: + return delta > 0 ? MouseOpacityMore : MouseOpacityLess; + default: + return MouseNothing; + } + } #endif Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s ) diff --git a/options.h b/options.h index e6526a4c65..da4836905f 100644 --- a/options.h +++ b/options.h @@ -208,10 +208,30 @@ class Options : public KDecorationOptions MouseMove, MouseUnrestrictedMove, MouseActivateRaiseAndMove, MouseActivateRaiseAndUnrestrictedMove, MouseResize, MouseUnrestrictedResize, - MouseShade, - MouseMinimize, + MouseShade, MouseSetShade, MouseUnsetShade, + MouseMaximize, MouseRestore, MouseMinimize, + MouseNextDesktop, MousePreviousDesktop, + MouseAbove, MouseBelow, + MouseOpacityMore, MouseOpacityLess, MouseNothing }; + + enum MouseWheelCommand + { + MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore, + MouseWheelAboveBelow, MouseWheelPreviousNextDesktop, + MouseWheelChangeOpacity, + MouseWheelNothing + }; + + MouseCommand operationTitlebarMouseWheel( int delta ) + { + return wheelToMouseCommand( CmdTitlebarWheel, delta ); + } + MouseCommand operationWindowMouseWheel( int delta ) + { + return wheelToMouseCommand( CmdAllWheel, delta ); + } MouseCommand commandActiveTitlebar1() { return CmdActiveTitlebar1; } MouseCommand commandActiveTitlebar2() { return CmdActiveTitlebar2; } @@ -230,6 +250,7 @@ class Options : public KDecorationOptions static WindowOperation windowOperation(const QString &name, bool restricted ); static MouseCommand mouseCommand(const QString &name, bool restricted ); + static MouseWheelCommand mouseWheelCommand(const QString &name); /** * @returns true if the Geometry Tip should be shown during a window move/resize. @@ -285,12 +306,14 @@ class Options : public KDecorationOptions MouseCommand CmdInactiveTitlebar1; MouseCommand CmdInactiveTitlebar2; MouseCommand CmdInactiveTitlebar3; + MouseWheelCommand CmdTitlebarWheel; MouseCommand CmdWindow1; MouseCommand CmdWindow2; MouseCommand CmdWindow3; MouseCommand CmdAll1; MouseCommand CmdAll2; MouseCommand CmdAll3; + MouseWheelCommand CmdAllWheel; uint CmdAllModKey; int electric_borders; @@ -300,7 +323,8 @@ class Options : public KDecorationOptions bool desktop_topmenu; // List of window classes for which not to use focus stealing prevention QStringList ignoreFocusStealingClasses; - + + MouseCommand wheelToMouseCommand( MouseWheelCommand com, int delta ); }; extern Options* options; diff --git a/useractions.cpp b/useractions.cpp index 7b8a73cb1c..a9d3ad1472 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -379,6 +379,8 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) case Options::VMaximizeOp: c->maximize( c->maximizeMode() ^ Client::MaximizeVertical ); break; + case Options::RestoreOp: + c->maximize( Client::MaximizeRestore ); case Options::MinimizeOp: c->minimize(); break; @@ -412,6 +414,9 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) lowerClient( c ); break; } + case Options::OperationsOp: + c->performMouseCommand( Options::MouseShade, QCursor::pos()); + break; case Options::WindowRulesOp: editWindowRules( c ); break; @@ -421,7 +426,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) case Options::LowerOp: lowerClient(c); break; - default: + case Options::NoOp: break; } } @@ -441,9 +446,16 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo workspace()->lowerClient( this ); break; case Options::MouseShade : - delete shadeHoverTimer; - shadeHoverTimer = 0; toggleShade(); + cancelShadeHover(); + break; + case Options::MouseSetShade: + setShade( ShadeNormal ); + cancelShadeHover(); + break; + case Options::MouseUnsetShade: + setShade( ShadeNone ); + cancelShadeHover(); break; case Options::MouseOperationsMenu: if ( isActive() & options->clickRaise ) @@ -531,12 +543,62 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo } break; } + case Options::MouseMaximize: + maximize( Client::MaximizeFull ); + break; + case Options::MouseRestore: + maximize( Client::MaximizeRestore ); + break; case Options::MouseMinimize: minimize(); break; + case Options::MouseAbove: + { + StackingUpdatesBlocker blocker( workspace()); + if( keepBelow()) + setKeepBelow( false ); + else + setKeepAbove( true ); + break; + } + case Options::MouseBelow: + { + StackingUpdatesBlocker blocker( workspace()); + if( keepAbove()) + setKeepAbove( false ); + else + setKeepBelow( true ); + break; + } + case Options::MousePreviousDesktop: + workspace()->windowToPreviousDesktop( this ); + break; + case Options::MouseNextDesktop: + workspace()->windowToNextDesktop( this ); + break; + case Options::MouseOpacityMore: + if (opacity_ < 0xFFFFFFFF) + { + if (opacity_ < 0xF3333333) + { + setOpacity(TRUE, opacity_ + 0xCCCCCCC); + custom_opacity = true; + } + else + { + setOpacity(FALSE, 0xFFFFFFFF); + custom_opacity = false; + } + } + break; + case Options::MouseOpacityLess: + if (opacity_ > 0) + { + setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0); + custom_opacity = true; + } + break; case Options::MouseNothing: - // fall through - default: replay = TRUE; break; } @@ -757,11 +819,15 @@ void Workspace::slotSetupWindowShortcut() Move window to next desktop */ void Workspace::slotWindowToNextDesktop() + { + windowToNextDesktop( active_popup_client ? active_popup_client : active_client ); + } + +void Workspace::windowToNextDesktop( Client* c ) { int d = currentDesktop() + 1; if ( d > numberOfDesktops() ) d = 1; - Client* c = active_popup_client ? active_popup_client : active_client; if (c && !c->isDesktop() && !c->isDock() && !c->isTopMenu()) { @@ -775,11 +841,15 @@ void Workspace::slotWindowToNextDesktop() Move window to previous desktop */ void Workspace::slotWindowToPreviousDesktop() + { + windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client ); + } + +void Workspace::windowToPreviousDesktop( Client* c ) { int d = currentDesktop() - 1; if ( d <= 0 ) d = numberOfDesktops(); - Client* c = active_popup_client ? active_popup_client : active_client; if (c && !c->isDesktop() && !c->isDock() && !c->isTopMenu()) { diff --git a/workspace.h b/workspace.h index 804c35d6bc..b436ea59b3 100644 --- a/workspace.h +++ b/workspace.h @@ -183,6 +183,8 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine Client* topClientOnDesktop( int desktop, bool unconstrained = false ) const; Client* findDesktop( bool topmost, int desktop ) const; void sendClientToDesktop( Client* c, int desktop, bool dont_activate ); + void windowToPreviousDesktop( Client* c ); + void windowToNextDesktop( Client* c ); // KDE4 remove me - and it's also in the DCOP interface :( void showWindowMenuAt( unsigned long id, int x, int y );