Changeset View
Changeset View
Standalone View
Standalone View
input.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> | ||
6 | Copyright (C) 2018 Roman Gilg <subdiff@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 346 Lines • ▼ Show 20 Line(s) | 318 | public: | |||
360 | virtual bool swipeGestureCancelled(quint32 time); | 361 | virtual bool swipeGestureCancelled(quint32 time); | ||
361 | 362 | | |||
362 | virtual bool switchEvent(SwitchEvent *event); | 363 | virtual bool switchEvent(SwitchEvent *event); | ||
363 | 364 | | |||
364 | protected: | 365 | protected: | ||
365 | void passToWaylandServer(QKeyEvent *event); | 366 | void passToWaylandServer(QKeyEvent *event); | ||
366 | }; | 367 | }; | ||
367 | 368 | | |||
368 | class InputDeviceHandler : public QObject | 369 | class KWIN_EXPORT InputDeviceHandler : public QObject | ||
369 | { | 370 | { | ||
370 | Q_OBJECT | 371 | Q_OBJECT | ||
371 | public: | 372 | public: | ||
372 | virtual ~InputDeviceHandler(); | 373 | virtual ~InputDeviceHandler(); | ||
374 | virtual void init(); | ||||
373 | 375 | | |||
374 | QPointer<Toplevel> window() const { | 376 | void update(); | ||
375 | return m_window; | 377 | | ||
378 | /** | ||||
379 | * @brief First Toplevel currently at the position of the input device | ||||
380 | * according to the stacking order. | ||||
381 | * @return Toplevel* at device position. | ||||
382 | */ | ||||
383 | QPointer<Toplevel> at() const { | ||||
384 | return m_at; | ||||
385 | } | ||||
386 | /** | ||||
387 | * @brief Toplevel currently having pointer input focus (this might | ||||
388 | * be different from the Toplevel at the position of the pointer). | ||||
389 | * @return Toplevel* with pointer focus. | ||||
390 | */ | ||||
391 | QPointer<Toplevel> focus() const { | ||||
392 | return m_focus.focus; | ||||
376 | } | 393 | } | ||
394 | /** | ||||
395 | * @brief The Decoration currently receiving events. | ||||
396 | * @return decoration with pointer focus. | ||||
397 | **/ | ||||
377 | QPointer<Decoration::DecoratedClientImpl> decoration() const { | 398 | QPointer<Decoration::DecoratedClientImpl> decoration() const { | ||
378 | return m_decoration; | 399 | return m_focus.decoration; | ||
379 | } | 400 | } | ||
401 | /** | ||||
402 | * @brief The internal window currently receiving events. | ||||
403 | * @return QWindow with pointer focus. | ||||
404 | **/ | ||||
380 | QPointer<QWindow> internalWindow() const { | 405 | QPointer<QWindow> internalWindow() const { | ||
381 | return m_internalWindow; | 406 | return m_focus.internalWindow; | ||
382 | } | 407 | } | ||
383 | 408 | | |||
409 | virtual QPointF position() const = 0; | ||||
410 | | ||||
411 | void setFocus(Toplevel *toplevel); | ||||
412 | void setDecoration(QPointer<Decoration::DecoratedClientImpl> decoration); | ||||
413 | void setInternalWindow(QWindow *window); | ||||
414 | | ||||
384 | Q_SIGNALS: | 415 | Q_SIGNALS: | ||
416 | void atChanged(Toplevel *old, Toplevel *now); | ||||
385 | void decorationChanged(); | 417 | void decorationChanged(); | ||
386 | void internalWindowChanged(); | | |||
387 | 418 | | |||
388 | protected: | 419 | protected: | ||
389 | explicit InputDeviceHandler(InputRedirection *parent); | 420 | explicit InputDeviceHandler(InputRedirection *parent); | ||
390 | void updateDecoration(Toplevel *t, const QPointF &pos); | 421 | | ||
391 | void updateInternalWindow(const QPointF &pos); | 422 | virtual void cleanupInternalWindow(QWindow *old, QWindow *now) = 0; | ||
zzag: Really minor thing: can you please pick a different name? It's a method, thus it would be… | |||||
392 | void setWindow(QPointer<Toplevel> window = QPointer<Toplevel>()) { | 423 | virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0; | ||
393 | m_window = window; | 424 | | ||
425 | virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0; | ||||
426 | | ||||
427 | virtual bool focusUpdatesBlocked() { | ||||
428 | return false; | ||||
394 | } | 429 | } | ||
395 | void clearDecoration() { | 430 | | ||
396 | m_decoration.clear(); | 431 | inline bool inited() const { | ||
432 | return m_inited; | ||||
397 | } | 433 | } | ||
398 | void clearInternalWindow() { | 434 | inline void setInited(bool set) { | ||
399 | m_internalWindow.clear(); | 435 | m_inited = set; | ||
400 | } | 436 | } | ||
401 | 437 | | |||
402 | private: | 438 | private: | ||
403 | /** | 439 | bool setAt(Toplevel *toplevel); | ||
404 | * @brief The Toplevel which currently receives events | 440 | void updateFocus(); | ||
405 | */ | 441 | bool updateDecoration(); | ||
406 | QPointer<Toplevel> m_window; | 442 | void updateInternalWindow(QWindow *window); | ||
407 | /** | 443 | | ||
408 | * @brief The Decoration which currently receives events. | 444 | QWindow* findInternalWindow(const QPoint &pos) const; | ||
Minor nitpick: The name is confusing. It's not obvious that it uses the position() method. What about adding position parameter instead, e.g. QWindow *internalWindowAtPosition(const QPointF &pos) const; zzag: Minor nitpick: The name is confusing. It's not obvious that it uses the position() method. What… | |||||
409 | **/ | 445 | | ||
410 | QPointer<Decoration::DecoratedClientImpl> m_decoration; | 446 | QPointer<Toplevel> m_at; | ||
411 | QPointer<QWindow> m_internalWindow; | 447 | struct { | ||
448 | QPointer<Toplevel> focus; | ||||
449 | QPointer<Decoration::DecoratedClientImpl> decoration; | ||||
450 | QPointer<QWindow> internalWindow; | ||||
451 | } m_focus; | ||||
452 | | ||||
453 | bool m_inited = false; | ||||
412 | }; | 454 | }; | ||
413 | 455 | | |||
414 | inline | 456 | inline | ||
415 | InputRedirection *input() | 457 | InputRedirection *input() | ||
416 | { | 458 | { | ||
417 | return InputRedirection::s_self; | 459 | return InputRedirection::s_self; | ||
418 | } | 460 | } | ||
419 | 461 | | |||
Show All 14 Lines |
Really minor thing: can you please pick a different name? It's a method, thus it would be better to use imperative mood.