Skip to content

Force WindowCloseButtonHint for toplevel dialogs

Vlad Zahorodnii requested to merge work/zzag/toplevel-dialog-title-actions into master

Prior to 6f6603eb, the close button had been implicitly added by QtXCB. For example, if window flags contain only Qt::Dialog, QtXCB will set MWM_FUNC_ALL motif hints. So QtQuick dialogs used to get the close button even though there's no Qt::WinodwCloseButtonHint flag. QtWidgets dialogs usually always pass Qt::WindowCloseButtonHint flag.

After making kwin display minimize and maximize decoration buttons only if corresponding Motif hints are set, KDE applications that use windows with Dialog type lost their min/max buttons because QtWidgets code doesn't set those flags.

6f6603eb tried to fix that by making the platform integration theme force Qt::WindowMinimizeButtonHint and Qt::WindowMaximizeButtonHint flags. But it accidentally broke QtQuick dialogs since dialogs have additional flags besides Qt::Dialog now, so QtXCB has stopped setting MWM_FUNC_ALL hints anymore.

In order to address that, this patch changes a few things:

  • Make the platform theme be more careful about changing window flags. If user has explicitly changed window decoration flags, i.e. Qt::CustomizeWindowHint flag is set, don't touch decoration hints.
  • Merge Qt::WindowMaximizeButtonHint with Qt::WindowMinimizeButtonHint. If the window cannot be maximized, the window manager will hide the maximize button, so we can pass Qt::WindowMinMaxButtonHint. In some way, it's a breaking change as child dialogs may not have maximize button, but it's a weird case and maybe user code should be in control of that?
  • Forces Qt::WindowCloseButtonHint in addition to min/max button hints.

QtQuick child dialogs, i.e. transientParent() is not null, will get default decoration buttons.

BUG: 464193

Edited by Vlad Zahorodnii

Merge request reports

Loading