#include "config.h"
#include "tray/UserModel.h"
+#include <QCursor>
#include <QDesktopServices>
#include <QGuiApplication>
#include <QQmlComponent>
int screenHeight = trayScreen->geometry().height();
int availableWidth = trayScreen->availableGeometry().width();
int availableHeight = trayScreen->availableGeometry().height();
- QPoint topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
- QPoint topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
- // get coordinates from top center point of tray icon
+ QPoint topRightDpiAware = QPoint();
+ QPoint topLeftDpiAware = QPoint();
+ if (this->geometry().left() == 0 || this->geometry().top() == 0) {
+ // tray geometry is invalid - QT bug on some linux desktop environments
+ // Use mouse position instead. Cringy, but should work for now
+ topRightDpiAware = QCursor::pos() / trayScreen->devicePixelRatio();
+ topLeftDpiAware = QCursor::pos() / trayScreen->devicePixelRatio();
+ } else {
+ topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
+ topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
+ }
+
+ // get x coordinate from top center point of tray icon
int trayIconTopCenterX = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).x();
- int trayIconTopCenterY = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).y();
if (availableHeight < screenHeight) {
// taskbar is on top or bottom
int screenWidth = trayScreen->geometry().width();
int screenHeight = trayScreen->geometry().height();
int availableHeight = trayScreen->availableGeometry().height();
- QPoint topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
- QPoint topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
- // get coordinates from top center point of tray icon
- int trayIconTopCenterX = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).x();
+ QPoint topRightDpiAware = QPoint();
+ QPoint topLeftDpiAware = QPoint();
+ if (this->geometry().left() == 0 || this->geometry().top() == 0) {
+ // tray geometry is invalid - QT bug on some linux desktop environments
+ // Use mouse position instead. Cringy, but should work for now
+ topRightDpiAware = QCursor::pos() / trayScreen->devicePixelRatio();
+ topLeftDpiAware = QCursor::pos() / trayScreen->devicePixelRatio();
+ } else {
+ topRightDpiAware = this->geometry().topRight() / trayScreen->devicePixelRatio();
+ topLeftDpiAware = this->geometry().topLeft() / trayScreen->devicePixelRatio();
+ }
+ // get y coordinate from top center point of tray icon
int trayIconTopCenterY = (topRightDpiAware - ((topRightDpiAware - topLeftDpiAware) * 0.5)).y();
if (availableHeight < screenHeight) {