mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 21:20:09 +00:00
quartz: Add monitor support
This is a backport of a patch by Tom Schoonjans, https://bugzilla.gnome.org/show_bug.cgi?id=779184
This commit is contained in:
parent
2f851530f4
commit
2ad14d393b
@ -29,6 +29,7 @@ libgdk_quartz_la_SOURCES = \
|
|||||||
gdkdevicemanager-core-quartz.c \
|
gdkdevicemanager-core-quartz.c \
|
||||||
gdkdevicemanager-core-quartz.h \
|
gdkdevicemanager-core-quartz.h \
|
||||||
gdkdisplay-quartz.c \
|
gdkdisplay-quartz.c \
|
||||||
|
gdkdisplay-quartz.h \
|
||||||
gdkdisplaymanager-quartz.c \
|
gdkdisplaymanager-quartz.c \
|
||||||
gdkdnd-quartz.c \
|
gdkdnd-quartz.c \
|
||||||
gdkdnd-quartz.h \
|
gdkdnd-quartz.h \
|
||||||
@ -38,6 +39,8 @@ libgdk_quartz_la_SOURCES = \
|
|||||||
gdkglcontext-quartz.h \
|
gdkglcontext-quartz.h \
|
||||||
gdkglobals-quartz.c \
|
gdkglobals-quartz.c \
|
||||||
gdkkeys-quartz.c \
|
gdkkeys-quartz.c \
|
||||||
|
gdkmonitor-quartz.c \
|
||||||
|
gdkmonitor-quartz.h \
|
||||||
gdkprivate-quartz.h \
|
gdkprivate-quartz.h \
|
||||||
gdkproperty-quartz.c \
|
gdkproperty-quartz.c \
|
||||||
gdkquartz.h \
|
gdkquartz.h \
|
||||||
@ -62,6 +65,7 @@ libgdkquartzinclude_HEADERS = \
|
|||||||
gdkquartzdisplaymanager.h \
|
gdkquartzdisplaymanager.h \
|
||||||
gdkquartzdnd.h \
|
gdkquartzdnd.h \
|
||||||
gdkquartzkeys.h \
|
gdkquartzkeys.h \
|
||||||
|
gdkquartzmonitor.h \
|
||||||
gdkquartzscreen.h \
|
gdkquartzscreen.h \
|
||||||
gdkquartzutils.h \
|
gdkquartzutils.h \
|
||||||
gdkquartzvisual.h \
|
gdkquartzvisual.h \
|
||||||
|
@ -26,18 +26,11 @@
|
|||||||
#include "gdkquartzwindow.h"
|
#include "gdkquartzwindow.h"
|
||||||
#include "gdkquartzdisplay.h"
|
#include "gdkquartzdisplay.h"
|
||||||
#include "gdkquartzdevicemanager-core.h"
|
#include "gdkquartzdevicemanager-core.h"
|
||||||
|
#include "gdkscreen.h"
|
||||||
|
#include "gdkmonitorprivate.h"
|
||||||
|
#include "gdkdisplay-quartz.h"
|
||||||
|
|
||||||
|
|
||||||
struct _GdkQuartzDisplay
|
|
||||||
{
|
|
||||||
GdkDisplay display;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GdkQuartzDisplayClass
|
|
||||||
{
|
|
||||||
GdkDisplayClass display_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
static GdkWindow *
|
static GdkWindow *
|
||||||
gdk_quartz_display_get_default_group (GdkDisplay *display)
|
gdk_quartz_display_get_default_group (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
@ -196,12 +189,45 @@ gdk_quartz_display_notify_startup_complete (GdkDisplay *display,
|
|||||||
/* FIXME: Implement? */
|
/* FIXME: Implement? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
gdk_quartz_display_get_n_monitors (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
|
||||||
|
|
||||||
|
return quartz_display->monitors->len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GdkMonitor *
|
||||||
|
gdk_quartz_display_get_monitor (GdkDisplay *display,
|
||||||
|
int monitor_num)
|
||||||
|
{
|
||||||
|
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
|
||||||
|
|
||||||
|
if (0 <= monitor_num || monitor_num < quartz_display->monitors->len)
|
||||||
|
return (GdkMonitor *)quartz_display->monitors->pdata[monitor_num];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GdkMonitor *
|
||||||
|
gdk_quartz_display_get_primary_monitor (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
|
||||||
|
|
||||||
|
return quartz_display->monitors->pdata[0];
|
||||||
|
}
|
||||||
|
|
||||||
G_DEFINE_TYPE (GdkQuartzDisplay, gdk_quartz_display, GDK_TYPE_DISPLAY)
|
G_DEFINE_TYPE (GdkQuartzDisplay, gdk_quartz_display, GDK_TYPE_DISPLAY)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_quartz_display_init (GdkQuartzDisplay *display)
|
gdk_quartz_display_init (GdkQuartzDisplay *display)
|
||||||
{
|
{
|
||||||
|
GDK_QUARTZ_ALLOC_POOL;
|
||||||
|
|
||||||
|
display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
|
|
||||||
|
GDK_QUARTZ_RELEASE_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -209,6 +235,8 @@ gdk_quartz_display_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
|
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
|
||||||
|
|
||||||
|
g_ptr_array_free (display_quartz->monitors, TRUE);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gdk_quartz_display_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gdk_quartz_display_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +296,9 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
|
|||||||
display_class->convert_selection = _gdk_quartz_display_convert_selection;
|
display_class->convert_selection = _gdk_quartz_display_convert_selection;
|
||||||
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
|
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
|
||||||
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
|
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
|
||||||
|
display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
|
||||||
|
display_class->get_monitor = gdk_quartz_display_get_monitor;
|
||||||
|
display_class->get_primary_monitor = gdk_quartz_display_get_primary_monitor;
|
||||||
|
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
|
|
||||||
|
58
gdk/quartz/gdkmonitor-quartz.c
Normal file
58
gdk/quartz/gdkmonitor-quartz.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2017 Tom Schoonjans
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdkmonitor-quartz.h"
|
||||||
|
#include "gdkscreen-quartz.h"
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GdkQuartzMonitor, gdk_quartz_monitor, GDK_TYPE_MONITOR)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_quartz_monitor_get_workarea (GdkMonitor *monitor,
|
||||||
|
GdkRectangle *dest)
|
||||||
|
{
|
||||||
|
GdkQuartzScreen *quartz_screen = GDK_QUARTZ_SCREEN(gdk_display_get_default_screen (monitor->display));
|
||||||
|
GdkQuartzMonitor *quartz_monitor = GDK_QUARTZ_MONITOR(monitor);
|
||||||
|
|
||||||
|
GDK_QUARTZ_ALLOC_POOL;
|
||||||
|
|
||||||
|
NSRect rect = [quartz_monitor->nsscreen visibleFrame];
|
||||||
|
|
||||||
|
dest->x = rect.origin.x - quartz_screen->min_x;
|
||||||
|
dest->y = quartz_screen->height - (rect.origin.y + rect.size.height) + quartz_screen->min_y;
|
||||||
|
dest->width = rect.size.width;
|
||||||
|
dest->height = rect.size.height;
|
||||||
|
|
||||||
|
GDK_QUARTZ_RELEASE_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_quartz_monitor_init (GdkQuartzMonitor *monitor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_quartz_monitor_class_init (GdkQuartzMonitorClass *class)
|
||||||
|
{
|
||||||
|
GDK_MONITOR_CLASS (class)->get_workarea = gdk_quartz_monitor_get_workarea;
|
||||||
|
}
|
||||||
|
|
41
gdk/quartz/gdkmonitor-quartz.h
Normal file
41
gdk/quartz/gdkmonitor-quartz.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2017 Tom Schoonjans
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GDK_QUARTZ_MONITOR_PRIVATE_H__
|
||||||
|
#define __GDK_QUARTZ_MONITOR_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdkmonitorprivate.h"
|
||||||
|
|
||||||
|
#include "gdkquartzmonitor.h"
|
||||||
|
#include "gdkprivate-quartz.h"
|
||||||
|
|
||||||
|
struct _GdkQuartzMonitor
|
||||||
|
{
|
||||||
|
GdkMonitor parent;
|
||||||
|
|
||||||
|
NSScreen *nsscreen;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GdkQuartzMonitorClass {
|
||||||
|
GdkMonitorClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -116,17 +116,6 @@ void _gdk_quartz_display_get_maximal_cursor_size (GdkDisplay *display,
|
|||||||
guint *width,
|
guint *width,
|
||||||
guint *height);
|
guint *height);
|
||||||
|
|
||||||
/* Display methods - window */
|
|
||||||
void _gdk_quartz_display_before_process_all_updates (GdkDisplay *display);
|
|
||||||
void _gdk_quartz_display_after_process_all_updates (GdkDisplay *display);
|
|
||||||
void _gdk_quartz_display_create_window_impl (GdkDisplay *display,
|
|
||||||
GdkWindow *window,
|
|
||||||
GdkWindow *real_parent,
|
|
||||||
GdkScreen *screen,
|
|
||||||
GdkEventMask event_mask,
|
|
||||||
GdkWindowAttr *attributes,
|
|
||||||
gint attributes_mask);
|
|
||||||
|
|
||||||
/* Display methods - keymap */
|
/* Display methods - keymap */
|
||||||
GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display);
|
GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display);
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ G_END_DECLS
|
|||||||
#include <gdk/quartz/gdkquartzdisplaymanager.h>
|
#include <gdk/quartz/gdkquartzdisplaymanager.h>
|
||||||
#include <gdk/quartz/gdkquartzdnd.h>
|
#include <gdk/quartz/gdkquartzdnd.h>
|
||||||
#include <gdk/quartz/gdkquartzkeys.h>
|
#include <gdk/quartz/gdkquartzkeys.h>
|
||||||
|
#include <gdk/quartz/gdkquartzmonitor.h>
|
||||||
#include <gdk/quartz/gdkquartzscreen.h>
|
#include <gdk/quartz/gdkquartzscreen.h>
|
||||||
#include <gdk/quartz/gdkquartzutils.h>
|
#include <gdk/quartz/gdkquartzutils.h>
|
||||||
#include <gdk/quartz/gdkquartzvisual.h>
|
#include <gdk/quartz/gdkquartzvisual.h>
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
#include "gdkprivate-quartz.h"
|
#include "gdkprivate-quartz.h"
|
||||||
|
#include "gdkdisplay-quartz.h"
|
||||||
|
#include "gdkmonitor-quartz.h"
|
||||||
|
|
||||||
|
|
||||||
/* A couple of notes about this file are in order. In GDK, a
|
/* A couple of notes about this file are in order. In GDK, a
|
||||||
@ -66,6 +68,8 @@ static void display_reconfiguration_callback (CGDirectDisplayID displ
|
|||||||
CGDisplayChangeSummaryFlags flags,
|
CGDisplayChangeSummaryFlags flags,
|
||||||
void *userInfo);
|
void *userInfo);
|
||||||
|
|
||||||
|
static gint get_mm_from_pixels (NSScreen *screen, int pixels);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GdkQuartzScreen, gdk_quartz_screen, GDK_TYPE_SCREEN);
|
G_DEFINE_TYPE (GdkQuartzScreen, gdk_quartz_screen, GDK_TYPE_SCREEN);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -103,21 +107,18 @@ gdk_quartz_screen_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (gdk_quartz_screen_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gdk_quartz_screen_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_quartz_screen_screen_rects_free (GdkQuartzScreen *screen)
|
|
||||||
{
|
|
||||||
screen->n_screens = 0;
|
|
||||||
g_clear_pointer (&screen->screen_rects, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_quartz_screen_finalize (GObject *object)
|
gdk_quartz_screen_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GdkQuartzScreen *screen = GDK_QUARTZ_SCREEN (object);
|
GdkQuartzScreen *screen = GDK_QUARTZ_SCREEN (object);
|
||||||
|
|
||||||
gdk_quartz_screen_screen_rects_free (screen);
|
G_OBJECT_CLASS (gdk_quartz_screen_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Protocol to build cleanly for OSX < 10.7 */
|
||||||
|
@protocol ScaleFactor
|
||||||
|
- (CGFloat) backingScaleFactor;
|
||||||
|
@end
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
||||||
@ -125,11 +126,14 @@ gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
|||||||
NSArray *array;
|
NSArray *array;
|
||||||
int i;
|
int i;
|
||||||
int max_x, max_y;
|
int max_x, max_y;
|
||||||
|
GdkDisplay *display = gdk_screen_get_display (GDK_SCREEN (screen));
|
||||||
|
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (display);
|
||||||
|
|
||||||
|
g_ptr_array_free (display_quartz->monitors, TRUE);
|
||||||
|
display_quartz->monitors = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
|
|
||||||
GDK_QUARTZ_ALLOC_POOL;
|
GDK_QUARTZ_ALLOC_POOL;
|
||||||
|
|
||||||
gdk_quartz_screen_screen_rects_free (screen);
|
|
||||||
|
|
||||||
array = [NSScreen screens];
|
array = [NSScreen screens];
|
||||||
|
|
||||||
screen->width = 0;
|
screen->width = 0;
|
||||||
@ -144,6 +148,12 @@ gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < [array count]; i++)
|
for (i = 0; i < [array count]; i++)
|
||||||
{
|
{
|
||||||
|
GdkQuartzMonitor *monitor = g_object_new (GDK_TYPE_QUARTZ_MONITOR,
|
||||||
|
"display", display,
|
||||||
|
NULL);
|
||||||
|
g_ptr_array_add (display_quartz->monitors, monitor);
|
||||||
|
monitor->nsscreen = [array objectAtIndex:i];
|
||||||
|
|
||||||
NSRect rect = [[array objectAtIndex:i] frame];
|
NSRect rect = [[array objectAtIndex:i] frame];
|
||||||
|
|
||||||
screen->min_x = MIN (screen->min_x, rect.origin.x);
|
screen->min_x = MIN (screen->min_x, rect.origin.x);
|
||||||
@ -156,22 +166,31 @@ gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
|||||||
screen->width = max_x - screen->min_x;
|
screen->width = max_x - screen->min_x;
|
||||||
screen->height = max_y - screen->min_y;
|
screen->height = max_y - screen->min_y;
|
||||||
|
|
||||||
screen->n_screens = [array count];
|
for (i = 0; i < [array count] ; i++)
|
||||||
screen->screen_rects = g_new0 (GdkRectangle, screen->n_screens);
|
|
||||||
|
|
||||||
for (i = 0; i < screen->n_screens; i++)
|
|
||||||
{
|
{
|
||||||
NSScreen *nsscreen;
|
NSScreen *nsscreen;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
GdkMonitor *monitor;
|
||||||
|
|
||||||
|
monitor = GDK_MONITOR(display_quartz->monitors->pdata[i]);
|
||||||
nsscreen = [array objectAtIndex:i];
|
nsscreen = [array objectAtIndex:i];
|
||||||
rect = [nsscreen frame];
|
rect = [nsscreen frame];
|
||||||
|
|
||||||
screen->screen_rects[i].x = rect.origin.x - screen->min_x;
|
monitor->geometry.x = rect.origin.x - screen->min_x;
|
||||||
screen->screen_rects[i].y
|
monitor->geometry.y
|
||||||
= screen->height - (rect.origin.y + rect.size.height) + screen->min_y;
|
= screen->height - (rect.origin.y + rect.size.height) + screen->min_y;
|
||||||
screen->screen_rects[i].width = rect.size.width;
|
monitor->geometry.width = rect.size.width;
|
||||||
screen->screen_rects[i].height = rect.size.height;
|
monitor->geometry.height = rect.size.height;
|
||||||
|
if (gdk_quartz_osx_version() >= GDK_OSX_LION)
|
||||||
|
monitor->scale_factor = [(id <ScaleFactor>) nsscreen backingScaleFactor];
|
||||||
|
else
|
||||||
|
monitor->scale_factor = 1;
|
||||||
|
monitor->width_mm = get_mm_from_pixels(nsscreen, monitor->geometry.width);
|
||||||
|
monitor->height_mm = get_mm_from_pixels(nsscreen, monitor->geometry.height);
|
||||||
|
monitor->refresh_rate = 0; // unknown
|
||||||
|
monitor->manufacturer = NULL; // unknown
|
||||||
|
monitor->model = NULL; // unknown
|
||||||
|
monitor->subpixel_layout = GDK_SUBPIXEL_LAYOUT_UNKNOWN; // unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_QUARTZ_RELEASE_POOL;
|
GDK_QUARTZ_RELEASE_POOL;
|
||||||
@ -331,133 +350,6 @@ get_mm_from_pixels (NSScreen *screen, int pixels)
|
|||||||
return (pixels / dpi) * 25.4;
|
return (pixels / dpi) * 25.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSScreen *
|
|
||||||
get_nsscreen_for_monitor (gint monitor_num)
|
|
||||||
{
|
|
||||||
NSArray *array;
|
|
||||||
NSScreen *screen;
|
|
||||||
|
|
||||||
GDK_QUARTZ_ALLOC_POOL;
|
|
||||||
|
|
||||||
array = [NSScreen screens];
|
|
||||||
screen = [array objectAtIndex:monitor_num];
|
|
||||||
|
|
||||||
GDK_QUARTZ_RELEASE_POOL;
|
|
||||||
|
|
||||||
return screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_width_mm (GdkScreen *screen)
|
|
||||||
{
|
|
||||||
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
|
||||||
GDK_QUARTZ_SCREEN (screen)->width);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_height_mm (GdkScreen *screen)
|
|
||||||
{
|
|
||||||
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
|
||||||
GDK_QUARTZ_SCREEN (screen)->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_n_monitors (GdkScreen *screen)
|
|
||||||
{
|
|
||||||
return GDK_QUARTZ_SCREEN (screen)->n_screens;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_primary_monitor (GdkScreen *screen)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_monitor_width_mm (GdkScreen *screen,
|
|
||||||
gint monitor_num)
|
|
||||||
{
|
|
||||||
return get_mm_from_pixels (get_nsscreen_for_monitor (monitor_num),
|
|
||||||
GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num].width);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
gdk_quartz_screen_get_monitor_height_mm (GdkScreen *screen,
|
|
||||||
gint monitor_num)
|
|
||||||
{
|
|
||||||
return get_mm_from_pixels (get_nsscreen_for_monitor (monitor_num),
|
|
||||||
GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num].height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
gdk_quartz_screen_get_monitor_plug_name (GdkScreen *screen,
|
|
||||||
gint monitor_num)
|
|
||||||
{
|
|
||||||
/* FIXME: Is there some useful name we could use here? */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_quartz_screen_get_monitor_geometry (GdkScreen *screen,
|
|
||||||
gint monitor_num,
|
|
||||||
GdkRectangle *dest)
|
|
||||||
{
|
|
||||||
*dest = GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gdk_quartz_screen_get_monitor_workarea (GdkScreen *screen,
|
|
||||||
gint monitor_num,
|
|
||||||
GdkRectangle *dest)
|
|
||||||
{
|
|
||||||
GdkQuartzScreen *quartz_screen = GDK_QUARTZ_SCREEN (screen);
|
|
||||||
NSArray *array;
|
|
||||||
NSScreen *nsscreen;
|
|
||||||
NSRect rect;
|
|
||||||
|
|
||||||
GDK_QUARTZ_ALLOC_POOL;
|
|
||||||
|
|
||||||
array = [NSScreen screens];
|
|
||||||
nsscreen = [array objectAtIndex:monitor_num];
|
|
||||||
rect = [nsscreen visibleFrame];
|
|
||||||
|
|
||||||
dest->x = rect.origin.x - quartz_screen->min_x;
|
|
||||||
dest->y = quartz_screen->height - (rect.origin.y + rect.size.height) + quartz_screen->min_y;
|
|
||||||
dest->width = rect.size.width;
|
|
||||||
dest->height = rect.size.height;
|
|
||||||
|
|
||||||
GDK_QUARTZ_RELEASE_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Protocol to build cleanly for OSX < 10.7 */
|
|
||||||
@protocol ScaleFactor
|
|
||||||
- (CGFloat) backingScaleFactor;
|
|
||||||
@end
|
|
||||||
|
|
||||||
gint
|
|
||||||
_gdk_quartz_screen_get_monitor_scale_factor (GdkScreen *screen,
|
|
||||||
gint monitor_num)
|
|
||||||
{
|
|
||||||
GdkQuartzScreen *quartz_screen;
|
|
||||||
NSArray *array;
|
|
||||||
NSScreen *nsscreen;
|
|
||||||
gint scale_factor = 1;
|
|
||||||
|
|
||||||
quartz_screen = GDK_QUARTZ_SCREEN (screen);
|
|
||||||
|
|
||||||
GDK_QUARTZ_ALLOC_POOL;
|
|
||||||
|
|
||||||
array = [NSScreen screens];
|
|
||||||
nsscreen = [array objectAtIndex:monitor_num];
|
|
||||||
|
|
||||||
if (gdk_quartz_osx_version() >= GDK_OSX_LION)
|
|
||||||
scale_factor = [(id <ScaleFactor>) nsscreen backingScaleFactor];
|
|
||||||
|
|
||||||
GDK_QUARTZ_RELEASE_POOL;
|
|
||||||
|
|
||||||
return scale_factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
gdk_quartz_screen_make_display_name (GdkScreen *screen)
|
gdk_quartz_screen_make_display_name (GdkScreen *screen)
|
||||||
{
|
{
|
||||||
@ -482,6 +374,20 @@ gdk_quartz_screen_is_composited (GdkScreen *screen)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gdk_quartz_screen_get_width_mm (GdkScreen *screen)
|
||||||
|
{
|
||||||
|
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
||||||
|
GDK_QUARTZ_SCREEN (screen)->width);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gdk_quartz_screen_get_height_mm (GdkScreen *screen)
|
||||||
|
{
|
||||||
|
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
||||||
|
GDK_QUARTZ_SCREEN (screen)->height);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
|
gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
|
||||||
{
|
{
|
||||||
@ -498,13 +404,6 @@ gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
|
|||||||
screen_class->get_height_mm = gdk_quartz_screen_get_height_mm;
|
screen_class->get_height_mm = gdk_quartz_screen_get_height_mm;
|
||||||
screen_class->get_number = gdk_quartz_screen_get_number;
|
screen_class->get_number = gdk_quartz_screen_get_number;
|
||||||
screen_class->get_root_window = gdk_quartz_screen_get_root_window;
|
screen_class->get_root_window = gdk_quartz_screen_get_root_window;
|
||||||
screen_class->get_n_monitors = gdk_quartz_screen_get_n_monitors;
|
|
||||||
screen_class->get_primary_monitor = gdk_quartz_screen_get_primary_monitor;
|
|
||||||
screen_class->get_monitor_width_mm = gdk_quartz_screen_get_monitor_width_mm;
|
|
||||||
screen_class->get_monitor_height_mm = gdk_quartz_screen_get_monitor_height_mm;
|
|
||||||
screen_class->get_monitor_plug_name = gdk_quartz_screen_get_monitor_plug_name;
|
|
||||||
screen_class->get_monitor_geometry = gdk_quartz_screen_get_monitor_geometry;
|
|
||||||
screen_class->get_monitor_workarea = gdk_quartz_screen_get_monitor_workarea;
|
|
||||||
screen_class->is_composited = gdk_quartz_screen_is_composited;
|
screen_class->is_composited = gdk_quartz_screen_is_composited;
|
||||||
screen_class->make_display_name = gdk_quartz_screen_make_display_name;
|
screen_class->make_display_name = gdk_quartz_screen_make_display_name;
|
||||||
screen_class->get_active_window = gdk_quartz_screen_get_active_window;
|
screen_class->get_active_window = gdk_quartz_screen_get_active_window;
|
||||||
@ -522,5 +421,4 @@ gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
|
|||||||
screen_class->query_depths = _gdk_quartz_screen_query_depths;
|
screen_class->query_depths = _gdk_quartz_screen_query_depths;
|
||||||
screen_class->query_visual_types = _gdk_quartz_screen_query_visual_types;
|
screen_class->query_visual_types = _gdk_quartz_screen_query_visual_types;
|
||||||
screen_class->list_visuals = _gdk_quartz_screen_list_visuals;
|
screen_class->list_visuals = _gdk_quartz_screen_list_visuals;
|
||||||
screen_class->get_monitor_scale_factor = _gdk_quartz_screen_get_monitor_scale_factor;
|
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,6 @@ struct _GdkQuartzScreen
|
|||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
int n_screens;
|
|
||||||
GdkRectangle *screen_rects;
|
|
||||||
|
|
||||||
guint screen_changed_id;
|
guint screen_changed_id;
|
||||||
|
|
||||||
guint emit_monitors_changed : 1;
|
guint emit_monitors_changed : 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user