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

fix fullscreen using pointer on several monitors #2049

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 23 additions & 26 deletions guake/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from guake.globals import ALIGN_LEFT
from guake.globals import ALIGN_RIGHT
from guake.globals import ALIGN_TOP
from guake.globals import ALWAYS_ON_PRIMARY

try:
from gi.repository import GdkX11
Expand Down Expand Up @@ -230,9 +229,8 @@ def set_final_window_rect(cls, settings, window):
log.debug(" vdisplacement = %s", vdisplacement)

# get the rectangle just from the destination monitor
screen = window.get_screen()
monitor = cls.get_final_window_monitor(settings, window)
window_rect = screen.get_monitor_geometry(monitor)
window_rect = monitor.get_workarea()
log.debug("Current monitor geometry")
log.debug(" window_rect.x: %s", window_rect.x)
log.debug(" window_rect.y: %s", window_rect.y)
Expand Down Expand Up @@ -285,34 +283,29 @@ def set_final_window_rect(cls, settings, window):

@classmethod
def get_final_window_monitor(cls, settings, window):
"""Gets the final screen number for the main window of guake."""
"""Gets the final monitor for the main window of guake."""

screen = window.get_screen()
display = window.get_display()

# fetch settings
use_mouse = settings.general.get_boolean("mouse-display")
dest_screen = settings.general.get_int("display-n")
num_monitor = settings.general.get_int("display-n")

if use_mouse:
pointer = display.get_default_seat().get_pointer()
if pointer is None:
monitor = display.get_primary_monitor()
else:
_, x, y = pointer.get_position()
monitor = display.get_monitor_at_point(x, y)
else:
monitor = display.get_monitor(num_monitor)
if monitor is None:
# monitor not found or num_monitor is wrong
# by default we use the primary monitor
monitor = display.get_primary_monitor()

# TODO PORT get_pointer is deprecated
# https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-pointer
win, x, y, _ = screen.get_root_window().get_pointer()
dest_screen = screen.get_monitor_at_point(x, y)

# If Guake is configured to use a screen that is not currently attached,
# default to 'primary display' option.
n_screens = screen.get_n_monitors()
if dest_screen > n_screens - 1:
settings.general.set_boolean("mouse-display", False)
settings.general.set_int("display-n", dest_screen)
dest_screen = screen.get_primary_monitor()

# Use primary display if configured
if dest_screen == ALWAYS_ON_PRIMARY:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the always on primary option in the "Appear on display" drop-down is for using the system configured primary display if chosen, while other options in the drop-down let the user override with a specific monitor. Looks like the explicit check is removed here in favor of a catch-all if the search for a specific monitor falls through. Not noticing adverse side effects from the removal of this, raising this in case any potential edge case comes to mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any side effects as well as it merges the behavior of lines 309 and 313.

I can add it back if you want to.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looked fine, just wanted to make sure we didn't accidentally kill any of the defined monitor options.

dest_screen = screen.get_primary_monitor()

return dest_screen
return monitor


class ImageLayoutMode(enum.IntEnum):
Expand Down Expand Up @@ -421,7 +414,9 @@ def draw(self, widget, cr):
# Step 1. Get target surface
# (paint background image into widget size surface by layout mode)
surface = self.render_target(
widget.get_allocated_width(), widget.get_allocated_height(), self.layout_mode
widget.get_allocated_width(),
widget.get_allocated_height(),
self.layout_mode,
)

cr.save()
Expand All @@ -440,7 +435,9 @@ def draw(self, widget, cr):
#
child = widget.get_child()
child_surface = cr.get_target().create_similar(
cairo.CONTENT_COLOR_ALPHA, child.get_allocated_width(), child.get_allocated_height()
cairo.CONTENT_COLOR_ALPHA,
child.get_allocated_width(),
child.get_allocated_height(),
)
child_cr = cairo.Context(child_surface)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fixes:
- |
Fix fullscreen window is not working on multiple monitors when using
"appear on mouse display" option #928