THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#1249 - dynamic tagging regression with commit 
9c69e857edb6690fe5a496e82ec57a0bbae36702
User who did this - Wei Peng (pengw)

----------
@ahktenzero

I have not observed ill effect after switching the two line as suggested by 
@psychon. However, I still feel the "switching lines" introducing a hidden 
"order dependency" between tag.setproperty(t, "index", i) and tag.setscreen(t, 
scr) which is not obvious from the API

I guess the underlying issue is the implicit contract of whether the API or 
user should handle corner cases of the input. The trade-off is robustness and 
(perhaps) performance overhead. In the case of tag.setscreen, the corner cases 
are:
* t is a new tag: tag.getproperty(t., "screen")==nil
* not moving to another tag: tag.getproperty(t., "screen")==s
In these cases, the "tag.setproperty(t, "index", nil)" and 
"tag.history.restore(old_screen,1)" should not be executed (if 
tag.history.restore can handle nil screen---which is a corner---, then only the 
second case needs to be considered).

If we are not handling these corner cases, the API doc shall specify these or 
users may be surprised. This is not ideal.

I expect the performance overhead of doing these corner case checks is minimial 
and handling these corner cases in API is worthwhile. Therefore, I suggest 
change tag.setscreen to the following:

--- Set a tag's screen
-- @param t tag object
-- @param s Screen number
function tag.setscreen(t, s)
    if t then
        local s = s or capi.mouse.screen
        local old_screen = tag.getproperty(t, "screen")

        if old_screen and old_screen ~= s then
            -- Keeping the old index make very little sense when changing screen
            tag.setproperty(t, "index", nil)

            -- Change the screen
            tag.setproperty(t, "screen", s)

            -- Make sure the client's screen matches its tags
            for _, c in ipairs(t:clients()) do
                c.screen = s --Move all clients
                c:tags({t})
            end

            tag.history.restore(old_screen, 1)
        end
    end
end

I have a patch against v3.5.4 on 
https://raw.githubusercontent.com/pw4ever/awesome-wm-config/master/00patch/v3.5.4/awful-tag.patch

----------

More information can be found at the following URL:
https://awesome.naquadah.org/bugs/index.php?do=details&task_id=1249#comment3996

You are receiving this message because you have requested it from the Flyspray 
bugtracking system.  If you did not expect this message or don't want to 
receive mails in future, you can change your notification settings at the URL 
shown above.

--
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to