summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-04-22 15:52:07 +0300
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2021-04-23 10:45:51 +0300
commitf60e327e49e5ccf40a4988716be7ccae0882d36e (patch)
tree51708145a825091cdad69f4df02535b91f960b98
parent954f6ac7bfd68ddfff7d89fe0ec6319710fa5940 (diff)
downloadmpv-f60e327e49e5ccf40a4988716be7ccae0882d36e.tar.bz2
mpv-f60e327e49e5ccf40a4988716be7ccae0882d36e.tar.xz
win32: fit_window_on_screen: simplify, add comments
The fit_on_screen logic was a bit twisted. Simplify it a bit and update few comments to explain better what it's used for. Note that the new logic is not identical to before, but its intent should now be clearer. This means there might be regressions or improvements at edge cases. If followup fixes are needed, then we should keep the intent clear. Most likely though that it's fine.
-rw-r--r--video/out/w32_common.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 1a84e0de55..59cfd6199d 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -103,8 +103,9 @@ struct vo_w32_state {
bool current_fs;
bool toggle_fs; // whether the current fullscreen state needs to be switched
- RECT windowrc; // currently known window rect
- RECT prev_windowrc; // last non-fullscreen window rect
+ // Note: maximized state doesn't involve nor modify windowrc
+ RECT windowrc; // currently known normal/fullscreen window client rect
+ RECT prev_windowrc; // saved normal window client rect while in fullscreen
// video size
uint32_t o_dwidth;
@@ -129,7 +130,13 @@ struct vo_w32_state {
// UTF-16 decoding state for WM_CHAR and VK_PACKET
int high_surrogate;
- // Whether to fit the window on screen on next window state updating
+ // Fit the window to one monitor working area next time it's not fullscreen
+ // and not maximized. Used once after every new "untrusted" size comes from
+ // mpv, else we assume that the last known size is valid and don't fit.
+ // FIXME: on a multi-monitor setup one bit is not enough, because the first
+ // fit (autofit etc) should be to one monitor, but later size changes from
+ // mpv like window-scale (VOCTRL_SET_UNFS_WINDOW_SIZE) should allow the
+ // entire virtual desktop area - but we still limit to one monitor size.
bool fit_on_screen;
ITaskbarList2 *taskbar_list;
@@ -848,11 +855,10 @@ static void fit_window_on_screen(struct vo_w32_state *w32)
}
// Calculate new fullscreen state and change window size and position.
-// returns true if fullscreen state was changed.
-static bool update_fullscreen_state(struct vo_w32_state *w32)
+static void update_fullscreen_state(struct vo_w32_state *w32)
{
if (w32->parent)
- return false;
+ return;
bool new_fs = w32->opts->fullscreen;
if (w32->toggle_fs) {
@@ -884,7 +890,6 @@ static bool update_fullscreen_state(struct vo_w32_state *w32)
MP_VERBOSE(w32, "reset window bounds: %d:%d:%d:%d\n",
(int)w32->windowrc.left, (int)w32->windowrc.top,
(int)rect_w(w32->windowrc), (int)rect_h(w32->windowrc));
- return toggle_fs;
}
static void update_minimized_state(struct vo_w32_state *w32)
@@ -978,17 +983,13 @@ static void reinit_window_state(struct vo_w32_state *w32)
return;
// The order matters: fs state should be updated prior to changing styles
- bool toggle_fs = update_fullscreen_state(w32);
+ update_fullscreen_state(w32);
update_window_style(w32);
- // Assume that the window has already been fit on screen before switching fs
- if (!toggle_fs || w32->fit_on_screen) {
- if (!w32->current_fs && !IsMaximized(w32->window))
- fit_window_on_screen(w32);
-
- // The fullscreen state might still be active, so set the flag
- // to fit on screen next time the window leaves the fullscreen.
- w32->fit_on_screen = w32->current_fs;
+ // fit_on_screen is applied at most once when/if applicable (normal win).
+ if (w32->fit_on_screen && !w32->current_fs && !IsMaximized(w32->window)) {
+ fit_window_on_screen(w32);
+ w32->fit_on_screen = false;
}
// Show and activate the window after all window state parameters were set