Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client move global by direction #2437

Open
darrenswhite opened this issue Oct 15, 2018 · 9 comments
Open

Add client move global by direction #2437

darrenswhite opened this issue Oct 15, 2018 · 9 comments

Comments

@darrenswhite
Copy link

Similar to how awful.client.focus.global_bydirection and awful.client.swap.global_bydirection work except for moving a client in a given direction. This would be nice to have if possible! Thanks.

@Elv13
Copy link
Member

Elv13 commented Oct 15, 2018

Here you go
https://github.com/elv13/collision

  • Select clients by direction
  • Move clients by direction
  • Move floating clients by relative offset
  • Select screens by direction
  • Select tag by direction
  • Move tag by direction

@actionless
Copy link
Member

i think it could be done as client:move_to_screen_bydirection as a counterpart to existing client:move_to_screen but i am running single-screen setup now so can't play with it

@Elv13
Copy link
Member

Elv13 commented Oct 16, 2018

In that case it would be swap_by_direction, but it has some issues and isn't such a good idea because of floating vs. tiled clients.

If you implement a trivial swap by direction and the next client is floating and the origin isn't, you only have bad choice. Either you blindly swap them and it doesn't work. Either you make the target tiled and the origin floating, in which case you probably made your calculator or popup tiled by accident or you do nothing and it's confusing.

It's better to keep separate logic for floating and tiled clients when it comes to swapping. So a global method on the client isn't gonna work.

@actionless
Copy link
Member

but move_to_screen is not swap, move means what the client just goes away from this screen to some other

@Elv13
Copy link
Member

Elv13 commented Oct 16, 2018

Ah, yeah, we could have that one. I always wanted to add move iterators and navigation methods to the screens to handle geometric navigation and iteration (from left to right, right to left, top to bottom, bottom to top) but I never did.

@actionless
Copy link
Member

but such kind of code should already reside in *_global_bydirection helpers, so mb it could be extracted and re-used?

@Elv13
Copy link
Member

Elv13 commented Oct 16, 2018

It is in gears.geometry.rectangle.get_in_direction. However given the rarely changing screen layouts, it may be worth it to cache the result and daisy-chain the screens (internally, in Lua). Then add myscreen.left/right/up/down properties. However, as I said, it's only safe to do this for screens. Client and tags have many corner case that makes such accessors useless in practice.

@darrenswhite
Copy link
Author

I think client:move_to_screen_bydirection which @actionless suggested would work for me.

@ngoonee
Copy link

ngoonee commented Jun 24, 2020

Any updates on this? Just spent half an hour to implement this behaviour in my crappy lua:-

awful.key({ modkey, "Shift"   }, "u",
          function (c)
              local geo = c.screen.geometry
              if geo.x > 0 then
                  c:move_to_screen(c.screen.index-1)
              end
          end,
          {description = "move to screen on left", group = "screen"}),
awful.key({ modkey, "Shift"   }, "i",
          function (c)
              local geo = c.screen.geometry
              local width = root:size(1)
              if geo.x + geo.width < width then
                  c:move_to_screen()
              end
          end,
          {description = "move to screen on right", group = "screen"}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants