Make GdkMirWindowImpl private again

This commit is contained in:
Robert Ancell
2014-06-09 16:52:38 +12:00
parent 2e8f42da85
commit ce50fc001a
4 changed files with 105 additions and 73 deletions

View File

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

View File

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

View File

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

View File

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