Registered Member
|
hello, I want to write simple kwin script but I have no idea how to do it.
I want to make all windows being moved to the current desktop when unmminimized. How difficult is to get this behavior?
Last edited by sir_herrbatka on Sun Oct 28, 2012 2:56 pm, edited 1 time in total.
|
|
Sth. like this (just written down, not tested. will contain typos.)
workspace.clientMinimized.connect(function(client) { client.setDesktop(workspace.currentDesktop); }); For more info see here: http://techbase.kde.org/Development/Tut ... /Scripting and here http://techbase.kde.org/Development/Tut ... ipting/API |
KDE Developer
|
instead of client.setDestkop() just use:
client.desktop = workspace.currentDesktop Don't forget to share your script on kde-look.org |
Registered Member
|
hmmm, for some reason this script has no effect. I restore minized window and I'm getting moved to the desktop where the window is instead of moving window to the current desktop.
edit, ok, actually it WORKS workspace.clientUnminimized.connect(function(client) { client.desktop = workspace.currentDesktop; }); but the problem is that clicking on the icon in the icon tasks moves to the desktop containing the window first, and then restores the window. Right clicking and using minimize box bring the effect, but well… that's suboptimal for me. It feels sad. |
|
The problem is that the taskbar does not unminize the window but activates it.
you're implictily kicked to the "proper" desktop and the window is automatically unminimized by this. What you actually want to do is to on every VD change move all minimized clients to that VD (otherwise you'd have to pre-act on the taskbar, not act on window state changes - that's too late.) |
Registered Member
|
uh, I see. I'm not quite sure If I am able to do this. I'm not a programmer at all. I see that there is client.isMinimized() but i have no idea how to use it :/
|
|
I bet you can.
You already managed to bind a function to an event - now you only need to pick the proper event, use the proper parameter in the function - "(client)" does not match that event - and then find a way to do sth. with all clients [1] which are not ("!") minimized and assign their desktop variable the known way. Try. Then try hader. And if you've remaining questions, just call back =) [1] hint: see here http://techbase.kde.org/Development/Tut ... ng#Clients |
Registered Member
|
Should I create a new array? But how do I add new elements to array?
|
KDE Developer
|
http://www.w3schools.com/jsref/jsref_obj_array.asp
|
Registered Member
|
var MinClients = new Array();
workspace.clientMinimized.connect(function(client) { MinClients.push(client); }); will push client after being minimized to the MinClients array? Edit My plan is to push every window after being minimized to the array and then move every element of the array to the current VD after VD being changed. Will it work this way? |
KDE Developer
|
would work, but solution is not optimal as you would need to track windows unminimizing and closing. I would just go through all windows when changing the desktop.
Something like:
code is not tested |
Registered Member
|
It is tested now.
It WORKS! wow, it's a major improvement for me. Thank you mgraesslin, you rock. |
Registered Member
|
I want to only add that i posted the script on the KDE-look.org.
|
Registered Member
|
Hi again!
I wanted to add extra check if window is not on all desktops. I figured out that i need: if (clients[i].desktop != -1) { } But it does not work for some reason. I feel a little retarded, it's so simple and I can't make it work. |
KDE Developer
|
The client has a property onAllDesktops, so just do:
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft