Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
c1152d2d by Cédric Krier at 2023-01-22T16:33:41+01:00
Prevent calendar pop-up to be displayed outside the monitor
Closes #5339
- - - - -
1 changed file:
- tryton/tryton/common/datetime_.py
Changes:
=====================================
tryton/tryton/common/datetime_.py
=====================================
@@ -129,4 +129,6 @@
self.__date.month - 1, self.__date.year)
self.__calendar.select_day(self.__date.day)
self.__cal_popup.set_transient_for(self.get_toplevel())
+ # Show popup before because position needs the popup allocation
+ popup_show(self.__cal_popup)
popup_position(self, self.__cal_popup)
@@ -132,5 +134,4 @@
popup_position(self, self.__cal_popup)
- popup_show(self.__cal_popup)
def cal_popup_changed(self, calendar):
year, month, day = self.__calendar.get_date()
@@ -532,4 +533,5 @@
def popup_position(widget, popup):
allocation = widget.get_allocation()
+ popup_allocation = popup.get_allocation()
x, y = widget.get_window().get_root_coords(allocation.x, allocation.y)
@@ -535,5 +537,15 @@
x, y = widget.get_window().get_root_coords(allocation.x, allocation.y)
- popup.move(x, y + allocation.height)
+ display = widget.get_display()
+ monitor = display.get_monitor_at_window(widget.get_window())
+ monitor_geometry = monitor.get_geometry()
+ if (monitor_geometry.height
+ < y + allocation.height + popup_allocation.height):
+ y -= popup_allocation.height
+ else:
+ y += allocation.height
+ if monitor_geometry.width < x + popup_allocation.width:
+ x -= popup_allocation.width
+ popup.move(x, y)
def popup_show(popup):
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/c1152d2d99b2d4d251f8521a0158af46b65b31e3
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/c1152d2d99b2d4d251f8521a0158af46b65b31e3
You're receiving this email because of your account on foss.heptapod.net.