Changeset View
Changeset View
Standalone View
Standalone View
kdecoration/breezesizegrip.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 54 | setMask( QRegion( QVector<QPoint>{ | |||
---|---|---|---|---|---|
57 | QPoint( GripSize, GripSize ), | 57 | QPoint( GripSize, GripSize ), | ||
58 | QPoint( 0, GripSize )} ) ); | 58 | QPoint( 0, GripSize )} ) ); | ||
59 | 59 | | |||
60 | // embed | 60 | // embed | ||
61 | embed(); | 61 | embed(); | ||
62 | updatePosition(); | 62 | updatePosition(); | ||
63 | 63 | | |||
64 | // connections | 64 | // connections | ||
65 | auto c = decoration->client().data(); | 65 | auto c = decoration->client().toStrongRef().data(); | ||
66 | connect( c, &KDecoration2::DecoratedClient::widthChanged, this, &SizeGrip::updatePosition ); | 66 | connect( c, &KDecoration2::DecoratedClient::widthChanged, this, &SizeGrip::updatePosition ); | ||
67 | connect( c, &KDecoration2::DecoratedClient::heightChanged, this, &SizeGrip::updatePosition ); | 67 | connect( c, &KDecoration2::DecoratedClient::heightChanged, this, &SizeGrip::updatePosition ); | ||
68 | connect( c, &KDecoration2::DecoratedClient::activeChanged, this, &SizeGrip::updateActiveState ); | 68 | connect( c, &KDecoration2::DecoratedClient::activeChanged, this, &SizeGrip::updateActiveState ); | ||
69 | 69 | | |||
70 | // show | 70 | // show | ||
71 | show(); | 71 | show(); | ||
72 | 72 | | |||
73 | } | 73 | } | ||
Show All 20 Lines | |||||
94 | 94 | | |||
95 | //_____________________________________________ | 95 | //_____________________________________________ | ||
96 | void SizeGrip::embed() | 96 | void SizeGrip::embed() | ||
97 | { | 97 | { | ||
98 | 98 | | |||
99 | #if BREEZE_HAVE_X11 | 99 | #if BREEZE_HAVE_X11 | ||
100 | 100 | | |||
101 | if( !QX11Info::isPlatformX11() ) return; | 101 | if( !QX11Info::isPlatformX11() ) return; | ||
102 | auto c = m_decoration.data()->client().data(); | 102 | auto c = m_decoration.data()->client().toStrongRef().data(); | ||
103 | 103 | | |||
104 | xcb_window_t windowId = c->windowId(); | 104 | xcb_window_t windowId = c->windowId(); | ||
105 | if( windowId ) | 105 | if( windowId ) | ||
106 | { | 106 | { | ||
107 | 107 | | |||
108 | /* | 108 | /* | ||
109 | find client's parent | 109 | find client's parent | ||
110 | we want the size grip to be at the same level as the client in the stack | 110 | we want the size grip to be at the same level as the client in the stack | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
186 | 186 | | |||
187 | //_______________________________________________________________________________ | 187 | //_______________________________________________________________________________ | ||
188 | void SizeGrip::updatePosition() | 188 | void SizeGrip::updatePosition() | ||
189 | { | 189 | { | ||
190 | 190 | | |||
191 | #if BREEZE_HAVE_X11 | 191 | #if BREEZE_HAVE_X11 | ||
192 | if( !QX11Info::isPlatformX11() ) return; | 192 | if( !QX11Info::isPlatformX11() ) return; | ||
193 | 193 | | |||
194 | auto c = m_decoration.data()->client().data(); | 194 | auto c = m_decoration.data()->client().toStrongRef().data(); | ||
195 | QPoint position( | 195 | QPoint position( | ||
196 | c->width() - GripSize - Offset, | 196 | c->width() - GripSize - Offset, | ||
197 | c->height() - GripSize - Offset ); | 197 | c->height() - GripSize - Offset ); | ||
198 | 198 | | |||
199 | quint32 values[2] = { quint32(position.x()), quint32(position.y()) }; | 199 | quint32 values[2] = { quint32(position.x()), quint32(position.y()) }; | ||
200 | xcb_configure_window( QX11Info::connection(), winId(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values ); | 200 | xcb_configure_window( QX11Info::connection(), winId(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values ); | ||
201 | #endif | 201 | #endif | ||
202 | 202 | | |||
203 | } | 203 | } | ||
204 | 204 | | |||
205 | //_____________________________________________ | 205 | //_____________________________________________ | ||
206 | void SizeGrip::sendMoveResizeEvent( QPoint position ) | 206 | void SizeGrip::sendMoveResizeEvent( QPoint position ) | ||
207 | { | 207 | { | ||
208 | 208 | | |||
209 | #if BREEZE_HAVE_X11 | 209 | #if BREEZE_HAVE_X11 | ||
210 | if( !QX11Info::isPlatformX11() ) return; | 210 | if( !QX11Info::isPlatformX11() ) return; | ||
211 | 211 | | |||
212 | // pointer to connection | 212 | // pointer to connection | ||
213 | auto connection( QX11Info::connection() ); | 213 | auto connection( QX11Info::connection() ); | ||
214 | 214 | | |||
215 | // client | 215 | // client | ||
216 | auto c = m_decoration.data()->client().data(); | 216 | auto c = m_decoration.data()->client().toStrongRef().data(); | ||
217 | 217 | | |||
218 | /* | 218 | /* | ||
219 | get root position matching position | 219 | get root position matching position | ||
220 | need to use xcb because the embedding of the widget | 220 | need to use xcb because the embedding of the widget | ||
221 | breaks QT's mapToGlobal and other methods | 221 | breaks QT's mapToGlobal and other methods | ||
222 | */ | 222 | */ | ||
223 | QPoint rootPosition( position ); | 223 | QPoint rootPosition( position ); | ||
224 | xcb_get_geometry_cookie_t cookie( xcb_get_geometry( connection, winId() ) ); | 224 | xcb_get_geometry_cookie_t cookie( xcb_get_geometry( connection, winId() ) ); | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |