summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2016-10-25 15:59:13 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2016-11-11 21:37:04 +0100
commitaceeeaf9bb7d3549c22557b8afe50838119f0b89 (patch)
tree612cf321968d79d0cae33c166bfe5626eb6a70c8
parent98e7b4e538d42b6df1aa3c5f4a4c6c162a06b737 (diff)
downloadmpv-aceeeaf9bb7d3549c22557b8afe50838119f0b89.tar.bz2
mpv-aceeeaf9bb7d3549c22557b8afe50838119f0b89.tar.xz
cocoa: option to scale window by HiDPI scale factor
Deactivating this options makes it possible to circumvent the default OS X behavior of using points. Windows on HiDPI resolutions won't open in double the size anymore and videos are display in their native resolution when windowed. Fixes #3716
-rw-r--r--DOCS/man/options.rst7
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--video/out/cocoa_common.m11
4 files changed, 19 insertions, 2 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 6f904b2495..b0fbaf7b93 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2353,6 +2353,13 @@ Window
- ``--monitoraspect=4:3`` or ``--monitoraspect=1.3333``
- ``--monitoraspect=16:9`` or ``--monitoraspect=1.7777``
+``--hidpi-window-scale``, ``--no-hidpi-window-scale``
+ (OS X only)
+ Scale the window size according to the backing scale factor (default: yes).
+ On regular HiDPI resolutions the window opens with double the size but appears
+ as having the same size as on none-HiDPI resolutions. This is the default OS X
+ behavior.
+
``--monitorpixelaspect=<ratio>``
Set the aspect of a single pixel of your monitor or TV screen (default:
1). A value of 1 means square pixels (correct for (almost?) all LCDs). See
diff --git a/options/options.c b/options/options.c
index 7a4deae776..e4c682303b 100644
--- a/options/options.c
+++ b/options/options.c
@@ -187,6 +187,7 @@ static const m_option_t mp_vo_opt_list[] = {
OPT_FLAG("fs-black-out-screens", fs_black_out_screens, 0),
OPT_FLAG("keepaspect", keepaspect, UPDATE_VIDEOPOS),
OPT_FLAG("keepaspect-window", keepaspect_window, 0),
+ OPT_FLAG("hidpi-window-scale", hidpi_window_scale, 0),
#if HAVE_X11
OPT_CHOICE("x11-netwm", x11_netwm, 0,
({"auto", 0}, {"no", -1}, {"yes", 1})),
@@ -216,6 +217,7 @@ const struct m_sub_options vo_sub_opts = {
.panscan = 0.0f,
.keepaspect = 1,
.keepaspect_window = 1,
+ .hidpi_window_scale = 1,
.taskbar_progress = 1,
.border = 1,
.fit_border = 1,
diff --git a/options/options.h b/options/options.h
index 160223d3e1..4ddf9d1490 100644
--- a/options/options.h
+++ b/options/options.h
@@ -38,6 +38,7 @@ typedef struct mp_vo_opts {
int keepaspect;
int keepaspect_window;
+ int hidpi_window_scale;
int64_t WinID;
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index ba241f42cc..719169df48 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -121,9 +121,14 @@ static void run_on_main_thread(struct vo *vo, void(^block)(void))
static void queue_new_video_size(struct vo *vo, int w, int h)
{
struct vo_cocoa_state *s = vo->cocoa;
+ struct mp_vo_opts *opts = vo->opts;
if ([s->window conformsToProtocol: @protocol(MpvSizing)]) {
id<MpvSizing> win = (id<MpvSizing>) s->window;
- [win queueNewVideoSize:NSMakeSize(w, h)];
+ NSRect r = NSMakeRect(0, 0, w, h);
+ if(!opts->hidpi_window_scale) {
+ r = [s->current_screen convertRectFromBacking:r];
+ }
+ [win queueNewVideoSize:NSMakeSize(r.size.width, r.size.height)];
}
}
@@ -488,8 +493,10 @@ static void create_ui(struct vo *vo, struct mp_rect *win, int geo_flags)
if (s->embedded) {
parent = (NSView *) (intptr_t) opts->WinID;
} else {
- const NSRect wr =
+ NSRect wr =
NSMakeRect(win->x0, win->y0, win->x1 - win->x0, win->y1 - win->y0);
+ if(!opts->hidpi_window_scale)
+ wr = [s->current_screen convertRectFromBacking:wr];
s->window = create_window(wr, s->current_screen, opts->border, adapter);
parent = [s->window contentView];
}