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
This commit is contained in:
Akemi 2016-10-25 15:59:13 +02:00 committed by Stefano Pigozzi
parent 98e7b4e538
commit aceeeaf9bb
4 changed files with 19 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -38,6 +38,7 @@ typedef struct mp_vo_opts {
int keepaspect;
int keepaspect_window;
int hidpi_window_scale;
int64_t WinID;

View File

@ -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];
}