Skip to content

Commit

Permalink
Improve tooltip visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cproc committed May 2, 2024
1 parent d35dc7f commit fe81363
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 15 additions & 7 deletions qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,11 @@ Gui::Session::View_handle QGenodePlatformWindow::_create_view()
return _gui_session.create_view();

/*
* Popup menus should never get a window decoration, therefore we set a top
* level Qt window as 'transient parent'.
* Popup menus and tooltips should never get a window decoration,
* therefore we set a top level Qt window as 'transient parent'.
*/
if (!window()->transientParent() && (window()->type() == Qt::Popup)) {
if (!window()->transientParent() &&
((window()->type() == Qt::Popup) || (window()->type() == Qt::ToolTip))) {
QWindow *top_window = QGuiApplication::topLevelWindows().first();
window()->setTransientParent(top_window);
}
Expand All @@ -456,9 +457,18 @@ void QGenodePlatformWindow::_adjust_and_set_geometry(const QRect &rect)
{
QRect adjusted_rect(rect);

/* Currently, top level windows must start at (0,0) */
if (!window()->transientParent())
if (!window()->transientParent()) {
/* Currently, top level windows must start at (0,0) */
adjusted_rect.moveTo(0, 0);
} else if (window()->type() == Qt::ToolTip) {
/* improve tooltip visibility */
if (adjusted_rect.topLeft().y() + adjusted_rect.height() >
window()->transientParent()->geometry().height()) {
int dy = -adjusted_rect.height() -
(adjusted_rect.topLeft().y() - QCursor::pos().y());
adjusted_rect.translate(0, dy);
}
}

QPlatformWindow::setGeometry(adjusted_rect);

Expand Down Expand Up @@ -526,8 +536,6 @@ QGenodePlatformWindow::QGenodePlatformWindow(Genode::Env &env,
_view_handle(_create_view()),
_input_session(env.rm(), _gui_session.input_session()),
_ev_buf(env.rm(), _input_session.dataspace()),
_resize_handle(!window->flags().testFlag(Qt::Popup)),
_decoration(!window->flags().testFlag(Qt::Popup)),
_egl_display(egl_display),
_egl_surface(EGL_NO_SURFACE),
_input_signal_handler(_env.ep(), *this,
Expand Down
2 changes: 0 additions & 2 deletions qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class QGenodePlatformWindow : public QObject, public QPlatformWindow
Qt::KeyboardModifiers _keyboard_modifiers;
Qt::MouseButtons _mouse_button_state;
QByteArray _title;
bool _resize_handle;
bool _decoration;
EGLDisplay _egl_display;
EGLSurface _egl_surface;

Expand Down

0 comments on commit fe81363

Please sign in to comment.