Fix tooltip & popup positioning (#4740)

* Fix tooltip & popup positioning

This tries to ensure the tooltip & popups are created on the correct
monitor

* Add changelog entry

* Clean up debug output

* Use the full frame geometry to figure out screen bound movements

* Remove the now-unused `setStayInScreenRect` function

* Change the UserInfoPopup offset to be based on its width & height
instead

* Remove more debug output
This commit is contained in:
pajlada
2023-08-05 13:22:37 +02:00
committed by GitHub
parent b98be3b0f3
commit 9e2eb0dd29
11 changed files with 63 additions and 54 deletions
+19 -7
View File
@@ -36,6 +36,17 @@ public:
DisableLayoutSave = 128,
};
enum class BoundsChecker {
// Don't attempt to do any "stay in screen" stuff, just move me!
Off,
// Attempt to keep the window within bounds of the screen the cursor is on
CursorPosition,
// Attempt to keep the window within bounds of the screen the desired position is on
DesiredPosition,
};
enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
explicit BaseWindow(FlagsEnum<Flags> flags_ = None,
@@ -51,15 +62,12 @@ public:
std::function<void()> onClicked);
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
void setStayInScreenRect(bool value);
bool getStayInScreenRect() const;
void setActionOnFocusLoss(ActionOnFocusLoss value);
ActionOnFocusLoss getActionOnFocusLoss() const;
void moveTo(QWidget *widget, QPoint point, bool offset = true);
void moveTo(QPoint point, bool offset, BoundsChecker boundsChecker);
virtual float scale() const override;
float scale() const override;
float qtFontScale() const;
pajlada::Signals::NoArgSignal closing;
@@ -101,7 +109,12 @@ protected:
private:
void init();
void moveIntoDesktopRect(QPoint point);
/**
*
**/
void moveWithinScreen(QPoint point, QPoint origin);
void calcButtonsSizes();
void drawCustomWindowFrame(QPainter &painter);
void onFocusLost();
@@ -121,7 +134,6 @@ private:
bool enableCustomFrame_;
ActionOnFocusLoss actionOnFocusLoss_ = Nothing;
bool frameless_;
bool stayInScreenRect_ = false;
bool shown_ = false;
FlagsEnum<Flags> flags_;
float nativeScale_ = 1;