MCPcopy Index your code
hub / github.com/python/cpython / get_max_height_and_y_coord

Method get_max_height_and_y_coord

Lib/idlelib/zoomheight.py:60–107  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 return False
59
60 def get_max_height_and_y_coord(self):
61 top = self.top
62
63 screen_dimensions = (top.winfo_screenwidth(),
64 top.winfo_screenheight())
65 if screen_dimensions not in self._max_height_and_y_coords:
66 orig_state = top.wm_state()
67
68 # Get window geometry info for maximized windows.
69 try:
70 top.wm_state('zoomed')
71 except tkinter.TclError:
72 # The 'zoomed' state is not supported by some esoteric WMs,
73 # such as Xvfb.
74 raise WmInfoGatheringError(
75 'Failed getting geometry of maximized windows, because ' +
76 'the "zoomed" window state is unavailable.')
77 top.update()
78 maxwidth, maxheight, maxx, maxy = get_window_geometry(top)
79 if sys.platform == 'win32':
80 # On Windows, the returned Y coordinate is the one before
81 # maximizing, so we use 0 which is correct unless a user puts
82 # their dock on the top of the screen (very rare).
83 maxy = 0
84 maxrooty = top.winfo_rooty()
85
86 # Get the "root y" coordinate for non-maximized windows with their
87 # y coordinate set to that of maximized windows. This is needed
88 # to properly handle different title bar heights for non-maximized
89 # vs. maximized windows, as seen e.g. in Windows 10.
90 top.wm_state('normal')
91 top.update()
92 orig_geom = get_window_geometry(top)
93 max_y_geom = orig_geom[:3] + (maxy,)
94 set_window_geometry(top, max_y_geom)
95 top.update()
96 max_y_geom_rooty = top.winfo_rooty()
97
98 # Adjust the maximum window height to account for the different
99 # title bar heights of non-maximized vs. maximized windows.
100 maxheight += maxrooty - max_y_geom_rooty
101
102 self._max_height_and_y_coords[screen_dimensions] = maxheight, maxy
103
104 set_window_geometry(top, orig_geom)
105 top.wm_state(orig_state)
106
107 return self._max_height_and_y_coords[screen_dimensions]
108
109
110def get_window_geometry(top):

Callers 1

zoom_heightMethod · 0.95

Calls 8

get_window_geometryFunction · 0.85
set_window_geometryFunction · 0.85
winfo_screenwidthMethod · 0.80
winfo_screenheightMethod · 0.80
wm_stateMethod · 0.80
winfo_rootyMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected