2005-11-22 10:03:32 +00:00
|
|
|
/* gdkscreen-quartz.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Imendio AB
|
2010-12-22 13:34:15 +00:00
|
|
|
* Copyright (C) 2009,2010 Kristian Rietveld <kris@gtk.org>
|
2005-11-22 10:03:32 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
2009-10-12 07:55:45 +00:00
|
|
|
|
|
|
|
|
2009-11-15 14:29:45 +00:00
|
|
|
/* A couple of notes about this file are in order. In GDK, a
|
|
|
|
* GdkScreen can contain multiple monitors. A GdkScreen has an
|
|
|
|
* associated root window, in which the monitors are placed. The
|
|
|
|
* root window "spans" all monitors. The origin is at the top-left
|
|
|
|
* corner of the root window.
|
|
|
|
*
|
|
|
|
* Cocoa works differently. The system has a "screen" (NSScreen) for
|
|
|
|
* each monitor that is connected (note the conflicting definitions
|
|
|
|
* of screen). The screen containing the menu bar is screen 0 and the
|
|
|
|
* bottom-left corner of this screen is the origin of the "monitor
|
|
|
|
* coordinate space". All other screens are positioned according to this
|
|
|
|
* origin. If the menu bar is on a secondary screen (for example on
|
|
|
|
* a monitor hooked up to a laptop), then this screen is screen 0 and
|
|
|
|
* other monitors will be positioned according to the "secondary screen".
|
|
|
|
* The main screen is the monitor that shows the window that is currently
|
|
|
|
* active (has focus), the position of the menu bar does not have influence
|
|
|
|
* on this!
|
|
|
|
*
|
|
|
|
* Upon start up and changes in the layout of screens, we calculate the
|
|
|
|
* size of the GdkScreen root window that is needed to be able to place
|
|
|
|
* all monitors in the root window. Once that size is known, we iterate
|
|
|
|
* over the monitors and translate their Cocoa position to a position
|
|
|
|
* in the root window of the GdkScreen. This happens below in the
|
2010-12-17 15:17:04 +00:00
|
|
|
* function gdk_quartz_screen_calculate_layout().
|
2009-11-15 14:29:45 +00:00
|
|
|
*
|
|
|
|
* A Cocoa coordinate is always relative to the origin of the monitor
|
|
|
|
* coordinate space. Such coordinates are mapped to their respective
|
|
|
|
* position in the GdkScreen root window (_gdk_quartz_window_xy_to_gdk_xy)
|
|
|
|
* and vice versa (_gdk_quartz_window_gdk_xy_to_xy). Both functions can
|
|
|
|
* be found in gdkwindow-quartz.c. Note that Cocoa coordinates can have
|
|
|
|
* negative values (in case a monitor is located left or below of screen 0),
|
|
|
|
* but GDK coordinates can *not*!
|
|
|
|
*/
|
|
|
|
|
2010-12-17 15:17:04 +00:00
|
|
|
static void gdk_quartz_screen_dispose (GObject *object);
|
|
|
|
static void gdk_quartz_screen_finalize (GObject *object);
|
2010-12-22 13:34:15 +00:00
|
|
|
static void gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
|
|
|
static void display_reconfiguration_callback (CGDirectDisplayID display,
|
|
|
|
CGDisplayChangeSummaryFlags flags,
|
|
|
|
void *userInfo);
|
|
|
|
|
2010-12-23 12:43:29 +00:00
|
|
|
G_DEFINE_TYPE (GdkQuartzScreen, gdk_quartz_screen, GDK_TYPE_SCREEN);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
|
|
|
static void
|
2010-12-23 12:43:29 +00:00
|
|
|
gdk_quartz_screen_init (GdkQuartzScreen *quartz_screen)
|
2009-10-24 09:48:39 +00:00
|
|
|
{
|
2010-12-17 15:17:04 +00:00
|
|
|
GdkScreen *screen = GDK_SCREEN (quartz_screen);
|
2009-10-24 09:51:51 +00:00
|
|
|
NSScreen *nsscreen;
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2009-10-24 09:51:51 +00:00
|
|
|
nsscreen = [[NSScreen screens] objectAtIndex:0];
|
|
|
|
gdk_screen_set_resolution (screen,
|
|
|
|
72.0 * [nsscreen userSpaceScaleFactor]);
|
|
|
|
|
2010-12-22 13:34:15 +00:00
|
|
|
gdk_quartz_screen_calculate_layout (quartz_screen);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
|
|
|
CGDisplayRegisterReconfigurationCallback (display_reconfiguration_callback,
|
|
|
|
screen);
|
2009-10-24 10:25:29 +00:00
|
|
|
|
2010-12-17 15:17:04 +00:00
|
|
|
quartz_screen->emit_monitors_changed = FALSE;
|
2009-10-24 09:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-17 15:17:04 +00:00
|
|
|
gdk_quartz_screen_dispose (GObject *object)
|
2009-10-24 09:48:39 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
GdkQuartzScreen *screen = GDK_QUARTZ_SCREEN (object);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
|
|
|
if (screen->screen_changed_id)
|
|
|
|
{
|
|
|
|
g_source_remove (screen->screen_changed_id);
|
|
|
|
screen->screen_changed_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGDisplayRemoveReconfigurationCallback (display_reconfiguration_callback,
|
|
|
|
screen);
|
|
|
|
|
2010-12-23 12:43:29 +00:00
|
|
|
G_OBJECT_CLASS (gdk_quartz_screen_parent_class)->dispose (object);
|
2009-10-24 09:48:39 +00:00
|
|
|
}
|
2009-10-12 07:55:45 +00:00
|
|
|
|
|
|
|
static void
|
2010-12-22 13:34:15 +00:00
|
|
|
gdk_quartz_screen_screen_rects_free (GdkQuartzScreen *screen)
|
2009-10-24 09:48:39 +00:00
|
|
|
{
|
|
|
|
screen->n_screens = 0;
|
|
|
|
|
|
|
|
if (screen->screen_rects)
|
|
|
|
{
|
|
|
|
g_free (screen->screen_rects);
|
|
|
|
screen->screen_rects = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-17 15:17:04 +00:00
|
|
|
gdk_quartz_screen_finalize (GObject *object)
|
2009-10-24 09:48:39 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
GdkQuartzScreen *screen = GDK_QUARTZ_SCREEN (object);
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2010-12-17 15:17:04 +00:00
|
|
|
gdk_quartz_screen_screen_rects_free (screen);
|
2009-10-24 09:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-22 13:34:15 +00:00
|
|
|
gdk_quartz_screen_calculate_layout (GdkQuartzScreen *screen)
|
2009-10-12 07:55:45 +00:00
|
|
|
{
|
|
|
|
NSArray *array;
|
|
|
|
int i;
|
2009-10-26 07:42:15 +00:00
|
|
|
int max_x, max_y;
|
2009-10-12 07:55:45 +00:00
|
|
|
|
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
|
|
|
|
2010-12-17 15:17:04 +00:00
|
|
|
gdk_quartz_screen_screen_rects_free (screen);
|
2009-10-12 07:55:45 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
array = [NSScreen screens];
|
2009-10-12 07:55:45 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
screen->width = 0;
|
|
|
|
screen->height = 0;
|
2009-10-25 20:36:56 +00:00
|
|
|
screen->min_x = 0;
|
|
|
|
screen->min_y = 0;
|
2009-10-26 07:42:15 +00:00
|
|
|
max_x = max_y = 0;
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2009-10-26 07:42:15 +00:00
|
|
|
/* We determine the minimum and maximum x and y coordinates
|
|
|
|
* covered by the monitors. From this we can deduce the width
|
|
|
|
* and height of the root screen.
|
|
|
|
*/
|
2009-10-24 09:48:39 +00:00
|
|
|
for (i = 0; i < [array count]; i++)
|
|
|
|
{
|
|
|
|
NSRect rect = [[array objectAtIndex:i] frame];
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
screen->min_x = MIN (screen->min_x, rect.origin.x);
|
2009-10-26 07:42:15 +00:00
|
|
|
max_x = MAX (max_x, rect.origin.x + rect.size.width);
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
screen->min_y = MIN (screen->min_y, rect.origin.y);
|
2009-10-26 07:42:15 +00:00
|
|
|
max_y = MAX (max_y, rect.origin.y + rect.size.height);
|
2009-10-24 09:48:39 +00:00
|
|
|
}
|
|
|
|
|
2009-10-26 07:42:15 +00:00
|
|
|
screen->width = max_x - screen->min_x;
|
|
|
|
screen->height = max_y - screen->min_y;
|
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
screen->n_screens = [array count];
|
|
|
|
screen->screen_rects = g_new0 (GdkRectangle, screen->n_screens);
|
2009-10-12 07:55:45 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
for (i = 0; i < screen->n_screens; i++)
|
2009-10-12 07:55:45 +00:00
|
|
|
{
|
|
|
|
NSScreen *nsscreen;
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
nsscreen = [array objectAtIndex:i];
|
|
|
|
rect = [nsscreen frame];
|
|
|
|
|
2009-10-25 20:36:56 +00:00
|
|
|
screen->screen_rects[i].x = rect.origin.x - screen->min_x;
|
2009-10-26 07:42:15 +00:00
|
|
|
screen->screen_rects[i].y
|
|
|
|
= screen->height - (rect.origin.y + rect.size.height) + screen->min_y;
|
2009-10-24 09:48:39 +00:00
|
|
|
screen->screen_rects[i].width = rect.size.width;
|
|
|
|
screen->screen_rects[i].height = rect.size.height;
|
2009-10-12 07:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-23 13:08:40 +00:00
|
|
|
void
|
|
|
|
_gdk_quartz_screen_update_window_sizes (GdkScreen *screen)
|
|
|
|
{
|
|
|
|
GList *windows, *list;
|
|
|
|
|
|
|
|
/* The size of the root window is so that it can contain all
|
|
|
|
* monitors attached to this machine. The monitors are laid out
|
|
|
|
* within this root window. We calculate the size of the root window
|
|
|
|
* and the positions of the different monitors in gdkscreen-quartz.c.
|
|
|
|
*
|
|
|
|
* This data is updated when the monitor configuration is changed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME: At some point, fetch the root window from GdkScreen. But
|
|
|
|
* on OS X will we only have a single root window anyway.
|
|
|
|
*/
|
|
|
|
_gdk_root->x = 0;
|
|
|
|
_gdk_root->y = 0;
|
|
|
|
_gdk_root->abs_x = 0;
|
|
|
|
_gdk_root->abs_y = 0;
|
|
|
|
_gdk_root->width = gdk_screen_get_width (screen);
|
|
|
|
_gdk_root->height = gdk_screen_get_height (screen);
|
|
|
|
|
|
|
|
windows = gdk_screen_get_toplevel_windows (screen);
|
|
|
|
|
|
|
|
for (list = windows; list; list = list->next)
|
|
|
|
_gdk_quartz_window_update_position (list->data);
|
|
|
|
|
|
|
|
g_list_free (windows);
|
|
|
|
}
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2009-10-24 08:29:43 +00:00
|
|
|
static void
|
2010-12-22 13:34:15 +00:00
|
|
|
process_display_reconfiguration (GdkQuartzScreen *screen)
|
2009-10-24 08:29:43 +00:00
|
|
|
{
|
2009-10-24 09:48:39 +00:00
|
|
|
int width, height;
|
2009-10-24 08:29:43 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
width = gdk_screen_get_width (GDK_SCREEN (screen));
|
|
|
|
height = gdk_screen_get_height (GDK_SCREEN (screen));
|
2009-10-24 08:29:43 +00:00
|
|
|
|
2010-12-22 13:34:15 +00:00
|
|
|
gdk_quartz_screen_calculate_layout (GDK_QUARTZ_SCREEN (screen));
|
2009-10-24 08:29:43 +00:00
|
|
|
|
2010-12-23 13:08:40 +00:00
|
|
|
_gdk_quartz_screen_update_window_sizes (GDK_SCREEN (screen));
|
2009-10-26 07:53:20 +00:00
|
|
|
|
2009-10-24 10:25:29 +00:00
|
|
|
if (screen->emit_monitors_changed)
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (screen, "monitors-changed");
|
|
|
|
screen->emit_monitors_changed = FALSE;
|
|
|
|
}
|
2009-10-24 12:53:28 +00:00
|
|
|
|
|
|
|
if (width != gdk_screen_get_width (GDK_SCREEN (screen))
|
|
|
|
|| height != gdk_screen_get_height (GDK_SCREEN (screen)))
|
|
|
|
g_signal_emit_by_name (screen, "size-changed");
|
2009-10-24 08:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
screen_changed_idle (gpointer data)
|
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
GdkQuartzScreen *screen = data;
|
2009-10-24 09:48:39 +00:00
|
|
|
|
|
|
|
process_display_reconfiguration (data);
|
2009-10-24 08:29:43 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
screen->screen_changed_id = 0;
|
2009-10-24 08:29:43 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-10-24 09:48:39 +00:00
|
|
|
display_reconfiguration_callback (CGDirectDisplayID display,
|
|
|
|
CGDisplayChangeSummaryFlags flags,
|
|
|
|
void *userInfo)
|
2009-10-24 08:29:43 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
GdkQuartzScreen *screen = userInfo;
|
2009-10-24 09:48:39 +00:00
|
|
|
|
2009-10-24 08:29:43 +00:00
|
|
|
if (flags & kCGDisplayBeginConfigurationFlag)
|
|
|
|
{
|
|
|
|
/* Ignore the begin configuration signal. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-24 10:25:29 +00:00
|
|
|
/* We save information about the changes, so we can emit
|
|
|
|
* ::monitors-changed when appropriate. This signal must be
|
|
|
|
* emitted when the number, size of position of one of the
|
|
|
|
* monitors changes.
|
|
|
|
*/
|
|
|
|
if (flags & kCGDisplayMovedFlag
|
|
|
|
|| flags & kCGDisplayAddFlag
|
|
|
|
|| flags & kCGDisplayRemoveFlag
|
|
|
|
|| flags & kCGDisplayEnabledFlag
|
|
|
|
|| flags & kCGDisplayDisabledFlag)
|
|
|
|
screen->emit_monitors_changed = TRUE;
|
|
|
|
|
2009-10-24 08:29:43 +00:00
|
|
|
/* At this point Cocoa does not know about the new screen data
|
|
|
|
* yet, so we delay our refresh into an idle handler.
|
|
|
|
*/
|
2009-10-24 09:48:39 +00:00
|
|
|
if (!screen->screen_changed_id)
|
|
|
|
screen->screen_changed_id = gdk_threads_add_idle (screen_changed_idle,
|
|
|
|
screen);
|
2009-10-24 08:29:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static GdkDisplay *
|
|
|
|
gdk_quartz_screen_get_display (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return _gdk_display;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static GdkWindow *
|
|
|
|
gdk_quartz_screen_get_root_window (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return _gdk_root;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_number (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_width (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
return GDK_QUARTZ_SCREEN (screen)->width;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_height (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
return GDK_QUARTZ_SCREEN (screen)->height;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2006-01-18 10:06:00 +00:00
|
|
|
static gint
|
|
|
|
get_mm_from_pixels (NSScreen *screen, int pixels)
|
|
|
|
{
|
|
|
|
/* userSpaceScaleFactor is in "pixels per point",
|
|
|
|
* 72 is the number of points per inch,
|
|
|
|
* and 25.4 is the number of millimeters per inch.
|
|
|
|
*/
|
2007-02-18 10:26:49 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3
|
|
|
|
float dpi = [screen userSpaceScaleFactor] * 72.0;
|
|
|
|
#else
|
|
|
|
float dpi = 96.0 / 72.0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return (pixels / dpi) * 25.4;
|
2006-01-18 10:06:00 +00:00
|
|
|
}
|
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
static NSScreen *
|
|
|
|
get_nsscreen_for_monitor (gint monitor_num)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2006-01-18 10:06:00 +00:00
|
|
|
NSArray *array;
|
2009-10-24 09:48:39 +00:00
|
|
|
NSScreen *screen;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2007-05-21 19:40:43 +00:00
|
|
|
GDK_QUARTZ_ALLOC_POOL;
|
2006-01-18 10:06:00 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
array = [NSScreen screens];
|
|
|
|
screen = [array objectAtIndex:monitor_num];
|
2006-01-18 10:06:00 +00:00
|
|
|
|
2007-05-21 19:40:43 +00:00
|
|
|
GDK_QUARTZ_RELEASE_POOL;
|
2006-01-18 10:06:00 +00:00
|
|
|
|
2009-10-24 09:48:39 +00:00
|
|
|
return screen;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_width_mm (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-10-24 09:48:39 +00:00
|
|
|
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
2010-12-22 13:34:15 +00:00
|
|
|
GDK_QUARTZ_SCREEN (screen)->width);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_height_mm (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2009-10-24 09:48:39 +00:00
|
|
|
return get_mm_from_pixels (get_nsscreen_for_monitor (0),
|
2010-12-22 13:34:15 +00:00
|
|
|
GDK_QUARTZ_SCREEN (screen)->height);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_n_monitors (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
return GDK_QUARTZ_SCREEN (screen)->n_screens;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_primary_monitor (GdkScreen *screen)
|
2009-12-14 01:40:02 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_monitor_width_mm (GdkScreen *screen,
|
|
|
|
gint monitor_num)
|
2008-08-07 08:14:12 +00:00
|
|
|
{
|
2009-10-12 07:55:45 +00:00
|
|
|
return get_mm_from_pixels (get_nsscreen_for_monitor (monitor_num),
|
2010-12-22 13:34:15 +00:00
|
|
|
GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num].width);
|
2008-08-07 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gint
|
|
|
|
gdk_quartz_screen_get_monitor_height_mm (GdkScreen *screen,
|
|
|
|
gint monitor_num)
|
2008-08-07 08:14:12 +00:00
|
|
|
{
|
2009-10-12 07:55:45 +00:00
|
|
|
return get_mm_from_pixels (get_nsscreen_for_monitor (monitor_num),
|
2010-12-22 13:34:15 +00:00
|
|
|
GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num].height);
|
2008-08-07 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gchar *
|
|
|
|
gdk_quartz_screen_get_monitor_plug_name (GdkScreen *screen,
|
|
|
|
gint monitor_num)
|
2008-08-07 08:14:12 +00:00
|
|
|
{
|
|
|
|
/* FIXME: Is there some useful name we could use here? */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static void
|
|
|
|
gdk_quartz_screen_get_monitor_geometry (GdkScreen *screen,
|
|
|
|
gint monitor_num,
|
|
|
|
GdkRectangle *dest)
|
2008-08-07 08:14:12 +00:00
|
|
|
{
|
2010-12-22 13:34:15 +00:00
|
|
|
*dest = GDK_QUARTZ_SCREEN (screen)->screen_rects[monitor_num];
|
2008-08-07 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2012-02-23 14:33:12 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gchar *
|
|
|
|
gdk_quartz_screen_make_display_name (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return g_strdup (gdk_display_get_name (_gdk_display));
|
|
|
|
}
|
2006-03-08 17:02:34 +00:00
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static GdkWindow *
|
|
|
|
gdk_quartz_screen_get_active_window (GdkScreen *screen)
|
2006-03-08 17:02:34 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static GList *
|
|
|
|
gdk_quartz_screen_get_window_stack (GdkScreen *screen)
|
2006-03-08 17:02:34 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-04-25 14:27:32 +00:00
|
|
|
|
2010-12-17 14:50:21 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_quartz_screen_is_composited (GdkScreen *screen)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-23 12:43:29 +00:00
|
|
|
gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
|
2006-04-25 14:27:32 +00:00
|
|
|
{
|
2010-12-17 14:50:21 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
|
2006-04-25 14:27:32 +00:00
|
|
|
|
2010-12-17 15:17:04 +00:00
|
|
|
object_class->dispose = gdk_quartz_screen_dispose;
|
|
|
|
object_class->finalize = gdk_quartz_screen_finalize;
|
|
|
|
|
|
|
|
screen_class->get_display = gdk_quartz_screen_get_display;
|
|
|
|
screen_class->get_width = gdk_quartz_screen_get_width;
|
|
|
|
screen_class->get_height = gdk_quartz_screen_get_height;
|
|
|
|
screen_class->get_width_mm = gdk_quartz_screen_get_width_mm;
|
|
|
|
screen_class->get_height_mm = gdk_quartz_screen_get_height_mm;
|
|
|
|
screen_class->get_number = gdk_quartz_screen_get_number;
|
|
|
|
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;
|
2012-02-23 14:33:12 +00:00
|
|
|
screen_class->get_monitor_workarea = gdk_quartz_screen_get_monitor_workarea;
|
2010-12-17 15:17:04 +00:00
|
|
|
screen_class->is_composited = gdk_quartz_screen_is_composited;
|
|
|
|
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_window_stack = gdk_quartz_screen_get_window_stack;
|
|
|
|
screen_class->broadcast_client_message = _gdk_quartz_screen_broadcast_client_message;
|
|
|
|
screen_class->get_setting = _gdk_quartz_screen_get_setting;
|
|
|
|
screen_class->get_rgba_visual = _gdk_quartz_screen_get_rgba_visual;
|
|
|
|
screen_class->get_system_visual = _gdk_quartz_screen_get_system_visual;
|
|
|
|
screen_class->visual_get_best_depth = _gdk_quartz_screen_visual_get_best_depth;
|
|
|
|
screen_class->visual_get_best_type = _gdk_quartz_screen_visual_get_best_type;
|
|
|
|
screen_class->visual_get_best = _gdk_quartz_screen_visual_get_best;
|
|
|
|
screen_class->visual_get_best_with_depth = _gdk_quartz_screen_visual_get_best_with_depth;
|
|
|
|
screen_class->visual_get_best_with_type = _gdk_quartz_screen_visual_get_best_with_type;
|
|
|
|
screen_class->visual_get_best_with_both = _gdk_quartz_screen_visual_get_best_with_both;
|
|
|
|
screen_class->query_depths = _gdk_quartz_screen_query_depths;
|
|
|
|
screen_class->query_visual_types = _gdk_quartz_screen_query_visual_types;
|
|
|
|
screen_class->list_visuals = _gdk_quartz_screen_list_visuals;
|
2006-04-25 14:27:32 +00:00
|
|
|
}
|