Changeset View
Changeset View
Standalone View
Standalone View
virtualdesktops.h
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | |||||
97 | class VirtualDesktopGrid | 97 | class VirtualDesktopGrid | ||
98 | { | 98 | { | ||
99 | public: | 99 | public: | ||
100 | VirtualDesktopGrid(); | 100 | VirtualDesktopGrid(); | ||
101 | ~VirtualDesktopGrid(); | 101 | ~VirtualDesktopGrid(); | ||
102 | void update(const QSize &size, Qt::Orientation orientation, const QVector<VirtualDesktop*> &desktops); | 102 | void update(const QSize &size, Qt::Orientation orientation, const QVector<VirtualDesktop*> &desktops); | ||
103 | /** | 103 | /** | ||
104 | * @returns The coords of desktop @a id in grid units. | 104 | * @returns The coords of desktop @a id in grid units. | ||
105 | */ | 105 | **/ | ||
106 | QPoint gridCoords(uint id) const; | 106 | QPoint gridCoords(uint id) const; | ||
107 | /** | 107 | /** | ||
108 | * @returns The coords of desktop @a vd in grid units. | 108 | * @returns The coords of desktop @a vd in grid units. | ||
109 | */ | 109 | **/ | ||
110 | QPoint gridCoords(VirtualDesktop *vd) const; | 110 | QPoint gridCoords(VirtualDesktop *vd) const; | ||
111 | /** | 111 | /** | ||
112 | * @returns The desktop at the point @a coords or 0 if no desktop exists at that | 112 | * @returns The desktop at the point @a coords or 0 if no desktop exists at that | ||
113 | * point. @a coords is to be in grid units. | 113 | * point. @a coords is to be in grid units. | ||
114 | */ | 114 | **/ | ||
115 | VirtualDesktop *at(const QPoint &coords) const; | 115 | VirtualDesktop *at(const QPoint &coords) const; | ||
116 | int width() const; | 116 | int width() const; | ||
117 | int height() const; | 117 | int height() const; | ||
118 | const QSize &size() const; | 118 | const QSize &size() const; | ||
119 | private: | 119 | private: | ||
120 | QSize m_size; | 120 | QSize m_size; | ||
121 | QVector<QVector<VirtualDesktop*>> m_grid; | 121 | QVector<QVector<VirtualDesktop*>> m_grid; | ||
122 | }; | 122 | }; | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 158 | public: | |||
168 | /** | 168 | /** | ||
169 | * @internal | 169 | * @internal | ||
170 | **/ | 170 | **/ | ||
171 | void setConfig(KSharedConfig::Ptr config); | 171 | void setConfig(KSharedConfig::Ptr config); | ||
172 | /** | 172 | /** | ||
173 | * @returns Total number of desktops currently in existence. | 173 | * @returns Total number of desktops currently in existence. | ||
174 | * @see setCount | 174 | * @see setCount | ||
175 | * @see countChanged | 175 | * @see countChanged | ||
176 | */ | 176 | **/ | ||
177 | uint count() const; | 177 | uint count() const; | ||
178 | /** | 178 | /** | ||
179 | * @returns the number of rows the layout has. | 179 | * @returns the number of rows the layout has. | ||
180 | * @see setRows | 180 | * @see setRows | ||
181 | * @see rowsChanged | 181 | * @see rowsChanged | ||
182 | */ | 182 | **/ | ||
183 | uint rows() const; | 183 | uint rows() const; | ||
184 | /** | 184 | /** | ||
185 | * @returns The ID of the current desktop. | 185 | * @returns The ID of the current desktop. | ||
186 | * @see setCurrent | 186 | * @see setCurrent | ||
187 | * @see currentChanged | 187 | * @see currentChanged | ||
188 | */ | 188 | **/ | ||
189 | uint current() const; | 189 | uint current() const; | ||
190 | /** | 190 | /** | ||
191 | * @returns The current desktop | 191 | * @returns The current desktop | ||
192 | * @see setCurrent | 192 | * @see setCurrent | ||
193 | * @see currentChanged | 193 | * @see currentChanged | ||
194 | **/ | 194 | **/ | ||
195 | VirtualDesktop *currentDesktop() const; | 195 | VirtualDesktop *currentDesktop() const; | ||
196 | /** | 196 | /** | ||
Show All 19 Lines | |||||
216 | /** | 216 | /** | ||
217 | * @returns The layout aware virtual desktop grid used by this manager. | 217 | * @returns The layout aware virtual desktop grid used by this manager. | ||
218 | **/ | 218 | **/ | ||
219 | const VirtualDesktopGrid &grid() const; | 219 | const VirtualDesktopGrid &grid() const; | ||
220 | 220 | | |||
221 | /** | 221 | /** | ||
222 | * @returns The ID of the desktop above desktop @a id. Wraps around to the bottom of | 222 | * @returns The ID of the desktop above desktop @a id. Wraps around to the bottom of | ||
223 | * the layout if @a wrap is set. If @a id is not set use the current one. | 223 | * the layout if @a wrap is set. If @a id is not set use the current one. | ||
224 | */ | 224 | **/ | ||
225 | uint above(uint id = 0, bool wrap = true) const; | 225 | uint above(uint id = 0, bool wrap = true) const; | ||
226 | /** | 226 | /** | ||
227 | * @returns The desktop above desktop @a desktop. Wraps around to the bottom of | 227 | * @returns The desktop above desktop @a desktop. Wraps around to the bottom of | ||
228 | * the layout if @a wrap is set. If @a desktop is @c null use the current one. | 228 | * the layout if @a wrap is set. If @a desktop is @c null use the current one. | ||
229 | */ | 229 | **/ | ||
230 | VirtualDesktop *above(VirtualDesktop *desktop, bool wrap = true) const; | 230 | VirtualDesktop *above(VirtualDesktop *desktop, bool wrap = true) const; | ||
231 | /** | 231 | /** | ||
232 | * @returns The ID of the desktop to the right of desktop @a id. Wraps around to the | 232 | * @returns The ID of the desktop to the right of desktop @a id. Wraps around to the | ||
233 | * left of the layout if @a wrap is set. If @a id is not set use the current one. | 233 | * left of the layout if @a wrap is set. If @a id is not set use the current one. | ||
234 | */ | 234 | **/ | ||
235 | uint toRight(uint id = 0, bool wrap = true) const; | 235 | uint toRight(uint id = 0, bool wrap = true) const; | ||
236 | /** | 236 | /** | ||
237 | * @returns The desktop to the right of desktop @a desktop. Wraps around to the | 237 | * @returns The desktop to the right of desktop @a desktop. Wraps around to the | ||
238 | * left of the layout if @a wrap is set. If @a desktop is @c null use the current one. | 238 | * left of the layout if @a wrap is set. If @a desktop is @c null use the current one. | ||
239 | */ | 239 | **/ | ||
240 | VirtualDesktop *toRight(VirtualDesktop *desktop, bool wrap = true) const; | 240 | VirtualDesktop *toRight(VirtualDesktop *desktop, bool wrap = true) const; | ||
241 | /** | 241 | /** | ||
242 | * @returns The ID of the desktop below desktop @a id. Wraps around to the top of the | 242 | * @returns The ID of the desktop below desktop @a id. Wraps around to the top of the | ||
243 | * layout if @a wrap is set. If @a id is not set use the current one. | 243 | * layout if @a wrap is set. If @a id is not set use the current one. | ||
244 | */ | 244 | **/ | ||
245 | uint below(uint id = 0, bool wrap = true) const; | 245 | uint below(uint id = 0, bool wrap = true) const; | ||
246 | /** | 246 | /** | ||
247 | * @returns The desktop below desktop @a desktop. Wraps around to the top of the | 247 | * @returns The desktop below desktop @a desktop. Wraps around to the top of the | ||
248 | * layout if @a wrap is set. If @a desktop is @c null use the current one. | 248 | * layout if @a wrap is set. If @a desktop is @c null use the current one. | ||
249 | */ | 249 | **/ | ||
250 | VirtualDesktop *below(VirtualDesktop *desktop, bool wrap = true) const; | 250 | VirtualDesktop *below(VirtualDesktop *desktop, bool wrap = true) const; | ||
251 | /** | 251 | /** | ||
252 | * @returns The ID of the desktop to the left of desktop @a id. Wraps around to the | 252 | * @returns The ID of the desktop to the left of desktop @a id. Wraps around to the | ||
253 | * right of the layout if @a wrap is set. If @a id is not set use the current one. | 253 | * right of the layout if @a wrap is set. If @a id is not set use the current one. | ||
254 | */ | 254 | **/ | ||
255 | uint toLeft(uint id = 0, bool wrap = true) const; | 255 | uint toLeft(uint id = 0, bool wrap = true) const; | ||
256 | /** | 256 | /** | ||
257 | * @returns The desktop to the left of desktop @a desktop. Wraps around to the | 257 | * @returns The desktop to the left of desktop @a desktop. Wraps around to the | ||
258 | * right of the layout if @a wrap is set. If @a desktop is @c null use the current one. | 258 | * right of the layout if @a wrap is set. If @a desktop is @c null use the current one. | ||
259 | */ | 259 | **/ | ||
260 | VirtualDesktop *toLeft(VirtualDesktop *desktop, bool wrap = true) const; | 260 | VirtualDesktop *toLeft(VirtualDesktop *desktop, bool wrap = true) const; | ||
261 | /** | 261 | /** | ||
262 | * @returns The desktop after the desktop @a desktop. Wraps around to the first | 262 | * @returns The desktop after the desktop @a desktop. Wraps around to the first | ||
263 | * desktop if @a wrap is set. If @a desktop is @c null use the current desktop. | 263 | * desktop if @a wrap is set. If @a desktop is @c null use the current desktop. | ||
264 | **/ | 264 | **/ | ||
265 | VirtualDesktop *next(VirtualDesktop *desktop = nullptr, bool wrap = true) const; | 265 | VirtualDesktop *next(VirtualDesktop *desktop = nullptr, bool wrap = true) const; | ||
266 | /** | 266 | /** | ||
267 | * @returns The desktop in front of the desktop @a desktop. Wraps around to the | 267 | * @returns The desktop in front of the desktop @a desktop. Wraps around to the | ||
Show All 21 Lines | |||||
289 | VirtualDesktop *desktopForId(const QByteArray &id) const; | 289 | VirtualDesktop *desktopForId(const QByteArray &id) const; | ||
290 | 290 | | |||
291 | /** | 291 | /** | ||
292 | * Create a new virtual desktop at the requested position. | 292 | * Create a new virtual desktop at the requested position. | ||
293 | * The difference with setCount is that setCount always adds new desktops at the end of the chain. The Id is automatically generated. | 293 | * The difference with setCount is that setCount always adds new desktops at the end of the chain. The Id is automatically generated. | ||
294 | * @param position The position of the desktop. It should be in range [0, count]. | 294 | * @param position The position of the desktop. It should be in range [0, count]. | ||
295 | * @param name The name for the new desktop, if empty the default name will be used. | 295 | * @param name The name for the new desktop, if empty the default name will be used. | ||
296 | * @returns the new VirtualDesktop, nullptr if we reached the maximum number of desktops | 296 | * @returns the new VirtualDesktop, nullptr if we reached the maximum number of desktops | ||
297 | */ | 297 | **/ | ||
298 | VirtualDesktop *createVirtualDesktop(uint position, const QString &name = QString()); | 298 | VirtualDesktop *createVirtualDesktop(uint position, const QString &name = QString()); | ||
299 | 299 | | |||
300 | /** | 300 | /** | ||
301 | * Remove the virtual desktop identified by id, if it exists | 301 | * Remove the virtual desktop identified by id, if it exists | ||
302 | * difference with setCount is that is possible to remove an arbitrary desktop, | 302 | * difference with setCount is that is possible to remove an arbitrary desktop, | ||
303 | * not only the last one. | 303 | * not only the last one. | ||
304 | * @param id the string id of the desktop to remove | 304 | * @param id the string id of the desktop to remove | ||
305 | */ | 305 | **/ | ||
306 | void removeVirtualDesktop(const QByteArray &id); | 306 | void removeVirtualDesktop(const QByteArray &id); | ||
307 | 307 | | |||
308 | /** | 308 | /** | ||
309 | * Updates the net root info for new number of desktops | 309 | * Updates the net root info for new number of desktops | ||
310 | **/ | 310 | **/ | ||
311 | void updateRootInfo(); | 311 | void updateRootInfo(); | ||
312 | 312 | | |||
313 | /** | 313 | /** | ||
314 | * @returns The maximum number of desktops that KWin supports. | 314 | * @returns The maximum number of desktops that KWin supports. | ||
315 | */ | 315 | **/ | ||
316 | static uint maximum(); | 316 | static uint maximum(); | ||
317 | 317 | | |||
318 | public Q_SLOTS: | 318 | public Q_SLOTS: | ||
319 | /** | 319 | /** | ||
320 | * Set the number of available desktops to @a count. This function overrides any previous | 320 | * Set the number of available desktops to @a count. This function overrides any previous | ||
321 | * grid layout. | 321 | * grid layout. | ||
322 | * There needs to be at least one virtual desktop and the new value is capped at the maximum | 322 | * There needs to be at least one virtual desktop and the new value is capped at the maximum | ||
323 | * number of desktops. A caller of this function cannot expect that the change has been applied. | 323 | * number of desktops. A caller of this function cannot expect that the change has been applied. | ||
324 | * It is the callers responsibility to either check the numberOfDesktops or connect to the | 324 | * It is the callers responsibility to either check the numberOfDesktops or connect to the | ||
325 | * countChanged signal. | 325 | * countChanged signal. | ||
326 | * | 326 | * | ||
327 | * In case the @ref current desktop is on a desktop higher than the new count, the current desktop | 327 | * In case the @ref current desktop is on a desktop higher than the new count, the current desktop | ||
328 | * is changed to be the new desktop with highest id. In that situation the signal desktopRemoved | 328 | * is changed to be the new desktop with highest id. In that situation the signal desktopRemoved | ||
329 | * is emitted. | 329 | * is emitted. | ||
330 | * @param count The new number of desktops to use | 330 | * @param count The new number of desktops to use | ||
331 | * @see count | 331 | * @see count | ||
332 | * @see maximum | 332 | * @see maximum | ||
333 | * @see countChanged | 333 | * @see countChanged | ||
334 | * @see desktopCreated | 334 | * @see desktopCreated | ||
335 | * @see desktopRemoved | 335 | * @see desktopRemoved | ||
336 | */ | 336 | **/ | ||
337 | void setCount(uint count); | 337 | void setCount(uint count); | ||
338 | /** | 338 | /** | ||
339 | * Set the current desktop to @a current. | 339 | * Set the current desktop to @a current. | ||
340 | * @returns True on success, false otherwise. | 340 | * @returns True on success, false otherwise. | ||
341 | * @see current | 341 | * @see current | ||
342 | * @see currentChanged | 342 | * @see currentChanged | ||
343 | * @see moveTo | 343 | * @see moveTo | ||
344 | */ | 344 | **/ | ||
345 | bool setCurrent(uint current); | 345 | bool setCurrent(uint current); | ||
346 | /** | 346 | /** | ||
347 | * Set the current desktop to @a current. | 347 | * Set the current desktop to @a current. | ||
348 | * @returns True on success, false otherwise. | 348 | * @returns True on success, false otherwise. | ||
349 | * @see current | 349 | * @see current | ||
350 | * @see currentChanged | 350 | * @see currentChanged | ||
351 | * @see moveTo | 351 | * @see moveTo | ||
352 | **/ | 352 | **/ | ||
353 | bool setCurrent(VirtualDesktop *current); | 353 | bool setCurrent(VirtualDesktop *current); | ||
354 | /** | 354 | /** | ||
355 | * Updates the layout to a new number of rows. The number of columns will be calculated accordingly | 355 | * Updates the layout to a new number of rows. The number of columns will be calculated accordingly | ||
356 | */ | 356 | **/ | ||
357 | void setRows(uint rows); | 357 | void setRows(uint rows); | ||
358 | /** | 358 | /** | ||
359 | * Called from within setCount() to ensure the desktop layout is still valid. | 359 | * Called from within setCount() to ensure the desktop layout is still valid. | ||
360 | */ | 360 | **/ | ||
361 | void updateLayout(); | 361 | void updateLayout(); | ||
362 | /** | 362 | /** | ||
363 | * @param enabled wrapping around borders for navigation in desktop layout | 363 | * @param enabled wrapping around borders for navigation in desktop layout | ||
364 | * @see isNavigationWrappingAround | 364 | * @see isNavigationWrappingAround | ||
365 | * @see navigationWrappingAroundChanged | 365 | * @see navigationWrappingAroundChanged | ||
366 | **/ | 366 | **/ | ||
367 | void setNavigationWrappingAround(bool enabled); | 367 | void setNavigationWrappingAround(bool enabled); | ||
368 | /** | 368 | /** | ||
Show All 11 Lines | 377 | Q_SIGNALS: | |||
380 | * @param previousCount The number of desktops prior to the change | 380 | * @param previousCount The number of desktops prior to the change | ||
381 | * @param newCount The new current number of desktops | 381 | * @param newCount The new current number of desktops | ||
382 | **/ | 382 | **/ | ||
383 | void countChanged(uint previousCount, uint newCount); | 383 | void countChanged(uint previousCount, uint newCount); | ||
384 | 384 | | |||
385 | /** | 385 | /** | ||
386 | * Signal when the number of rows in the layout changes | 386 | * Signal when the number of rows in the layout changes | ||
387 | * @param rows number of rows | 387 | * @param rows number of rows | ||
388 | */ | 388 | **/ | ||
389 | void rowsChanged(uint rows); | 389 | void rowsChanged(uint rows); | ||
390 | 390 | | |||
391 | /** | 391 | /** | ||
392 | * A new desktop has been created | 392 | * A new desktop has been created | ||
393 | * @param desktop the new just crated desktop | 393 | * @param desktop the new just crated desktop | ||
394 | */ | 394 | **/ | ||
395 | void desktopCreated(KWin::VirtualDesktop *desktop); | 395 | void desktopCreated(KWin::VirtualDesktop *desktop); | ||
396 | 396 | | |||
397 | /** | 397 | /** | ||
398 | * A desktop has been removed and is about to be deleted | 398 | * A desktop has been removed and is about to be deleted | ||
399 | * @param desktop the desktop that has been removed. | 399 | * @param desktop the desktop that has been removed. | ||
400 | * It's guaranteed to stil la valid pointer when the signal arrives, | 400 | * It's guaranteed to stil la valid pointer when the signal arrives, | ||
401 | * but it's about to be deleted. | 401 | * but it's about to be deleted. | ||
402 | */ | 402 | **/ | ||
403 | void desktopRemoved(KWin::VirtualDesktop *desktop); | 403 | void desktopRemoved(KWin::VirtualDesktop *desktop); | ||
404 | 404 | | |||
405 | /** | 405 | /** | ||
406 | * Signal emitted whenever the current desktop changes. | 406 | * Signal emitted whenever the current desktop changes. | ||
407 | * @param previousDesktop The virtual desktop changed from | 407 | * @param previousDesktop The virtual desktop changed from | ||
408 | * @param newDesktop The virtual desktop changed to | 408 | * @param newDesktop The virtual desktop changed to | ||
409 | **/ | 409 | **/ | ||
410 | void currentChanged(uint previousDesktop, uint newDesktop); | 410 | void currentChanged(uint previousDesktop, uint newDesktop); | ||
Show All 38 Lines | 422 | private Q_SLOTS: | |||
449 | /** | 449 | /** | ||
450 | * Slot for switch to desktop below action. | 450 | * Slot for switch to desktop below action. | ||
451 | **/ | 451 | **/ | ||
452 | void slotDown(); | 452 | void slotDown(); | ||
453 | 453 | | |||
454 | private: | 454 | private: | ||
455 | /** | 455 | /** | ||
456 | * Generate a desktop layout from EWMH _NET_DESKTOP_LAYOUT property parameters. | 456 | * Generate a desktop layout from EWMH _NET_DESKTOP_LAYOUT property parameters. | ||
457 | */ | 457 | **/ | ||
458 | void setNETDesktopLayout(Qt::Orientation orientation, uint width, uint height, int startingCorner); | 458 | void setNETDesktopLayout(Qt::Orientation orientation, uint width, uint height, int startingCorner); | ||
459 | /** | 459 | /** | ||
460 | * @returns A default name for the given @p desktop | 460 | * @returns A default name for the given @p desktop | ||
461 | **/ | 461 | **/ | ||
462 | QString defaultName(int desktop) const; | 462 | QString defaultName(int desktop) const; | ||
463 | /** | 463 | /** | ||
464 | * Creates all the global keyboard shortcuts for "Switch To Desktop n" actions. | 464 | * Creates all the global keyboard shortcuts for "Switch To Desktop n" actions. | ||
465 | **/ | 465 | **/ | ||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |