KWin/Screen Edges: Difference between revisions

From KDE Community Wiki
(Screen edges wiki page for Aaron's refactoring)
 
No edit summary
Line 13: Line 13:
== Refactoring ==
== 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.
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.
== Seigo's Proposal ==
* Setting a ElectricBorder XAtom on a window would cause KWin to register a watch on the requests area for that window. When the window clears the atom or the window is deleted, then the area is unregistered. These would be called "window reservations" (as opposed to "effects" or "internal" reservations).
* The ElectricBorder XAtom should consist of a screen #, a screen location (specific edge or corner), optional offset and length (except for corners, for which this is meaningless)
* KWin would then manage a collection of reservations for entire or partial sides; as long as there is at least one reservation for a given side, that border is activated. When the pointer moves into the area (or that area is otherwise triggered, e.g. by a keyboard shortcut?), then all reservations that span the entire area or which contain the location due to their offset/length will get notified.
* Two glows (separated by color?) would be offered on mouse proximity. One for windows with edge triggers, and one for effects. This glow would become part of the KWin effects stack and use an input window.
* Window reservations should not be triggered even on full screen applications; in fact, it may be worthwhile to _not_ raise the input only windows over full screen apps if only window reservations are made for that edge.
* When a window reservation is triggered, KWin should set an XAtom on the window notifying it of such. Windows would remain responsible for their own actions, however, as KWin can not know what specific action to take or if the application needs to do some preparation before taking action (e.g. loading content in a window prior to displaying it).

Revision as of 19:50, 18 January 2011

Screen Edges

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.

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).

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.

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.

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.

Seigo's Proposal

  • Setting a ElectricBorder XAtom on a window would cause KWin to register a watch on the requests area for that window. When the window clears the atom or the window is deleted, then the area is unregistered. These would be called "window reservations" (as opposed to "effects" or "internal" reservations).
  • The ElectricBorder XAtom should consist of a screen #, a screen location (specific edge or corner), optional offset and length (except for corners, for which this is meaningless)
  • KWin would then manage a collection of reservations for entire or partial sides; as long as there is at least one reservation for a given side, that border is activated. When the pointer moves into the area (or that area is otherwise triggered, e.g. by a keyboard shortcut?), then all reservations that span the entire area or which contain the location due to their offset/length will get notified.
  • Two glows (separated by color?) would be offered on mouse proximity. One for windows with edge triggers, and one for effects. This glow would become part of the KWin effects stack and use an input window.
  • Window reservations should not be triggered even on full screen applications; in fact, it may be worthwhile to _not_ raise the input only windows over full screen apps if only window reservations are made for that edge.
  • When a window reservation is triggered, KWin should set an XAtom on the window notifying it of such. Windows would remain responsible for their own actions, however, as KWin can not know what specific action to take or if the application needs to do some preparation before taking action (e.g. loading content in a window prior to displaying it).