Adapt win32 backend to the semantic change of StageWindow
http://bugzilla.openedhand.com/show_bug.cgi?id=1847 Signed-off-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
b69ee0989b
commit
26ce94eda0
@ -231,7 +231,11 @@ static void
|
||||
clutter_backend_win32_ensure_context (ClutterBackend *backend,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
if (stage == NULL)
|
||||
ClutterStageWindow *impl;
|
||||
|
||||
if (stage == NULL ||
|
||||
(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) ||
|
||||
((impl = _clutter_stage_get_window (stage)) == NULL))
|
||||
{
|
||||
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
|
||||
|
||||
@ -241,9 +245,7 @@ clutter_backend_win32_ensure_context (ClutterBackend *backend,
|
||||
{
|
||||
ClutterBackendWin32 *backend_win32;
|
||||
ClutterStageWin32 *stage_win32;
|
||||
ClutterStageWindow *impl;
|
||||
|
||||
impl = _clutter_stage_get_window (stage);
|
||||
g_return_if_fail (impl != NULL);
|
||||
|
||||
CLUTTER_NOTE (MULTISTAGE, "Setting context for stage of type %s [%p]",
|
||||
@ -303,14 +305,14 @@ clutter_backend_win32_redraw (ClutterBackend *backend,
|
||||
SwapBuffers (stage_win32->client_dc);
|
||||
}
|
||||
|
||||
static ClutterActor *
|
||||
static ClutterStageWindow *
|
||||
clutter_backend_win32_create_stage (ClutterBackend *backend,
|
||||
ClutterStage *wrapper,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendWin32 *backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
||||
ClutterStageWin32 *stage_win32;
|
||||
ClutterActor *stage;
|
||||
ClutterStageWindow *stage;
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Creating stage of type '%s'",
|
||||
g_type_name (CLUTTER_STAGE_TYPE));
|
||||
|
@ -48,75 +48,55 @@ static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageWin32,
|
||||
clutter_stage_win32,
|
||||
CLUTTER_TYPE_GROUP,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE
|
||||
(CLUTTER_TYPE_STAGE_WINDOW,
|
||||
clutter_stage_window_iface_init));
|
||||
|
||||
static void
|
||||
clutter_stage_win32_show (ClutterActor *actor)
|
||||
clutter_stage_win32_show (ClutterStageWindow *stage_window,
|
||||
gboolean do_raise)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
|
||||
if (stage_win32->hwnd)
|
||||
ShowWindow (stage_win32->hwnd, SW_SHOW);
|
||||
{
|
||||
ShowWindow (stage_win32->hwnd, do_raise ? SW_SHOW : SW_SHOWNA);
|
||||
|
||||
clutter_stage_ensure_viewport (CLUTTER_STAGE (stage_win32->wrapper));
|
||||
clutter_actor_map (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_hide (ClutterActor *actor)
|
||||
clutter_stage_win32_hide (ClutterStageWindow *stage_window)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
|
||||
if (stage_win32->hwnd)
|
||||
{
|
||||
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||
ShowWindow (stage_win32->hwnd, SW_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
clutter_stage_win32_get_geometry (ClutterStageWindow *stage_window,
|
||||
ClutterGeometry *geometry)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
|
||||
int width;
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
|
||||
/* If we're in fullscreen mode then return the size of the screen
|
||||
instead */
|
||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
||||
width = stage_win32->fullscreen_rect.right
|
||||
- stage_win32->fullscreen_rect.left;
|
||||
else
|
||||
width = stage_win32->win_width;
|
||||
{
|
||||
geometry->width = (stage_win32->fullscreen_rect.right
|
||||
- stage_win32->fullscreen_rect.left);
|
||||
geometry->height = (stage_win32->fullscreen_rect.bottom
|
||||
- stage_win32->fullscreen_rect.top);
|
||||
return;
|
||||
}
|
||||
|
||||
if (min_width_p)
|
||||
*min_width_p = width;
|
||||
|
||||
if (natural_width_p)
|
||||
*natural_width_p = width;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
|
||||
int height;
|
||||
|
||||
/* If we're in fullscreen mode then return the size of the screen
|
||||
instead */
|
||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
||||
height = stage_win32->fullscreen_rect.bottom
|
||||
- stage_win32->fullscreen_rect.top;
|
||||
else
|
||||
height = stage_win32->win_height;
|
||||
|
||||
if (min_height_p)
|
||||
*min_height_p = height;
|
||||
|
||||
if (natural_height_p)
|
||||
*natural_height_p = height;
|
||||
geometry->width = stage_win32->win_width;
|
||||
geometry->height = stage_win32->win_height;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -179,31 +159,29 @@ _clutter_stage_win32_get_min_max_info (ClutterStageWin32 *stage_win32,
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
clutter_stage_win32_resize (ClutterStageWindow *stage_window,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
|
||||
gint new_width, new_height;
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
gboolean resize;
|
||||
|
||||
new_width = ABS (box->x2 - box->x1);
|
||||
new_height = ABS (box->y2 - box->y1);
|
||||
resize = clutter_stage_get_user_resizable (stage_win32->wrapper);
|
||||
|
||||
if (new_width != stage_win32->win_width ||
|
||||
new_height != stage_win32->win_height)
|
||||
if (width != stage_win32->win_width || height != stage_win32->win_height)
|
||||
{
|
||||
/* Ignore size requests if we are in full screen mode */
|
||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
|
||||
{
|
||||
stage_win32->win_width = new_width;
|
||||
stage_win32->win_height = new_height;
|
||||
stage_win32->win_width = width;
|
||||
stage_win32->win_height = height;
|
||||
|
||||
if (stage_win32->hwnd != NULL && !stage_win32->is_foreign_win)
|
||||
{
|
||||
int full_width, full_height;
|
||||
|
||||
get_full_window_size (stage_win32,
|
||||
new_width, new_height,
|
||||
width, height,
|
||||
&full_width, &full_height);
|
||||
|
||||
SetWindowPos (stage_win32->hwnd, NULL,
|
||||
@ -216,9 +194,6 @@ clutter_stage_win32_allocate (ClutterActor *self,
|
||||
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
|
||||
CLUTTER_ACTOR_SYNC_MATRICES);
|
||||
}
|
||||
|
||||
CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class)
|
||||
->allocate (self, box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -226,15 +201,32 @@ clutter_stage_win32_set_title (ClutterStageWindow *stage_window,
|
||||
const gchar *title)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
wchar_t *wtitle;
|
||||
|
||||
/* Empty window titles not allowed, so set it to just a period. */
|
||||
if (title == NULL || !title[0])
|
||||
title = ".";
|
||||
|
||||
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
||||
SetWindowTextW (stage_win32->hwnd, wtitle);
|
||||
g_free (wtitle);
|
||||
if (stage_win32->wtitle != NULL)
|
||||
g_free (stage_win32->wtitle);
|
||||
stage_win32->wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
||||
|
||||
/* If the window is not yet created, the title will be set during the
|
||||
window creation */
|
||||
if (stage_win32->hwnd != NULL)
|
||||
SetWindowTextW (stage_win32->hwnd, stage_win32->wtitle);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_set_cursor_visible (ClutterStageWindow *stage_window,
|
||||
gboolean cursor_visible)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
|
||||
if (stage_win32->is_cursor_visible != cursor_visible &&
|
||||
stage_win32->tracking_mouse)
|
||||
ShowCursor (cursor_visible);
|
||||
|
||||
stage_win32->is_cursor_visible = cursor_visible;
|
||||
}
|
||||
|
||||
static LONG
|
||||
@ -452,10 +444,10 @@ clutter_stage_win32_choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
|
||||
return best_pf;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_realize (ClutterActor *actor)
|
||||
static gboolean
|
||||
clutter_stage_win32_realize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
ClutterBackendWin32 *backend_win32;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int pf;
|
||||
@ -495,8 +487,11 @@ clutter_stage_win32_realize (ClutterActor *actor)
|
||||
&win_width, &win_height);
|
||||
}
|
||||
|
||||
if (stage_win32->wtitle == NULL)
|
||||
stage_win32->wtitle = g_utf8_to_utf16 (".", -1, NULL, NULL, NULL);
|
||||
|
||||
stage_win32->hwnd = CreateWindowW ((LPWSTR) MAKEINTATOM (window_class),
|
||||
L".",
|
||||
stage_win32->wtitle,
|
||||
get_window_style (stage_win32),
|
||||
win_xpos,
|
||||
win_ypos,
|
||||
@ -552,22 +547,15 @@ clutter_stage_win32_realize (ClutterActor *actor)
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
||||
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_unrealize (ClutterActor *actor)
|
||||
clutter_stage_win32_unprepare_window (ClutterStageWin32 *stage_win32)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Unrealizing stage");
|
||||
|
||||
if (CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class)->unrealize != NULL)
|
||||
CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class)->unrealize (actor);
|
||||
|
||||
if (stage_win32->client_dc)
|
||||
{
|
||||
ReleaseDC (stage_win32->hwnd, stage_win32->client_dc);
|
||||
@ -582,15 +570,33 @@ clutter_stage_win32_unrealize (ClutterActor *actor)
|
||||
invalid stage instance */
|
||||
SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) 0);
|
||||
DestroyWindow (stage_win32->hwnd);
|
||||
stage_win32->hwnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_unrealize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Unrealizing stage");
|
||||
|
||||
clutter_stage_win32_unprepare_window (stage_win32);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_win32_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (gobject);
|
||||
|
||||
/* Make sure that context and window are destroyed in case unrealize
|
||||
* hasn't been called yet.
|
||||
*/
|
||||
if (stage_win32->hwnd)
|
||||
clutter_stage_win32_unprepare_window (stage_win32);
|
||||
|
||||
if (stage_win32->wtitle)
|
||||
g_free (stage_win32->wtitle);
|
||||
|
||||
G_OBJECT_CLASS (clutter_stage_win32_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@ -598,15 +604,8 @@ static void
|
||||
clutter_stage_win32_class_init (ClutterStageWin32Class *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = clutter_stage_win32_dispose;
|
||||
|
||||
actor_class->get_preferred_width = clutter_stage_win32_get_preferred_width;
|
||||
actor_class->get_preferred_height = clutter_stage_win32_get_preferred_height;
|
||||
actor_class->allocate = clutter_stage_win32_allocate;
|
||||
actor_class->realize = clutter_stage_win32_realize;
|
||||
actor_class->unrealize = clutter_stage_win32_unrealize;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -619,7 +618,8 @@ clutter_stage_win32_init (ClutterStageWin32 *stage)
|
||||
stage->backend = NULL;
|
||||
stage->scroll_pos = 0;
|
||||
stage->is_foreign_win = FALSE;
|
||||
|
||||
stage->wtitle = NULL;
|
||||
stage->is_cursor_visible = TRUE;
|
||||
stage->wrapper = NULL;
|
||||
|
||||
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IS_TOPLEVEL);
|
||||
@ -631,9 +631,14 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||
iface->get_wrapper = clutter_stage_win32_get_wrapper;
|
||||
iface->set_title = clutter_stage_win32_set_title;
|
||||
iface->set_fullscreen = clutter_stage_win32_set_fullscreen;
|
||||
iface->set_cursor_visible = clutter_stage_win32_set_cursor_visible;
|
||||
iface->set_user_resizable = clutter_stage_win32_set_user_resize;
|
||||
iface->show = clutter_stage_win32_show;
|
||||
iface->hide = clutter_stage_win32_hide;
|
||||
iface->resize = clutter_stage_win32_resize;
|
||||
iface->get_geometry = clutter_stage_win32_get_geometry;
|
||||
iface->realize = clutter_stage_win32_realize;
|
||||
iface->unrealize = clutter_stage_win32_unrealize;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -773,7 +778,6 @@ clutter_win32_set_stage_foreign (ClutterStage *stage,
|
||||
void
|
||||
clutter_stage_win32_map (ClutterStageWin32 *stage_win32)
|
||||
{
|
||||
clutter_actor_map (CLUTTER_ACTOR (stage_win32));
|
||||
clutter_actor_map (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||
@ -782,6 +786,5 @@ clutter_stage_win32_map (ClutterStageWin32 *stage_win32)
|
||||
void
|
||||
clutter_stage_win32_unmap (ClutterStageWin32 *stage_win32)
|
||||
{
|
||||
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32));
|
||||
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ struct _ClutterStageWin32
|
||||
RECT fullscreen_rect;
|
||||
gboolean is_foreign_win;
|
||||
gboolean tracking_mouse;
|
||||
wchar_t *wtitle;
|
||||
gboolean is_cursor_visible;
|
||||
|
||||
ClutterBackendWin32 *backend;
|
||||
ClutterStageState state;
|
||||
|
Loading…
Reference in New Issue
Block a user