Skip to content

Conversation

@melwyncarlo
Copy link
Contributor

PR summary

This PR closes #26733.

Basically, the change in DPI is signaled when resizing or changing the device scale, and not when the canvas is launched/loaded, hence the issue.

This video demonstrates the problem and the fix.

self.window.protocol("WM_DELETE_WINDOW", destroy)
self.window.deiconify()
self.canvas._tkcanvas.focus_set()
if self._window_dpi.get() != 96:
Copy link
Member

Choose a reason for hiding this comment

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

why hard-code 96?

@tacaswell
Copy link
Member

How does this intersect with the discussion in #21875 ?

(GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow");
if (GetDpiForWindowPtr == NULL) {
FreeLibrary(user32);
return py::cast(false);
Copy link
Member

Choose a reason for hiding this comment

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

Is completely returning here correct? Is there a case where we may not be able to get the methods for managing the dpi but still need to run the setWindowSubclass method?

// window_dpi variable stored on interp.
typedef UINT (WINAPI *GetDpiForWindow_t)(HWND);
GetDpiForWindow_t GetDpiForWindowPtr =
(GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the shorter style for casting as in #30615.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure sticks out of window after setting window to full screen from code

3 participants