From what I understand, window:set_prop() is mainly for setting supported window properties, but fullscreen state is generally managed through dispatchers rather than by directly modifying the fullscreen field. may i ask what exactly you are trying to do? I actually used this example for someone else here but it hink it can also work for you.. look at how whatever game window i launch i grab and throw to workspace 4.
-below will grab whatever game lauched from steam
29 wr({
30 name = “steam-games-workspace-4”,
31 match = {
32 class = “^(steam_app_[0-9]+)$”,
33 },
34 workspace = “4 silent”,
35 no_blur = true,
36 })
37
38 – Game goes to workspace 4 stuff
39 wr({
40 name = “gamescope-workspace-4”,
41 match = {
42 class = “^(gamescope)$”,
43 },
44 workspace = “4 silent”,
45 no_blur = true,
46 })
for fullscreen id iamgine something maybe like this
wr({
name = “gamescope-workspace-4-fullscreen”,
match = {
class = “^(gamescope)$”,
},
workspace = “4 silent”,
fullscreen = true,
no_blur = true,
})
Currently I experience the behavior, that if I fullscreen a youtube video that after returning from fullscreen the window is maximized. I know I could write a window rule to force a youtube/browser fullscreen to always return to non-maximized. But I feel like this is kind of a restriction, because there can be the case where I fullscreened from maximized and want to return to that state. That is why I chose to go for this approach. My idea was to write an event handler for full screen and keep track of the states of the windows, and to return to that state.
This is the template I have, but again the “fullscreen” prop seems to not work as you pointed out
local windows_fullscreen = {}
-- updatng windows from leaving fullscreen
hl.on("window.fullscreen", function(w)
notify(tostring(windows_fullscreen[w.address]))
if w.fullscreen ~= 2 and w.fullscreen ~= 3 then
hl.dispatch(hl.dsp.window.set_prop({ prop = "fullscreen", value = 0, window = w.address }))
end
end)
-- keeping track of window states (tiled/maximized)
hl.on("window.update_rules", function(w)
if w.fullscreen ~= 2 and w.fullscreen ~= 3 then
windows_fullscreen[w.address] = w.fullscreen
end
end)
I had to check the current wiki, but from what im seeing, set_prop() is intended for dynamic windowrule effects, not necessarily every field exposed on a window object. So while w.fullscreen and w.fullscreenClient appear to be readable state values, that doesnt automatically mean “fullscreen” is a valid writable property through set_prop(). I do however think the idea of tracking the previous window state makes sense, but I don’t think set_prop() is the right tool for changing fullscreen/maximized state. window.fullscreen looks like readable window state, not necessarily a wriable dynamic property. So even though you can read w.fullscreen, that does not mean set_prop({ prop = “fullscreen”, value = 0 }) is valid. for this kind of behavior, idtake my best guess that the correct path to be a fullscreen/fullscreen_state dispatcher rather than set_prop(). The tricky part is finding the current syntax for targeting that dispatcher at a specific window address
windows_fullscreen[w.address] = w.fullscreen
when leaving fullscreen, restore the saved state with a fullscreen/fullscreen_state dispatcher
So id think the state tracking approach is reasonable. The part I would change is the restore call. Instead of trying to write “fullscreen” as a prop, id look for the lua equivalent of the fullscreen/fullscreen_state dispatcher and use that to restore 0 1 2 or 3 depending on the saved value.
Thank you all for replying and pointing me into the right direction. The solution is
local windows_fullscreen = {}
hl.on("window.fullscreen", function(w)
-- if NEW STATE after leaving fullscreen is NON-FULLSCREEN, then write OLD STATE
if w.fullscreen ~= 2 and w.fullscreen ~= 3 then
hl.dispatch(hl.dsp.window.fullscreen_state({ internal = 0, client = 0, window = w }))
end
end)
-- tracking window fullscreen states
hl.on("window.update_rules", function(w)
-- only save fullscreen states which are NON-FULLSCREEN
-- 0 tiling
-- 1 maximized
-- 2 fullscreen
-- 3 maximized-fullscreen
if w.fullscreen ~= 2 and w.fullscreen ~= 3 then
windows_fullscreen[w.address] = w.fullscreen
end
end)
What is it doing?
Anytime a window is changing, the window.update_rules grabs the last non-fullscreen state and saves it in the windows_fullscreen table. Whenever a window was fullscreen, i.e. 2 and 3, then the new state will be the one before entering fullscreen.
What I think would be better is handling closed windows to not make the table explode. So I think one can also write a handler for the window.close or window.destroy event, such that the table stays clean over longer sessions.