Jump to content

KWin/Screen Edges: Difference between revisions

From KDE Community Wiki
Mgraesslin (talk | contribs)
Screen edges wiki page for Aaron's refactoring
 
Mgraesslin (talk | contribs)
Documentation of the new implementation
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Screen Edges =
This provides a new protocol intended to be used by auto-hiding panels to make use of the centralized screen edges. To use it a Client can set an X11 property of type '''_KDE_NET_WM_SCREEN_EDGE_SHOW''' to KWin.


The screen edge utility is called "Electric Borders" in KWin's Workspace class. There are through the enum ElectricBorder (kwinglobals.h) eight borders defined: one for each side and one for each corner.
As value it takes (CARDINAL/32, 1 value):


The electric borders are windows kept above all other windows. KWin watches for EnterNotify and ClientMessage XEvents on the electric border windows in the global event handler Workspace::workspaceEvent (events.cpp:228) which calls Workspace::electricBorderEvent (workspace.cpp:2621). EnterNotify is used to test whether the mouse entered a border, ClientMessage is used for the D&D case, though this is mostly broken (e.g. using D&D to Present Windows does not work/crashes the application you drag from).
* 0: top edge
* 1: right edge
* 2: bottom edge
* 3: left edge
 
KWin will hide the Client (hide because unmap or minimize would break it) and create an Edge. If that Edge gets triggered the Client is shown again and the property gets deleted. If the Client doesn't border the specified screen edge the Client gets shown immediately so that we never end in a situation that we cannot unhide the auto-hidden panel again. The exact process is described in the documentation of ScreenEdges. The Client can request to be shown again by deleting the property.


ElectricBorders need to be reserved and unreserved. This can be done from a KWin Effect (effect.cpp:962), though it does not have any information about which KWin effect reserves the border. Several effects could reserve the border. Some electric borders are reserved cause of some settings to e.g. lock screen or activate dashboard.
If KWin gets restarted the state is read from the property and it is tried to create the edge as described.
   
As this is a KWin specific extension we need to discuss what it means for Clients using this feature with other WMs: it does nothing. As the Client gets hidden by KWin and not by the Client, it just doesn't get hidden if the WM doesn't provide the feature. In case of an auto-hiding panel this seems like a good solution given that we don't want to hide it if we cannot unhide it. Of course there's the option for the Client to provide that feature itself and if that's wanted we would need to announce the feature in the _NET_SUPPORTED atom. At the moment that doesn't sound like being needed as Plasma doesn't want to  provide an own implementation.


Most of the electric border related code is in workspace.cpp about line 2325. Show/hideElectricBorderWindowOutline() are not related to electric borders, but to Quick Tiling. There is also some code in layers.cpp. In Workspace::propagateClients the WIds of the electric borders are added to the stacking order and there is Workspace::raiseElectricBorderWindows which is needed to re raise the windows if a fullscreen effect window is opened above.
The implementation comes with a small test application showing how the feature is intended to be used.
 
Notifying effects, switching desktop and so on is done from Workspace::checkElectricBorder()
 
== Refactoring ==
All electric border related code should be moved out of Workspace into an own class, e.g. ElectricBorder or more generic ScreenEdge. (Un)Reserving is probably not needed any more, all edges need to be reserved to inform other applications about triggered edges. Desktop switching while moving can probably be dropped from screen edge handling and should be merged with Quick Tiling which does not use electric borders.

Latest revision as of 13:19, 26 February 2014

This provides a new protocol intended to be used by auto-hiding panels to make use of the centralized screen edges. To use it a Client can set an X11 property of type _KDE_NET_WM_SCREEN_EDGE_SHOW to KWin.

As value it takes (CARDINAL/32, 1 value):

  • 0: top edge
  • 1: right edge
  • 2: bottom edge
  • 3: left edge

KWin will hide the Client (hide because unmap or minimize would break it) and create an Edge. If that Edge gets triggered the Client is shown again and the property gets deleted. If the Client doesn't border the specified screen edge the Client gets shown immediately so that we never end in a situation that we cannot unhide the auto-hidden panel again. The exact process is described in the documentation of ScreenEdges. The Client can request to be shown again by deleting the property.

If KWin gets restarted the state is read from the property and it is tried to create the edge as described.

As this is a KWin specific extension we need to discuss what it means for Clients using this feature with other WMs: it does nothing. As the Client gets hidden by KWin and not by the Client, it just doesn't get hidden if the WM doesn't provide the feature. In case of an auto-hiding panel this seems like a good solution given that we don't want to hide it if we cannot unhide it. Of course there's the option for the Client to provide that feature itself and if that's wanted we would need to announce the feature in the _NET_SUPPORTED atom. At the moment that doesn't sound like being needed as Plasma doesn't want to provide an own implementation.

The implementation comes with a small test application showing how the feature is intended to be used.