jbuchermn / newm

Wayland compositor
MIT License
958 stars 31 forks source link

Ideas for Layout functions #161

Open CRAG666 opened 1 year ago

CRAG666 commented 1 year ago

I am working more actively on this project, so I want to improve and add functions to Layout, believe this ISSUE only to make them known and have a feedback before doing a PR

CRAG666 commented 1 year ago

The first idea is to make a function that takes you to a specific tile

def goto_tile(self, index: int):
    if index == 0:
        return
    workspace = self.get_active_workspace()
    tiles = self.tiles(workspace)
    num_t = len(tiles)
    if index > num_t:
        return
    self.focus_view(tiles[index - 1])

@jbuchermn What do you think about this

CRAG666 commented 1 year ago

I also wrote my version for NextView and implemented logic for Prev_View

def __hook_prev_next_view(self, fun, step=1):
    workspace = self.get_active_workspace()
    views = self.tiles(workspace)
    current_view = self.find_focused_view()
    if not current_view:
        return
    index = views.index(current_view) + step
    fun(index, views)

def next_view(self):
    def call(index, views):
        num_w = len(views)
        if index == num_w:
            index = 0
        self.focus_view(views[index])
    hook_prev_next_view(call)

def prev_view(self):
    def call(index, views):
        self.focus_view(views[index])
    hook_prev_next_view(call, -1)

i even could add, the "all_views" parameter, to use self.views instead of self.tiles

jbuchermn commented 1 year ago

Hi,

I think these are good ideas! Did you try if it works?

CRAG666 commented 1 year ago

Hi,

I think these are good ideas! Did you try if it works?

@jbuchermn Of course I am already using these functions in my day by day

CRAG666 commented 1 year ago

imagen imagen

CRAG666 commented 1 year ago

I've been using this for more than a month