add option for setting keepAbove on floating windows (fixes #15)
This commit is contained in:
@@ -15,15 +15,13 @@
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="layout_tab_general" columnstretch="0,1">
|
||||
<layout class="QFormLayout" name="layout_tab_general">
|
||||
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_gapsOuterTop">
|
||||
<property name="text">
|
||||
<string>Top margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@@ -45,9 +43,6 @@
|
||||
<property name="text">
|
||||
<string>Bottom margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@@ -69,9 +64,6 @@
|
||||
<property name="text">
|
||||
<string>Left margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@@ -93,9 +85,6 @@
|
||||
<property name="text">
|
||||
<string>Right margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
@@ -117,9 +106,6 @@
|
||||
<property name="text">
|
||||
<string>Horizontal gaps between windows:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
@@ -141,9 +127,6 @@
|
||||
<property name="text">
|
||||
<string>Vertical gaps between windows:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
@@ -165,9 +148,6 @@
|
||||
<property name="text">
|
||||
<string>Overscroll amount:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
@@ -189,9 +169,6 @@
|
||||
<property name="text">
|
||||
<string>Manual scroll step size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
@@ -209,22 +186,43 @@
|
||||
</item>
|
||||
|
||||
<item row="8" column="1">
|
||||
<spacer name="separator_behavior">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_behavior">
|
||||
<property name="text">
|
||||
<string>Behavior:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_untileOnDrag">
|
||||
<property name="text">
|
||||
<string>Un-tile windows by dragging them</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="9" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_stackColumnsByDefault">
|
||||
<property name="text">
|
||||
<string>Stack columns by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="10" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_resizeNeighborColumn">
|
||||
<property name="text">
|
||||
<string>Resize neighbor column on edge resize</string>
|
||||
@@ -232,13 +230,44 @@
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="11" column="0" colspan="2">
|
||||
<spacer name="bottomSpacer_tab_general">
|
||||
<item row="12" column="1">
|
||||
<spacer name="separator_layering">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_layering">
|
||||
<property name="text">
|
||||
<string>Layering mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QRadioButton" name="kcfg_tiledKeepBelow">
|
||||
<property name="text">
|
||||
<string>Keep tiled windows below</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QRadioButton" name="kcfg_floatingKeepAbove">
|
||||
<property name="text">
|
||||
<string>Keep floating windows above</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_windowRules">
|
||||
|
||||
@@ -10,5 +10,7 @@ type Config = {
|
||||
untileOnDrag: boolean,
|
||||
stackColumnsByDefault: boolean,
|
||||
resizeNeighborColumn: boolean,
|
||||
tiledKeepBelow: boolean,
|
||||
floatingKeepAbove: boolean,
|
||||
windowRules: string,
|
||||
};
|
||||
|
||||
@@ -107,6 +107,16 @@ const configDef = [
|
||||
"type": "Bool",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "tiledKeepBelow",
|
||||
"type": "Bool",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "floatingKeepAbove",
|
||||
"type": "Bool",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "windowRules",
|
||||
"type": "String",
|
||||
|
||||
1
src/extern/kwin.d.ts
vendored
1
src/extern/kwin.d.ts
vendored
@@ -45,6 +45,7 @@ interface AbstractClient {
|
||||
// Read-write Properties
|
||||
fullScreen: boolean;
|
||||
activities: string[]; // empty array means all activities
|
||||
keepAbove: boolean;
|
||||
keepBelow: boolean;
|
||||
shade: boolean;
|
||||
minimized: boolean;
|
||||
|
||||
@@ -3,4 +3,6 @@ type LayoutConfig = {
|
||||
gapsInnerVertical: number,
|
||||
stackColumnsByDefault: boolean,
|
||||
resizeNeighborColumn: boolean,
|
||||
tiledKeepBelow: boolean,
|
||||
maximizedKeepAbove: boolean,
|
||||
};
|
||||
|
||||
@@ -57,14 +57,22 @@ class Window {
|
||||
public onMaximizedChanged(horizontally: boolean, vertically: boolean) {
|
||||
const maximized = horizontally || vertically;
|
||||
this.skipArrange = maximized;
|
||||
this.client.kwinClient.keepBelow = !maximized;
|
||||
if (this.column.grid.config.tiledKeepBelow) {
|
||||
this.client.kwinClient.keepBelow = !maximized;
|
||||
}
|
||||
if (this.column.grid.config.maximizedKeepAbove) {
|
||||
this.client.kwinClient.keepAbove = maximized;
|
||||
}
|
||||
}
|
||||
|
||||
public onFullScreenChanged(fullScreen: boolean) {
|
||||
this.skipArrange = fullScreen;
|
||||
if (this.isFocused()) {
|
||||
if (this.column.grid.config.tiledKeepBelow && this.isFocused()) {
|
||||
this.client.kwinClient.keepBelow = !fullScreen;
|
||||
}
|
||||
if (this.column.grid.config.maximizedKeepAbove) {
|
||||
this.client.kwinClient.keepAbove = fullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
public onUserResize(oldGeometry: QRect, resizeNeighborColumn: boolean) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class ClientManager {
|
||||
private readonly world: World;
|
||||
private readonly config: ClientManager.Config;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
private readonly clientMap: Map<AbstractClient, ClientWrapper>;
|
||||
private lastFocusedClient: AbstractClient|null;
|
||||
@@ -7,6 +8,7 @@ class ClientManager {
|
||||
|
||||
constructor(config: Config, world: World, desktopManager: DesktopManager) {
|
||||
this.world = world;
|
||||
this.config = { keepAbove: config.floatingKeepAbove };
|
||||
this.desktopManager = desktopManager;
|
||||
this.clientMap = new Map();
|
||||
this.lastFocusedClient = null;
|
||||
@@ -31,7 +33,7 @@ class ClientManager {
|
||||
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
|
||||
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, grid);
|
||||
} else {
|
||||
constructState = (client: ClientWrapper) => new ClientState.Floating(client, false);
|
||||
constructState = (client: ClientWrapper) => new ClientState.Floating(client, this.config, false);
|
||||
}
|
||||
|
||||
const client = new ClientWrapper(
|
||||
@@ -105,7 +107,7 @@ class ClientManager {
|
||||
return;
|
||||
}
|
||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||
client.stateManager.setState(() => new ClientState.Floating(client, true), false);
|
||||
client.stateManager.setState(() => new ClientState.Floating(client, this.config, true), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +123,7 @@ class ClientManager {
|
||||
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||
} else if (clientState instanceof ClientState.Tiled) {
|
||||
client.stateManager.setState(() => new ClientState.Floating(client, true), false);
|
||||
client.stateManager.setState(() => new ClientState.Floating(client, this.config, true), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,3 +169,9 @@ class ClientManager {
|
||||
this.removeAllClients();
|
||||
}
|
||||
}
|
||||
|
||||
namespace ClientManager {
|
||||
export type Config = {
|
||||
keepAbove: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,14 @@ class World {
|
||||
marginRight: config.gapsOuterRight,
|
||||
overscroll: config.overscroll,
|
||||
},
|
||||
config,
|
||||
{
|
||||
gapsInnerHorizontal: config.gapsInnerHorizontal,
|
||||
gapsInnerVertical: config.gapsInnerVertical,
|
||||
stackColumnsByDefault: config.stackColumnsByDefault,
|
||||
resizeNeighborColumn: config.resizeNeighborColumn,
|
||||
tiledKeepBelow: config.tiledKeepBelow,
|
||||
maximizedKeepAbove: config.floatingKeepAbove,
|
||||
},
|
||||
workspace.currentActivity,
|
||||
);
|
||||
this.clientManager = new ClientManager(config, this, this.desktopManager);
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
namespace ClientState {
|
||||
export class Floating implements State {
|
||||
constructor(client: ClientWrapper, limitHeight: boolean) {
|
||||
private readonly client: ClientWrapper;
|
||||
private readonly config: ClientManager.Config;
|
||||
|
||||
constructor(client: ClientWrapper, config: ClientManager.Config, limitHeight: boolean) {
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
if (config.keepAbove) {
|
||||
client.kwinClient.keepAbove = true;
|
||||
}
|
||||
if (limitHeight && client.kwinClient.tile === null) {
|
||||
Floating.limitHeight(client);
|
||||
}
|
||||
}
|
||||
|
||||
public destroy(passFocus: boolean) {}
|
||||
public destroy(passFocus: boolean) {
|
||||
if (this.config.keepAbove) {
|
||||
this.client.kwinClient.keepAbove = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static limitHeight(client: ClientWrapper) {
|
||||
const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.screen, client.kwinClient.desktop);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ClientState {
|
||||
private readonly signalManager: SignalManager;
|
||||
|
||||
constructor(world: World, client: ClientWrapper, grid: Grid) {
|
||||
Tiled.prepareClientForTiling(client);
|
||||
Tiled.prepareClientForTiling(client, grid.config);
|
||||
|
||||
const column = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn());
|
||||
const window = new Window(client, column);
|
||||
@@ -21,7 +21,7 @@ namespace ClientState {
|
||||
const client = window.client;
|
||||
window.destroy(passFocus);
|
||||
|
||||
Tiled.restoreClientAfterTiling(client, grid.desktop.clientArea);
|
||||
Tiled.restoreClientAfterTiling(client, grid.config, grid.desktop.clientArea);
|
||||
}
|
||||
|
||||
private static initSignalManager(world: World, window: Window) {
|
||||
@@ -131,8 +131,10 @@ namespace ClientState {
|
||||
window.moveToColumn(newColumn);
|
||||
}
|
||||
|
||||
private static prepareClientForTiling(client: ClientWrapper) {
|
||||
client.kwinClient.keepBelow = true;
|
||||
private static prepareClientForTiling(client: ClientWrapper, config: LayoutConfig) {
|
||||
if (config.tiledKeepBelow) {
|
||||
client.kwinClient.keepBelow = true;
|
||||
}
|
||||
client.setFullScreen(false);
|
||||
if (client.kwinClient.tile !== null) {
|
||||
client.setMaximize(false, true); // disable quick tile mode
|
||||
@@ -140,8 +142,10 @@ namespace ClientState {
|
||||
client.setMaximize(false, false);
|
||||
}
|
||||
|
||||
private static restoreClientAfterTiling(client: ClientWrapper, screenSize: QRect) {
|
||||
client.kwinClient.keepBelow = false;
|
||||
private static restoreClientAfterTiling(client: ClientWrapper, config: LayoutConfig, screenSize: QRect) {
|
||||
if (config.tiledKeepBelow) {
|
||||
client.kwinClient.keepBelow = false;
|
||||
}
|
||||
client.setShade(false);
|
||||
client.setFullScreen(false);
|
||||
if (client.kwinClient.tile === null) {
|
||||
|
||||
Reference in New Issue
Block a user