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 action to bring focus to the window at a specific point #15

Closed
wants to merge 0 commits into from

Conversation

brainwater
Copy link

With the recent introduction of 4k monitors, the usable screen space on a single screen has increased significantly. I found that I spent an increased amount of time switching between windows because I was able to have more windows open on one desktop than ever before. I wanted to have a way to switch to another window in O(1) time. I decided that a way to select which window to go to based on the position in the screen in a 4x3 grid using the letters qwer,asdf,zxcv in order to select which position to go to the window. Unfortunately that functionallity was not available in openbox, so I modified it to allow this. So I added a new command "FocusOnPoint" that would bring the focus to the window at the specified point. An example of what it can be used for is in this snippet of my config file:

    <!-- Keybindings for focusing on a window in a grid -->
    <keybind key="W-C-q"><action name="FocusOnPoint"><x>1/8</x><y>1/6</y></action></keybind>
    <keybind key="W-C-w"><action name="FocusOnPoint"><x>3/8</x><y>1/6</y></action></keybind>
    <keybind key="W-C-e"><action name="FocusOnPoint"><x>5/8</x><y>1/6</y></action></keybind>
    <keybind key="W-C-r"><action name="FocusOnPoint"><x>7/8</x><y>1/6</y></action></keybind>

    <keybind key="W-C-a"><action name="FocusOnPoint"><x>1/8</x><y>3/6</y></action></keybind>
    <keybind key="W-C-s"><action name="FocusOnPoint"><x>3/8</x><y>3/6</y></action></keybind>
    <keybind key="W-C-d"><action name="FocusOnPoint"><x>5/8</x><y>3/6</y></action></keybind>
    <keybind key="W-C-f"><action name="FocusOnPoint"><x>7/8</x><y>3/6</y></action></keybind>

    <keybind key="W-C-z"><action name="FocusOnPoint"><x>1/8</x><y>5/6</y></action></keybind>
    <keybind key="W-C-x"><action name="FocusOnPoint"><x>3/8</x><y>5/6</y></action></keybind>
    <keybind key="W-C-c"><action name="FocusOnPoint"><x>5/8</x><y>5/6</y></action></keybind>
    <keybind key="W-C-v"><action name="FocusOnPoint"><x>7/8</x><y>5/6</y></action></keybind>

The FocusOnPoint action takes 2 mandatory parameters "x" and "y", and one optional parameter, "raise". The x and y parameters take either an absolute position, or a fractional position based on the width or height of the screen, or a percentage based on the width or height of the screen. "raise" when set to true will cause the window that is being focused to also be raised to the front of the z-order.

I had also added the following to my openbox config file for resizing and moving windows based on that same 4x3 grid using the same letters:

 <!-- Keybindings for resizing windows in a grid -->
    <keybind key="W-S-q">
      <keybind key="q"><action name="MoveResizeTo"><width>1/4</width><height>1/3</height></action></keybind>
      <keybind key="w"><action name="MoveResizeTo"><width>2/4</width><height>1/3</height></action></keybind>
      <keybind key="e"><action name="MoveResizeTo"><width>3/4</width><height>1/3</height></action></keybind>
      <keybind key="r"><action name="MoveResizeTo"><width>4/4</width><height>1/3</height></action></keybind>

      <keybind key="a"><action name="MoveResizeTo"><width>1/4</width><height>2/3</height></action></keybind>
      <keybind key="s"><action name="MoveResizeTo"><width>2/4</width><height>2/3</height></action></keybind>
      <keybind key="d"><action name="MoveResizeTo"><width>3/4</width><height>2/3</height></action></keybind>
      <keybind key="f"><action name="MoveResizeTo"><width>4/4</width><height>2/3</height></action></keybind>

      <keybind key="z"><action name="MoveResizeTo"><width>1/4</width><height>3/3</height></action></keybind>
      <keybind key="x"><action name="MoveResizeTo"><width>2/4</width><height>3/3</height></action></keybind>
      <keybind key="c"><action name="MoveResizeTo"><width>3/4</width><height>3/3</height></action></keybind>
      <keybind key="v"><action name="MoveResizeTo"><width>4/4</width><height>3/3</height></action></keybind>
    </keybind>
    <!-- Keybindings for moving windows in a grid -->
    <keybind key="W-S-w">
      <keybind key="q"><action name="MoveResizeTo"><x>0/4</x><y>0/3</y></action></keybind>
      <keybind key="w"><action name="MoveResizeTo"><x>1/4</x><y>0/3</y></action></keybind>
      <keybind key="e"><action name="MoveResizeTo"><x>2/4</x><y>0/3</y></action></keybind>
      <keybind key="r"><action name="MoveResizeTo"><x>3/4</x><y>0/3</y></action></keybind>

      <keybind key="a"><action name="MoveResizeTo"><x>0/4</x><y>1/3</y></action></keybind>
      <keybind key="s"><action name="MoveResizeTo"><x>1/4</x><y>1/3</y></action></keybind>
      <keybind key="d"><action name="MoveResizeTo"><x>2/4</x><y>1/3</y></action></keybind>
      <keybind key="f"><action name="MoveResizeTo"><x>3/4</x><y>1/3</y></action></keybind>

      <keybind key="z"><action name="MoveResizeTo"><x>0/4</x><y>2/3</y></action></keybind>
      <keybind key="x"><action name="MoveResizeTo"><x>1/4</x><y>2/3</y></action></keybind>
      <keybind key="c"><action name="MoveResizeTo"><x>2/4</x><y>2/3</y></action></keybind>
      <keybind key="v"><action name="MoveResizeTo"><x>3/4</x><y>2/3</y></action></keybind>
    </keybind>

Here are some screenshots that show the problem that I was running into with a 4k screen:
dtscreenshot-1
dtscreenshot-2

@danakj
Copy link
Owner

danakj commented Jan 1, 2015

Did you consider adding this to the "If" action instead? http://openbox.org/wiki/Help:Actions#If

Then you could do any action on the window at a position instead of just focus it.

@brainwater
Copy link
Author

I hadn't thought about adding this functionality to the "if" action instead. It looks like it may be somewhat more difficult to do that, however I'll see what I can come up with.

@brainwater
Copy link
Author

This has been superseded by #20 which implements the functionality in the "If" action instead, as requested.

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

Successfully merging this pull request may close these issues.

2 participants