mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
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,
|
clutter_backend_win32_ensure_context (ClutterBackend *backend,
|
||||||
ClutterStage *stage)
|
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");
|
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
|
||||||
|
|
||||||
@ -241,9 +245,7 @@ clutter_backend_win32_ensure_context (ClutterBackend *backend,
|
|||||||
{
|
{
|
||||||
ClutterBackendWin32 *backend_win32;
|
ClutterBackendWin32 *backend_win32;
|
||||||
ClutterStageWin32 *stage_win32;
|
ClutterStageWin32 *stage_win32;
|
||||||
ClutterStageWindow *impl;
|
|
||||||
|
|
||||||
impl = _clutter_stage_get_window (stage);
|
|
||||||
g_return_if_fail (impl != NULL);
|
g_return_if_fail (impl != NULL);
|
||||||
|
|
||||||
CLUTTER_NOTE (MULTISTAGE, "Setting context for stage of type %s [%p]",
|
CLUTTER_NOTE (MULTISTAGE, "Setting context for stage of type %s [%p]",
|
||||||
@ -255,28 +257,28 @@ clutter_backend_win32_ensure_context (ClutterBackend *backend,
|
|||||||
|
|
||||||
/* no GL context to set */
|
/* no GL context to set */
|
||||||
if (backend_win32->gl_context == NULL)
|
if (backend_win32->gl_context == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* we might get here inside the final dispose cycle, so we
|
/* we might get here inside the final dispose cycle, so we
|
||||||
* need to handle this gracefully
|
* need to handle this gracefully
|
||||||
*/
|
*/
|
||||||
if (stage_win32->client_dc == NULL)
|
if (stage_win32->client_dc == NULL)
|
||||||
{
|
{
|
||||||
CLUTTER_NOTE (MULTISTAGE,
|
CLUTTER_NOTE (MULTISTAGE,
|
||||||
"Received a stale stage, clearing all context");
|
"Received a stale stage, clearing all context");
|
||||||
|
|
||||||
wglMakeCurrent (NULL, NULL);
|
wglMakeCurrent (NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLUTTER_NOTE (BACKEND,
|
CLUTTER_NOTE (BACKEND,
|
||||||
"MakeCurrent window %p (%s), context %p",
|
"MakeCurrent window %p (%s), context %p",
|
||||||
stage_win32->hwnd,
|
stage_win32->hwnd,
|
||||||
stage_win32->is_foreign_win ? "foreign" : "native",
|
stage_win32->is_foreign_win ? "foreign" : "native",
|
||||||
backend_win32->gl_context);
|
backend_win32->gl_context);
|
||||||
wglMakeCurrent (stage_win32->client_dc,
|
wglMakeCurrent (stage_win32->client_dc,
|
||||||
backend_win32->gl_context);
|
backend_win32->gl_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,14 +305,14 @@ clutter_backend_win32_redraw (ClutterBackend *backend,
|
|||||||
SwapBuffers (stage_win32->client_dc);
|
SwapBuffers (stage_win32->client_dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterActor *
|
static ClutterStageWindow *
|
||||||
clutter_backend_win32_create_stage (ClutterBackend *backend,
|
clutter_backend_win32_create_stage (ClutterBackend *backend,
|
||||||
ClutterStage *wrapper,
|
ClutterStage *wrapper,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
ClutterBackendWin32 *backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
ClutterBackendWin32 *backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
||||||
ClutterStageWin32 *stage_win32;
|
ClutterStageWin32 *stage_win32;
|
||||||
ClutterActor *stage;
|
ClutterStageWindow *stage;
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "Creating stage of type '%s'",
|
CLUTTER_NOTE (BACKEND, "Creating stage of type '%s'",
|
||||||
g_type_name (CLUTTER_STAGE_TYPE));
|
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,
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageWin32,
|
||||||
clutter_stage_win32,
|
clutter_stage_win32,
|
||||||
CLUTTER_TYPE_GROUP,
|
G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE
|
G_IMPLEMENT_INTERFACE
|
||||||
(CLUTTER_TYPE_STAGE_WINDOW,
|
(CLUTTER_TYPE_STAGE_WINDOW,
|
||||||
clutter_stage_window_iface_init));
|
clutter_stage_window_iface_init));
|
||||||
|
|
||||||
static void
|
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)
|
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
|
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)
|
if (stage_win32->hwnd)
|
||||||
ShowWindow (stage_win32->hwnd, SW_HIDE);
|
{
|
||||||
|
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||||
|
ShowWindow (stage_win32->hwnd, SW_HIDE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_win32_get_preferred_width (ClutterActor *self,
|
clutter_stage_win32_get_geometry (ClutterStageWindow *stage_window,
|
||||||
gfloat for_height,
|
ClutterGeometry *geometry)
|
||||||
gfloat *min_width_p,
|
|
||||||
gfloat *natural_width_p)
|
|
||||||
{
|
{
|
||||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
|
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||||
int width;
|
|
||||||
|
|
||||||
/* If we're in fullscreen mode then return the size of the screen
|
|
||||||
instead */
|
|
||||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
||||||
width = stage_win32->fullscreen_rect.right
|
{
|
||||||
- stage_win32->fullscreen_rect.left;
|
geometry->width = (stage_win32->fullscreen_rect.right
|
||||||
else
|
- stage_win32->fullscreen_rect.left);
|
||||||
width = stage_win32->win_width;
|
geometry->height = (stage_win32->fullscreen_rect.bottom
|
||||||
|
- stage_win32->fullscreen_rect.top);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (min_width_p)
|
geometry->width = stage_win32->win_width;
|
||||||
*min_width_p = width;
|
geometry->height = stage_win32->win_height;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -179,46 +159,41 @@ _clutter_stage_win32_get_min_max_info (ClutterStageWin32 *stage_win32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_win32_allocate (ClutterActor *self,
|
clutter_stage_win32_resize (ClutterStageWindow *stage_window,
|
||||||
const ClutterActorBox *box,
|
gint width,
|
||||||
ClutterAllocationFlags flags)
|
gint height)
|
||||||
{
|
{
|
||||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
|
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||||
gint new_width, new_height;
|
gboolean resize;
|
||||||
|
|
||||||
new_width = ABS (box->x2 - box->x1);
|
resize = clutter_stage_get_user_resizable (stage_win32->wrapper);
|
||||||
new_height = ABS (box->y2 - box->y1);
|
|
||||||
|
|
||||||
if (new_width != stage_win32->win_width ||
|
if (width != stage_win32->win_width || height != stage_win32->win_height)
|
||||||
new_height != stage_win32->win_height)
|
|
||||||
{
|
{
|
||||||
/* Ignore size requests if we are in full screen mode */
|
/* Ignore size requests if we are in full screen mode */
|
||||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
|
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
|
||||||
{
|
{
|
||||||
stage_win32->win_width = new_width;
|
stage_win32->win_width = width;
|
||||||
stage_win32->win_height = new_height;
|
stage_win32->win_height = height;
|
||||||
|
|
||||||
if (stage_win32->hwnd != NULL && !stage_win32->is_foreign_win)
|
if (stage_win32->hwnd != NULL && !stage_win32->is_foreign_win)
|
||||||
{
|
{
|
||||||
int full_width, full_height;
|
int full_width, full_height;
|
||||||
|
|
||||||
get_full_window_size (stage_win32,
|
get_full_window_size (stage_win32,
|
||||||
new_width, new_height,
|
width, height,
|
||||||
&full_width, &full_height);
|
&full_width, &full_height);
|
||||||
|
|
||||||
SetWindowPos (stage_win32->hwnd, NULL,
|
SetWindowPos (stage_win32->hwnd, NULL,
|
||||||
0, 0,
|
0, 0,
|
||||||
full_width, full_height,
|
full_width, full_height,
|
||||||
SWP_NOZORDER | SWP_NOMOVE);
|
SWP_NOZORDER | SWP_NOMOVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
|
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
|
||||||
CLUTTER_ACTOR_SYNC_MATRICES);
|
CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class)
|
|
||||||
->allocate (self, box, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -226,15 +201,32 @@ clutter_stage_win32_set_title (ClutterStageWindow *stage_window,
|
|||||||
const gchar *title)
|
const gchar *title)
|
||||||
{
|
{
|
||||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
|
||||||
wchar_t *wtitle;
|
|
||||||
|
|
||||||
/* Empty window titles not allowed, so set it to just a period. */
|
/* Empty window titles not allowed, so set it to just a period. */
|
||||||
if (title == NULL || !title[0])
|
if (title == NULL || !title[0])
|
||||||
title = ".";
|
title = ".";
|
||||||
|
|
||||||
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
if (stage_win32->wtitle != NULL)
|
||||||
SetWindowTextW (stage_win32->hwnd, wtitle);
|
g_free (stage_win32->wtitle);
|
||||||
g_free (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
|
static LONG
|
||||||
@ -296,31 +288,31 @@ clutter_stage_win32_set_fullscreen (ClutterStageWindow *stage_window,
|
|||||||
| (old_style & WS_VISIBLE));
|
| (old_style & WS_VISIBLE));
|
||||||
/* Update the window size */
|
/* Update the window size */
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
get_fullscreen_rect (stage_win32);
|
get_fullscreen_rect (stage_win32);
|
||||||
SetWindowPos (hwnd, HWND_TOP,
|
SetWindowPos (hwnd, HWND_TOP,
|
||||||
stage_win32->fullscreen_rect.left,
|
stage_win32->fullscreen_rect.left,
|
||||||
stage_win32->fullscreen_rect.top,
|
stage_win32->fullscreen_rect.top,
|
||||||
stage_win32->fullscreen_rect.right
|
stage_win32->fullscreen_rect.right
|
||||||
- stage_win32->fullscreen_rect.left,
|
- stage_win32->fullscreen_rect.left,
|
||||||
stage_win32->fullscreen_rect.bottom
|
stage_win32->fullscreen_rect.bottom
|
||||||
- stage_win32->fullscreen_rect.top,
|
- stage_win32->fullscreen_rect.top,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int full_width, full_height;
|
int full_width, full_height;
|
||||||
|
|
||||||
get_full_window_size (stage_win32,
|
get_full_window_size (stage_win32,
|
||||||
stage_win32->win_width,
|
stage_win32->win_width,
|
||||||
stage_win32->win_height,
|
stage_win32->win_height,
|
||||||
&full_width, &full_height);
|
&full_width, &full_height);
|
||||||
|
|
||||||
SetWindowPos (stage_win32->hwnd, NULL,
|
SetWindowPos (stage_win32->hwnd, NULL,
|
||||||
0, 0,
|
0, 0,
|
||||||
full_width, full_height,
|
full_width, full_height,
|
||||||
SWP_NOZORDER | SWP_NOMOVE);
|
SWP_NOZORDER | SWP_NOMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
|
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
|
||||||
CLUTTER_ACTOR_SYNC_MATRICES);
|
CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
@ -441,10 +433,10 @@ clutter_stage_win32_choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
|
|||||||
already found */
|
already found */
|
||||||
&& (best_pf == 0
|
&& (best_pf == 0
|
||||||
|| clutter_stage_win32_pixel_format_is_better (&best_pfd, pfd)))
|
|| clutter_stage_win32_pixel_format_is_better (&best_pfd, pfd)))
|
||||||
{
|
{
|
||||||
best_pf = i;
|
best_pf = i;
|
||||||
best_pfd = *pfd;
|
best_pfd = *pfd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pfd = best_pfd;
|
*pfd = best_pfd;
|
||||||
@ -452,10 +444,10 @@ clutter_stage_win32_choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
|
|||||||
return best_pf;
|
return best_pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
clutter_stage_win32_realize (ClutterActor *actor)
|
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;
|
ClutterBackendWin32 *backend_win32;
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
int pf;
|
int pf;
|
||||||
@ -470,33 +462,36 @@ clutter_stage_win32_realize (ClutterActor *actor)
|
|||||||
int win_xpos, win_ypos, win_width, win_height;
|
int win_xpos, win_ypos, win_width, win_height;
|
||||||
|
|
||||||
if (window_class == 0)
|
if (window_class == 0)
|
||||||
{
|
{
|
||||||
g_critical ("Unable to register window class");
|
g_critical ("Unable to register window class");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're in fullscreen mode then use the fullscreen rect
|
/* If we're in fullscreen mode then use the fullscreen rect
|
||||||
instead */
|
instead */
|
||||||
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
|
||||||
{
|
{
|
||||||
get_fullscreen_rect (stage_win32);
|
get_fullscreen_rect (stage_win32);
|
||||||
win_xpos = stage_win32->fullscreen_rect.left;
|
win_xpos = stage_win32->fullscreen_rect.left;
|
||||||
win_ypos = stage_win32->fullscreen_rect.top;
|
win_ypos = stage_win32->fullscreen_rect.top;
|
||||||
win_width = stage_win32->fullscreen_rect.right - win_xpos;
|
win_width = stage_win32->fullscreen_rect.right - win_xpos;
|
||||||
win_height = stage_win32->fullscreen_rect.left - win_ypos;
|
win_height = stage_win32->fullscreen_rect.left - win_ypos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
win_xpos = win_ypos = CW_USEDEFAULT;
|
win_xpos = win_ypos = CW_USEDEFAULT;
|
||||||
|
|
||||||
get_full_window_size (stage_win32,
|
get_full_window_size (stage_win32,
|
||||||
stage_win32->win_width,
|
stage_win32->win_width,
|
||||||
stage_win32->win_height,
|
stage_win32->win_height,
|
||||||
&win_width, &win_height);
|
&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),
|
stage_win32->hwnd = CreateWindowW ((LPWSTR) MAKEINTATOM (window_class),
|
||||||
L".",
|
stage_win32->wtitle,
|
||||||
get_window_style (stage_win32),
|
get_window_style (stage_win32),
|
||||||
win_xpos,
|
win_xpos,
|
||||||
win_ypos,
|
win_ypos,
|
||||||
@ -507,13 +502,13 @@ clutter_stage_win32_realize (ClutterActor *actor)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (stage_win32->hwnd == NULL)
|
if (stage_win32->hwnd == NULL)
|
||||||
{
|
{
|
||||||
g_critical ("Unable to create stage window");
|
g_critical ("Unable to create stage window");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store a pointer to the actor in the extra bytes of the window
|
/* Store a pointer to the actor in the extra bytes of the window
|
||||||
so we can quickly access it in the window procedure */
|
so we can quickly access it in the window procedure */
|
||||||
SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) stage_win32);
|
SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) stage_win32);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,39 +530,32 @@ clutter_stage_win32_realize (ClutterActor *actor)
|
|||||||
backend_win32->gl_context = wglCreateContext (stage_win32->client_dc);
|
backend_win32->gl_context = wglCreateContext (stage_win32->client_dc);
|
||||||
|
|
||||||
if (backend_win32->gl_context == NULL)
|
if (backend_win32->gl_context == NULL)
|
||||||
{
|
{
|
||||||
g_critical ("Unable to create suitable GL context");
|
g_critical ("Unable to create suitable GL context");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make the context current so we can check the GL version */
|
/* Make the context current so we can check the GL version */
|
||||||
wglMakeCurrent (stage_win32->client_dc, backend_win32->gl_context);
|
wglMakeCurrent (stage_win32->client_dc, backend_win32->gl_context);
|
||||||
|
|
||||||
if (!clutter_stage_win32_check_gl_version ())
|
if (!clutter_stage_win32_check_gl_version ())
|
||||||
{
|
{
|
||||||
g_critical ("OpenGL version number is too low");
|
g_critical ("OpenGL version number is too low");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
||||||
|
|
||||||
return;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)
|
if (stage_win32->client_dc)
|
||||||
{
|
{
|
||||||
ReleaseDC (stage_win32->hwnd, stage_win32->client_dc);
|
ReleaseDC (stage_win32->hwnd, stage_win32->client_dc);
|
||||||
@ -577,20 +565,38 @@ clutter_stage_win32_unrealize (ClutterActor *actor)
|
|||||||
if (!stage_win32->is_foreign_win && stage_win32->hwnd)
|
if (!stage_win32->is_foreign_win && stage_win32->hwnd)
|
||||||
{
|
{
|
||||||
/* Drop the pointer to this stage in the window so that any
|
/* Drop the pointer to this stage in the window so that any
|
||||||
further messages won't be processed. The stage might be being
|
further messages won't be processed. The stage might be being
|
||||||
destroyed so otherwise the messages would be handled with an
|
destroyed so otherwise the messages would be handled with an
|
||||||
invalid stage instance */
|
invalid stage instance */
|
||||||
SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) 0);
|
SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) 0);
|
||||||
DestroyWindow (stage_win32->hwnd);
|
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
|
static void
|
||||||
clutter_stage_win32_dispose (GObject *gobject)
|
clutter_stage_win32_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (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);
|
G_OBJECT_CLASS (clutter_stage_win32_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,15 +604,8 @@ static void
|
|||||||
clutter_stage_win32_class_init (ClutterStageWin32Class *klass)
|
clutter_stage_win32_class_init (ClutterStageWin32Class *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = clutter_stage_win32_dispose;
|
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
|
static void
|
||||||
@ -619,7 +618,8 @@ clutter_stage_win32_init (ClutterStageWin32 *stage)
|
|||||||
stage->backend = NULL;
|
stage->backend = NULL;
|
||||||
stage->scroll_pos = 0;
|
stage->scroll_pos = 0;
|
||||||
stage->is_foreign_win = FALSE;
|
stage->is_foreign_win = FALSE;
|
||||||
|
stage->wtitle = NULL;
|
||||||
|
stage->is_cursor_visible = TRUE;
|
||||||
stage->wrapper = NULL;
|
stage->wrapper = NULL;
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IS_TOPLEVEL);
|
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->get_wrapper = clutter_stage_win32_get_wrapper;
|
||||||
iface->set_title = clutter_stage_win32_set_title;
|
iface->set_title = clutter_stage_win32_set_title;
|
||||||
iface->set_fullscreen = clutter_stage_win32_set_fullscreen;
|
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->set_user_resizable = clutter_stage_win32_set_user_resize;
|
||||||
iface->show = clutter_stage_win32_show;
|
iface->show = clutter_stage_win32_show;
|
||||||
iface->hide = clutter_stage_win32_hide;
|
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
|
void
|
||||||
clutter_stage_win32_map (ClutterStageWin32 *stage_win32)
|
clutter_stage_win32_map (ClutterStageWin32 *stage_win32)
|
||||||
{
|
{
|
||||||
clutter_actor_map (CLUTTER_ACTOR (stage_win32));
|
|
||||||
clutter_actor_map (CLUTTER_ACTOR (stage_win32->wrapper));
|
clutter_actor_map (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||||
|
|
||||||
clutter_actor_queue_relayout (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
|
void
|
||||||
clutter_stage_win32_unmap (ClutterStageWin32 *stage_win32)
|
clutter_stage_win32_unmap (ClutterStageWin32 *stage_win32)
|
||||||
{
|
{
|
||||||
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32));
|
|
||||||
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32->wrapper));
|
clutter_actor_unmap (CLUTTER_ACTOR (stage_win32->wrapper));
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ struct _ClutterStageWin32
|
|||||||
RECT fullscreen_rect;
|
RECT fullscreen_rect;
|
||||||
gboolean is_foreign_win;
|
gboolean is_foreign_win;
|
||||||
gboolean tracking_mouse;
|
gboolean tracking_mouse;
|
||||||
|
wchar_t *wtitle;
|
||||||
|
gboolean is_cursor_visible;
|
||||||
|
|
||||||
ClutterBackendWin32 *backend;
|
ClutterBackendWin32 *backend;
|
||||||
ClutterStageState state;
|
ClutterStageState state;
|
||||||
|
Loading…
Reference in New Issue
Block a user