| Summary: | cannot change both width and height of client geometry (maybe a race?) | ||
|---|---|---|---|
| Product: | [Plasma] kwin | Reporter: | Antonio Russo <aerusso> |
| Component: | scripting | Assignee: | KWin default assignee <kwin-bugs-null> |
| Status: | CONFIRMED --- | ||
| Severity: | normal | CC: | andy, kde, kdedev |
| Priority: | NOR | Keywords: | wayland-only |
| Version First Reported In: | 5.25.2 | ||
| Target Milestone: | --- | ||
| Platform: | Debian testing | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Antonio Russo
2023-05-16 04:16:45 UTC
I forgot to mention: this is a wayland regression. It is broken on kwin_wayland, but works on kwin_X11. To explain what's happening: client.geometry.height = 1000; is asking the client for the geometry of (currentWidth, 1000); client.geometry.width = 1000; is asking the client for the geometry of (1000, currentHeight); Changing geometry is an async operation, at the time of the second call, the currentHeight is the frames current height, which is not 1000. I would say the script code is wrong, set client.geometry to a rect directly. Please reopen if there's a reason why your script can't do that. Yes, I suspected that the async operations were doing this, but I was never able to figure out how to overcome that. In particular, I don't know how to instantiate a QRect object (is it spelled "rect"?)? Could you please give me the exact script that you are saying will allow me to change both the width and height at the same time? If such a script indeed exists, I definitely agree this bug should be closed. Thank you, Antonio (In reply to Antonio Russo from comment #3) > Yes, I suspected that the async operations were doing this, but I was never > able to figure out how to overcome that. In particular, I don't know how to > instantiate a QRect object (is it spelled "rect"?)? > > Could you please give me the exact script that you are saying will allow me > to change both the width and height at the same time? If such a script > indeed exists, I definitely agree this bug should be closed. > > Thank you, > Antonio I figured it out (for plasma 6). You can set the entire frameGeometry object at once. var x = 2000 var y = 2000 var width = 200 var height = 200 var left = x var right = x + width var top = y var bottom = y + height workspace.activeWindow.frameGeometry = {"x":x,"y":y,"width":width,"height":height,"left":left,"right":right,"top":top,"bottom":bottom} If I query the geometry again (this is in the shell scripting console) I get {"x":2000,"y":2000,"width":200,"height":339,"left":2000,"right":2200,"top":2000,"bottom":2339} I was wondering if we have to specify all that or just x,y,width,height. If I don't specify left/right/top/bottom workspace.activeWindow.frameGeometry = {"x":x,"y":y,"width":width,"height":height} if I query the result I get slightly different positioning, but same width and height {"x":2000,"y":1861,"width":200,"height":339,"left":2000,"right":2200,"top":1861,"bottom":2200} But for just a move this works workspace.activeWindow.frameGeometry = {"x":x,"y":y} For just a resize lol this doesn't work, it moves the window to (0,0) which is off-screen for my monitor setup. workspace.activeWindow.frameGeometry = {"width":width,"height":height} I wanted to follow up on this. Antonio, would the suggestion in comment 3 work for you? ๐๐งน โ ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME. For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging. Thank you for helping us make KDE software even better for everyone! Thanks for the hint, andy! Things seem to be a little bit wonky. The following works:
var oldgeometry = workspace.activeWindow.frameGeometry;
workspace.activeWindow.frameGeometry = {"x":oldgeometry["x"],"y":oldgeometry["y"],"width":oldgeometry["width"],"height":oldgeometry["height"]};
(i.e., modify any of these parameters, and you can get the effect you're looking for). As far as I can tell, top and bottom don't seem to be necessary/useful. However, you might think that you could do
var oldgeometry = workspace.activeWindow.frameGeometry;
oldgeometry["width"] = 400;
workspace.activeWindow.frameGeometry = oldgeometry;
but that does not work! You have to create a whole new geometry:
var oldgeometry = workspace.activeWindow.frameGeometry;
var newgeometry = {"x":oldgeometry["x"],"y":oldgeometry["y"],"width":oldgeometry["width"],"height":oldgeometry["height"]};
newgeometry["width"] = 400;
workspace.activeWindow.frameGeometry = oldgeometry;
I'm guessing the structure that actually comes out of workspace.activeWindow.frameGeometry is more complicated than a dictionary, then?
I suggest that this is a documentation bug. I have not read all of the (improved, since 2023!) documentation, but I don't immediately see a statement anywhere explaining any of these quirks. Moreover, I don't see a description of how a QRect is represented in the scripting API. (This was part of my original question, and I still don't quite understand it). Of course, one could dig into the code to figure out how that mapping is done, but it would be nice if the documentation had this information.
Feel free to close this bug, but I do think that the tutorial should include a subset/restatement of this bug report in it, at a minimum.
|