KCompletionBox popup gets full window decoration on Windows
Review Request #127424 - Created March 19, 2016 and submitted
|kdeframeworks, kdewin, kwin|
In https://git.reviewboard.kde.org/r/127191/ the KCompletionBox WindowFlags were change from Qt::ToolTip to Qt::Window.
As consequence, the completion popup of the Kate command line gets a full window decoration, which is obviously wrong, see attached screenshot.
Changing the type to Qt::Popup shows the proper popup, but key presses are not forwarded, so typing is not possible, and additionally, on losing focus the popup keeps staying open.
Therefore, this patch reverts the type back to Qt::ToolTip.
Better fixes are of course welcome ;) Any ideas?
Works on Windows as expected.
"Loose focus" is the complete wrong concept anyway.
It makes kickoff and various other plasmashell elements barely usable w/ any but the click-to-focus policy (implicit hide)
Try adding Qt::FramelessWindowHint (Qt::X11BypassWindowManagerHint should be Qt::BypassWindowManagerHint anyway)
PS: it's rather worrysome that Qt::Popup fails since it is set for the QComboBox dropdown. May point an implementation weakeness/bug in this class.
Finally found a solution:
We need to set the attribute Qt::WA_ShowWithoutActivating.
In addition, we need the Qt::FramelessWindowHint to avoid a window decoration.
And I also change X11BypassWindowManagerHint to Qt::BypassWindowManagerHint.
Qt::Popup will not work, since the popup by default sets the modality (according to Qt docs). This is also the reason why it works for QComboBox: there, when the popup is visible, the QLineEdit never has focus. In KLineEdit this is different. KLineEdit's popup is automatically shown for completion, and the focus should be kept in KLineEdit. That's why Qt::Window is correct here.
With this background in mind, I even believe the comments above don't make much sense:
//we can't link to QXcbWindowFunctions::Combo
//also, q->setAttribute(Qt::WA_X11NetWmWindowTypeCombo); is broken in Qt xcb
Since KLineEdit's completion popup has essentially nothing to do with both code-wise and workflow-wise with QComboBox... So ok to remove this again, too?
I could also add the WindowFlag "Qt::WindowStaysOnTopHint", but since it also works as is, I've omitted this.
PS: I also have no idea what is meant by the comment "// calls setVisible, so must be done after initializations", imho this comment shoud be removed.
Revision 2 (+2 -1)
except that it's effectively an editable combobox? _NET_WM_WINDOW_TYPE_COMBO should be used on the windows that are popped up by combo boxes. An example is a window that appears below a text field with a list of suggested completions. This property is typically used on override-redirect windows.
Given the feedback I got, I will submit tomorrow (Friday), independent on whether I have a ship-it or not.
The patch is tested both on Windows and Linux, and imo correct (the changes are rather trivial now).
If you have objections, please raise them by tomorrow, or better yet, do a review - thanks.
PS: I am totally aware that typically a ship-it is the way to get a patch accepted, but I have the feeling this patch is not getting much attention, despite me trying to get input for days.