[gtk+/wip/mir] Make GdkMirWindowImpl private again



commit 8b837fe85bea1ccd43de23994987bcaf393f4cb8
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Jun 9 16:52:38 2014 +1200

    Make GdkMirWindowImpl private again

 gdk/mir/gdkmir-private.h    |   59 +++------------------------------
 gdk/mir/gdkmirdisplay.c     |    6 ++--
 gdk/mir/gdkmireventsource.c |   38 ++++++++++++---------
 gdk/mir/gdkmirwindowimpl.c  |   75 ++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 105 insertions(+), 73 deletions(-)
---
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index d81f62f..d1792a1 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -14,22 +14,6 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * 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
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
 
 #ifndef __GDK_PRIVATE_MIR_H__
 #define __GDK_PRIVATE_MIR_H__
@@ -51,43 +35,6 @@ typedef struct _GdkMirEventSource GdkMirEventSource;
 #define GDK_MIR_WINDOW_IMPL(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), 
GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImpl))
 #define GDK_IS_WINDOW_IMPL_MIR(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), 
GDK_TYPE_WINDOW_IMPL_MIR))
 
-struct _GdkMirWindowImpl
-{
-  GdkWindowImpl parent_instance;
-
-  /* Window we are temporary for */
-  GdkWindow *transient_for;
-  GdkRectangle transient_size;
-
-  /* Child windows (e.g. tooltips) */
-  GList *transient_children;
-
-  /* Desired surface attributes */
-  MirSurfaceType surface_type; // FIXME
-  MirSurfaceState surface_state;
-
-  /* Pattern for background */
-  cairo_pattern_t *background;
-
-  /* Current button state for checking which buttons are being pressed / released */
-  gdouble x;
-  gdouble y;
-  MirMotionButton button_state;
-
-  /* Surface being rendered to (only exists when window visible) */
-  MirSurface *surface;
-
-  /* Cairo context for current frame */
-  cairo_surface_t *cairo_surface;
-
-  /* TRUE if the window can be seen */
-  gboolean visible;
-
-  /* TRUE if cursor is inside this window */
-  gboolean cursor_inside;
-};
-
-
 GdkDisplay *_gdk_mir_display_open (const gchar *display_name);
 
 GdkScreen *_gdk_mir_screen_new (GdkDisplay *display);
@@ -108,6 +55,12 @@ GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type);
 
 GdkWindowImpl *_gdk_mir_window_impl_new (void);
 
+void _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state);
+
+void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean 
cursor_inside, MirMotionButton button_state);
+
+void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean 
*cursor_inside, MirMotionButton *button_state);
+
 GdkMirEventSource *_gdk_mir_display_get_event_source (GdkDisplay *display);
 
 GdkMirEventSource *_gdk_mir_event_source_new (GdkDisplay *display);
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index e705239..7a56587 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -513,10 +513,10 @@ gdk_mir_display_init (GdkMirDisplay *display)
 }
 
 static void
