Guidelines and HOWTOs/Wayland Porting Notes: Difference between revisions

From KDE Community Wiki
(Introduce page)
 
(Porting notes for popup menus)
Line 1: Line 1:
This documents contains porting notes for Wayland.
This documents contains porting notes for Wayland.
If you don't use the Plasma Wayland session as your daily driver, you can still test the behavior of your application on Wayland and fix the bugs. Check the [[KWin/Wayland]] wiki page and also [https://blog.martin-graesslin.com/blog/2015/07/porting-qt-applications-to-wayland/ this blog post] by Martin.
If you don't use the Plasma Wayland session as your daily driver, you can still test the behavior of your application on Wayland and fix the bugs. Check the [[KWin/Wayland]] wiki page and also [https://blog.martin-graesslin.com/blog/2015/07/porting-qt-applications-to-wayland/ this blog post] by Martin.
= Popup Menus =
Chances are that many popup menus of your application will be misplaced on Wayland. This is because the compositor needs to know how to relate the QMenu's window with the main window of the application. This is done by setting a transient parent window on the QMenu. The easiest way to do so is ensuring that the menu is created with a parent widget:
<syntaxhighlight lang="cpp-qt">
// Don't
auto menu = new QMenu;
menu->popup(somePos);
// Do
auto menu = new QMenu(someParentWidget);
menu->popup(somePos);
// Don't
QMenu::exec(someActions, somePos);
// Do
QMenu::exec(someActions, somePos, nullptr, someParentWidget);
 
</syntaxhighlight>

Revision as of 08:27, 8 June 2017

This documents contains porting notes for Wayland. If you don't use the Plasma Wayland session as your daily driver, you can still test the behavior of your application on Wayland and fix the bugs. Check the KWin/Wayland wiki page and also this blog post by Martin.

Popup Menus

Chances are that many popup menus of your application will be misplaced on Wayland. This is because the compositor needs to know how to relate the QMenu's window with the main window of the application. This is done by setting a transient parent window on the QMenu. The easiest way to do so is ensuring that the menu is created with a parent widget:

// Don't
auto menu = new QMenu;
menu->popup(somePos);
// Do
auto menu = new QMenu(someParentWidget);
menu->popup(somePos);

// Don't
QMenu::exec(someActions, somePos);
// Do
QMenu::exec(someActions, somePos, nullptr, someParentWidget);