Changeset View
Changeset View
Standalone View
Standalone View
kdecoration/config/breezedetectwidget.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 67 | #endif | |||
---|---|---|---|---|---|
105 | 105 | | |||
106 | //_________________________________________________________ | 106 | //_________________________________________________________ | ||
107 | void DetectDialog::selectWindow() | 107 | void DetectDialog::selectWindow() | ||
108 | { | 108 | { | ||
109 | 109 | | |||
110 | // use a dialog, so that all user input is blocked | 110 | // use a dialog, so that all user input is blocked | ||
111 | // use WX11BypassWM and moving away so that it's not actually visible | 111 | // use WX11BypassWM and moving away so that it's not actually visible | ||
112 | // grab only mouse, so that keyboard can be used e.g. for switching windows | 112 | // grab only mouse, so that keyboard can be used e.g. for switching windows | ||
113 | m_grabber = new QDialog( 0, Qt::X11BypassWindowManagerHint ); | 113 | m_grabber = new QDialog( nullptr, Qt::X11BypassWindowManagerHint ); | ||
114 | m_grabber->move( -1000, -1000 ); | 114 | m_grabber->move( -1000, -1000 ); | ||
115 | m_grabber->setModal( true ); | 115 | m_grabber->setModal( true ); | ||
116 | m_grabber->show(); | 116 | m_grabber->show(); | ||
117 | 117 | | |||
118 | // need to explicitly override cursor for Qt5 | 118 | // need to explicitly override cursor for Qt5 | ||
119 | qApp->setOverrideCursor( Qt::CrossCursor ); | 119 | qApp->setOverrideCursor( Qt::CrossCursor ); | ||
120 | m_grabber->grabMouse( Qt::CrossCursor ); | 120 | m_grabber->grabMouse( Qt::CrossCursor ); | ||
121 | m_grabber->installEventFilter( this ); | 121 | m_grabber->installEventFilter( this ); | ||
122 | 122 | | |||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | //_________________________________________________________ | 125 | //_________________________________________________________ | ||
126 | bool DetectDialog::eventFilter( QObject* o, QEvent* e ) | 126 | bool DetectDialog::eventFilter( QObject* o, QEvent* e ) | ||
127 | { | 127 | { | ||
128 | // check object and event type | 128 | // check object and event type | ||
129 | if( o != m_grabber ) return false; | 129 | if( o != m_grabber ) return false; | ||
130 | if( e->type() != QEvent::MouseButtonRelease ) return false; | 130 | if( e->type() != QEvent::MouseButtonRelease ) return false; | ||
131 | 131 | | |||
132 | // need to explicitely release cursor for Qt5 | 132 | // need to explicitely release cursor for Qt5 | ||
133 | qApp->restoreOverrideCursor(); | 133 | qApp->restoreOverrideCursor(); | ||
134 | 134 | | |||
135 | // delete old m_grabber | 135 | // delete old m_grabber | ||
136 | delete m_grabber; | 136 | delete m_grabber; | ||
137 | m_grabber = 0; | 137 | m_grabber = nullptr; | ||
138 | 138 | | |||
139 | // check button | 139 | // check button | ||
140 | if( static_cast< QMouseEvent* >( e )->button() != Qt::LeftButton ) return true; | 140 | if( static_cast< QMouseEvent* >( e )->button() != Qt::LeftButton ) return true; | ||
141 | 141 | | |||
142 | // read window information | 142 | // read window information | ||
143 | readWindow( findWindow() ); | 143 | readWindow( findWindow() ); | ||
144 | 144 | | |||
145 | return true; | 145 | return true; | ||
Show All 39 Lines |