-gdk_mir_display_class_init (GdkMirDisplayClass * class)
+gdk_mir_display_class_init (GdkMirDisplayClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (class);
-  GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (klass);
 
   object_class->dispose = gdk_mir_display_dispose;
   object_class->finalize = gdk_mir_display_finalize;
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c
index 2e4d383..831962b 100644
--- a/gdk/mir/gdkmireventsource.c
+++ b/gdk/mir/gdkmireventsource.c
@@ -555,53 +555,59 @@ static void
 handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
 {
   GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+  gdouble x, y;
+  gboolean cursor_inside;
+  MirMotionButton button_state;
   guint modifier_state;
   GdkEventType event_type;
   MirMotionButton changed_button_state;
 
+  _gdk_mir_window_impl_get_cursor_state (impl, &x, &y, &cursor_inside, &button_state);
   if (event->pointer_count > 0)
     {
-      impl->x = event->pointer_coordinates[0].x;
-      impl->y = event->pointer_coordinates[0].y;
+      x = event->pointer_coordinates[0].x;
+      y = event->pointer_coordinates[0].y;
     }
   modifier_state = get_modifier_state (event->modifiers, event->button_state);
 
   /* The Mir events generate hover-exits even while inside the window so
      counteract this by always generating an enter notify on all other events */
-  if (!impl->cursor_inside && event->action != mir_motion_action_hover_exit)
+  if (!cursor_inside && event->action != mir_motion_action_hover_exit)
     {
-      impl->cursor_inside = TRUE;
-      generate_crossing_event (window, GDK_ENTER_NOTIFY, impl->x, impl->y);
+      cursor_inside = TRUE;
+      generate_crossing_event (window, GDK_ENTER_NOTIFY, x, y);
     }
 
   /* Update which window has focus */
-  _gdk_mir_pointer_set_location (get_pointer (window), impl->x, impl->y, window, modifier_state);
+  _gdk_mir_pointer_set_location (get_pointer (window), x, y, window, modifier_state);
   switch (event->action)
     {
     case mir_motion_action_down:
     case mir_motion_action_up:
       event_type = event->action == mir_motion_action_down ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
-      changed_button_state = impl->button_state ^ event->button_state;
+      changed_button_state = button_state ^ event->button_state;
       if ((changed_button_state & mir_motion_button_primary) != 0)
-        generate_button_event (window, event_type, impl->x, impl->y, GDK_BUTTON_PRIMARY, modifier_state);
+        generate_button_event (window, event_type, x, y, GDK_BUTTON_PRIMARY, modifier_state);
       if ((changed_button_state & mir_motion_button_secondary) != 0)
-        generate_button_event (window, event_type, impl->x, impl->y, GDK_BUTTON_SECONDARY, modifier_state);
+        generate_button_event (window, event_type, x, y, GDK_BUTTON_SECONDARY, modifier_state);
       if ((changed_button_state & mir_motion_button_tertiary) != 0)
-        generate_button_event (window, event_type, impl->x, impl->y, GDK_BUTTON_MIDDLE, modifier_state);
-      impl->button_state = event->button_state;
+        generate_button_event (window, event_type, x, y, GDK_BUTTON_MIDDLE, modifier_state);
+      button_state = event->button_state;
       break;
     case mir_motion_action_scroll:
-      generate_scroll_event (window, impl->x, impl->y, event->pointer_coordinates[0].hscroll, 
event->pointer_coordinates[0].vscroll, modifier_state);
+      generate_scroll_event (window, x, y, event->pointer_coordinates[0].hscroll, 
event->pointer_coordinates[0].vscroll, modifier_state);
       break;
     case mir_motion_action_move: // move with button
     case mir_motion_action_hover_move: // move without button
-      generate_motion_event (window, impl->x, impl->y, modifier_state);
+      generate_motion_event (window, x, y, modifier_state);
       break;
     case mir_motion_action_hover_exit:
-      impl->cursor_inside = FALSE;
-      generate_crossing_event (window, GDK_LEAVE_NOTIFY, impl->x, impl->y);
+      cursor_inside = FALSE;
+      generate_crossing_event (window, GDK_LEAVE_NOTIFY, x, y);
       break;
     }
+
+  _gdk_mir_window_impl_set_cursor_state (impl, x, y, cursor_inside, button_state);
 }
 
 static void
@@ -614,7 +620,7 @@ handle_surface_event (GdkWindow *window, const MirSurfaceEvent *event)
     case mir_surface_attrib_type:
       break;
     case mir_surface_attrib_state:
-      impl->surface_state = event->value;
+      _gdk_mir_window_impl_set_surface_state (impl, event->value);
       // FIXME: notify
       break;
     case mir_surface_attrib_swapinterval:
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index a3d9425..8eada37 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -34,6 +34,42 @@
 
 typedef struct _GdkMirWindowImplClass GdkMirWindowImplClass;
 
+struct _GdkMirWindowImpl
+{
+  GdkWindowImpl parent_instance;
+
+  /* Window we are temporary for */
+  GdkWindow *transient_for;
+  GdkRectangle transient_size;
+
+  /* Child windows (e.g. tooltips) */
+  GList *transient_children;
+
+  /* Desired surface attributes */
+  MirSurfaceType surface_type; // FIXME
+  MirSurfaceState surface_state;
+
+  /* Pattern for background */
+  cairo_pattern_t *background;
+
+  /* Current button state for checking which buttons are being pressed / released */
+  gdouble x;
+  gdouble y;
+  MirMotionButton button_state;
+
+  /* Surface being rendered to (only exists when window visible) */
+  MirSurface *surface;
+
+  /* Cairo context for current frame */
+  cairo_surface_t *cairo_surface;
+
+  /* TRUE if the window can be seen */
+  gboolean visible;
+
+  /* TRUE if cursor is inside this window */
+  gboolean cursor_inside;
+};
+
 struct _GdkMirWindowImplClass
 {
   GdkWindowImplClass parent_class;
@@ -49,6 +85,42 @@ _gdk_mir_window_impl_new (void)
   return g_object_new (GDK_TYPE_MIR_WINDOW_IMPL, NULL);
 }
 
+void
+_gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state)
+{
+  impl->surface_state = state;
+}
+
+void
+_gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl,
+                                       gdouble x,
+                                       gdouble y,
+                                       gboolean cursor_inside,
+                                       MirMotionButton button_state)
+{
+  impl->x = x;
+  impl->y = y;
+  impl->cursor_inside = cursor_inside;
+  impl->button_state = button_state;
+}
+
+void
+_gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl,
+                                       gdouble *x,
+                                       gdouble *y,
+                                       gboolean *cursor_inside,
+                                       MirMotionButton *button_state)
+{
+  if (x)
+    *x = impl->x;
+  if (y)
+    *y = impl->y;
+  if (cursor_inside)
+    *cursor_inside = impl->cursor_inside;
+  if (button_state)
+    *button_state = impl->button_state;
+}
+
 static void
 gdk_mir_window_impl_init (GdkMirWindowImpl *impl)
 {
@@ -61,7 +133,8 @@ get_connection (GdkWindow *window)
 }
 
 static void
-set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state)
+set_surface_state (GdkMirWindowImpl *impl,
+                   MirSurfaceState state)
 {
   impl->surface_state = state;
   if (impl->surface)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]