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

Drag the window down to open workspace view #579

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

donadigo
Copy link
Contributor

@donadigo donadigo commented Jul 2, 2019

Fixes #569.

Enables dragging the window down to the bottom screen edge to open workspace view and immediately move the window elsewhere.

Currently based on screen percentage (more than 98% of the height), we may rethink if this should happen.

Testable also with other experimental features in https://github.com/elementary/gala/tree/intelligent-workspaces.

@danirabbit
Copy link
Member

This is a cool idea and it works smoothly. I'm into it.

Something brought up in slack was making sure that we only do this for bottom displays in a vertical multi-display setup.

the percentage works fine for me on a 13" display, but maybe we should get feedback from someone with a rather large display to make sure that's still sane

@worldofpeace
Copy link
Contributor

How's this going to fit in when Pantheon is gesture aware?

@jlnr jlnr force-pushed the drag-window-down-workspace-view branch from cebae81 to afdcc60 Compare October 31, 2019 21:42
@jlnr
Copy link
Member

jlnr commented Oct 31, 2019

@donadigo I've rebased this on master, but besides the git conflicts, I've had to change the handling of AnimationSettings. Also, start_motion returns a bool now because the extracted branch on master has started to return false when handle == null. I've compared the diff before and after rebasing, but please also double-check that the animation changes make sense 🙏

As for the percentage, it feels good to me on a large 3840x1600px screen 👍

int height;
screen.get_size (null, out height);

if (y > (float)height * TRIGGER_RATIO) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does currently not work for multiple monitors if monitors have not the same height or are not aligned. Instead of using the screen height I think it should be better to use the height of the current monitor. This should fix the Problem:
Meta.Rectangle wa = window.get_work_area_for_monitor (screen.get_current_monitor ());

if (y - wa.y > wa.height * TRIGGER_RATIO) {
  window.position_changed.disconnect (on_position_changed);
  open (window, x, y);
}
  • Also wouldn't it be reasonable for the TRIGGER_RATIO to take the current scaling factor into account, so that it would be larger on HiDPI?

@felix-andreas
Copy link
Member

To check if there is no monitor below in a vertical multi monitor setup you could use the code below.
I have implement this and changes from the comment above in https://github.com/andreasfelix/gala/commit/c5709005ecce3b7baba5e391ea11bfc34b8e9e9c. Feel free to merge them if you agree.

bool has_monitor_below (Meta.Window window) {
  unowned Meta.Screen screen = window.get_screen ();
  var n_monitors = screen.get_n_monitors ();
  var current_monitor = screen.get_current_monitor ();
  var current_rect = window.get_work_area_for_monitor (current_monitor);
  var current_end_x = current_rect.x + current_rect.width - 1;
  var current_end_y = current_rect.y + current_rect.height - 1;
  for (int i = 0; i < n_monitors; i++) {
    if (i == current_monitor) {
      continue;
    }

    var other_rect = window.get_work_area_for_monitor (i);
    if (current_end_y < other_rect.y) {
        if (current_rect.x <= other_rect.x + other_rect.width - 1 && current_end_x >= other_rect.x) {
            return true;
        }
    }
  }

  return false;
}

@donadigo
Copy link
Contributor Author

donadigo commented Jan 8, 2020

@andreasfelix do I understand correctly that your code disables the behaviour completely when the monitors are stacked up vertically? If that's the case then it's not what we really want. Ideally, we would like to have always the most bottom edge of the monitor setup to be the trigger instead of disabling the feature completely.

@felix-andreas
Copy link
Member

felix-andreas commented Jan 8, 2020

@donadigo

We would like to have always the most bottom edge of the monitor setup to be the trigger instead of disabling the feature completely.

This is what I was trying to achieve:

  1. Currently you are using the screen height to test if the cursor is at the bottom on the lowest monitor. This logic fails for a horizontal monitor setup, if the bottom of the monitors are not aligned. I think, therefore it would be reasonable to use the monitor height instead. See https://github.com/andreasfelix/gala/commit/88c5b7ef18acc860bb709f8c61b376ccaf2f848d

  2. But using the monitor height, the workspace overview gets also triggered when trying to move a window from the upper monitor to the bottom monitor in a vertical setup. To prevent the drag-to-bottom-action should not be triggered for monitors which have a monitor below. See https://github.com/andreasfelix/gala/commit/c5709005ecce3b7baba5e391ea11bfc34b8e9e9c

The function has_monitor_below only evaluates to true if the current monitor has a monitor below not if any monitor has a monitor below. This is not so easy to test because of #7. You have to horizontally offset the windows so that the wingpanel struts only block the monitor partially or install the branch with the fix.

@donadigo
Copy link
Contributor Author

donadigo commented Feb 9, 2020

@danrabbit resolved conflicts and merged the multi-monitor fixes from @andreasfelix. Ready for review again.

@felix-andreas
Copy link
Member

Another multi-monitor issue occurs when dragging a window from a secondary monitor to the bottom.
The workspace overview gets triggered, but the window does not transform into the icon and instead moves back to its initial monitor.

issue

@donadigo
Copy link
Contributor Author

donadigo commented Feb 9, 2020

@andreasfelix unfortunately I won't be able to solve these issues by myself. I do not have the setup to properly test these cases so there's little here to do for me.

@danirabbit danirabbit marked this pull request as draft June 15, 2021 19:33
@danirabbit
Copy link
Member

Converting to draft since there are conflicts and there hasn't been any movement here for a while. Feel free to mark ready for review if this is updated :)

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.

Drag the window down to move it to a workspace
5 participants