This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Set the floating window to the center of screen #249
Comments
in code KWin.registerShortcut("TILING: Toggle Floating",
"TILING: Toggle Floating and center the Application Window",
"",
function() {
var client = workspace.activeClient;
if (client == null) {
print("No active client");
return;
}
// This can be undefined if the client
// has never been seen before
if (client.tiling_floating
|| client.tiling_floating == null) {
client.tiling_floating = false;
self.tiles.addClient(client);
} else {
client.tiling_floating = true;
self.tiles.untileClient(client);
///// maybe center the client here?
}
}); But I am not sure which api I can use to center the client |
The client's shape is stored in client.geometry. You'll have to set that so that the middle of that is the middle of the screenrectangle. There is no specific api to "center". (Kwin's plugin api is old school, barebones and badly documented) |
function() {
var client = workspace.activeClient;
if (client == null) {
print("No active client");
return;
}
// This can be undefined if the client
// has never been seen before
if (client.tiling_floating
|| client.tiling_floating == null) {
client.tiling_floating = false;
self.tiles.addClient(client);
} else {
client.tiling_floating = true;
self.tiles.untileClient(client);
var maxArea = workspace.clientArea(KWin.MaximizeArea, client);
client.geometry = {
x: maxArea.x + (maxArea.width - client.width) / 2,
y: maxArea.y + (maxArea.height - client.height) / 2,
width: client.width,
height: client.height
};
} I tried one online script, the logic seems to be working in but inside |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
Is it possible to add a keyboard shortcut to center the floating window on the screen?
Currently I can bind a shortcut to make a tiling window into float mode, but I wish I could center the window right after set it to float mode.
Is it possible to accomplish the sequence in setting? If not, is there a way to do it programmatically?
Thanks
The text was updated successfully, but these errors were encountered: