[gtk+] Document how Cocoa coordinate and monitor layout transforms to GDK work
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Document how Cocoa coordinate and monitor layout transforms to GDK work
- Date: Sun, 15 Nov 2009 14:30:51 +0000 (UTC)
commit cffddd2adc336a2ab07b73bcae460c4183ff084e
Author: Kristian Rietveld <kris gtk org>
Date: Sun Nov 15 15:29:45 2009 +0100
Document how Cocoa coordinate and monitor layout transforms to GDK work
gdk/quartz/gdkscreen-quartz.c | 34 ++++++++++++++++++++++++++++++++++
gdk/quartz/gdkwindow-quartz.c | 1 +
2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c
index 58b1d55..38d150e 100644
--- a/gdk/quartz/gdkscreen-quartz.c
+++ b/gdk/quartz/gdkscreen-quartz.c
@@ -25,6 +25,40 @@
#include "gdkprivate-quartz.h"
+/* 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
+ * function gdk_screen_quartz_calculate_layout().
+ *
+ * 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*!
+ */
+
static void gdk_screen_quartz_dispose (GObject *object);
static void gdk_screen_quartz_finalize (GObject *object);
static void gdk_screen_quartz_calculate_layout (GdkScreenQuartz *screen);
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 0a851e8..7b47e7f 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -653,6 +653,7 @@ _gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
}
+/* See notes on top of gdkscreen-quartz.c */
void
_gdk_quartz_window_gdk_xy_to_xy (gint gdk_x,
gint gdk_y,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]