* clutter/win32/clutter-stage-win32.c: Updated to the new layout

API. All code to do with positioning the stage has been removed so
	the window is left where Windows wants to put it and it can not be
	moved with clutter_actor_set_position.

	* clutter/win32/clutter-stage-win32.h (ClutterStageWin32): Remove
	win_xpos and win_ypos.

	* clutter/win32/clutter-event-win32.c (message_translate): Remove
	the handler for WM_MOVE because the stage no longer cares where it
	is positioned.
This commit is contained in:
Neil Roberts 2008-06-12 12:12:25 +00:00
parent 8ff6cec829
commit e4304e2d0a
4 changed files with 92 additions and 119 deletions

View File

@ -1,3 +1,17 @@
2008-06-12 Neil Roberts <neil@o-hand.com>
* clutter/win32/clutter-stage-win32.c: Updated to the new layout
API. All code to do with positioning the stage has been removed so
the window is left where Windows wants to put it and it can not be
moved with clutter_actor_set_position.
* clutter/win32/clutter-stage-win32.h (ClutterStageWin32): Remove
win_xpos and win_ypos.
* clutter/win32/clutter-event-win32.c (message_translate): Remove
the handler for WM_MOVE because the stage no longer cares where it
is positioned.
2008-06-12 Emmanuele Bassi <ebassi@openedhand.com> 2008-06-12 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.[ch]: Documentation fixes. * clutter/clutter-actor.[ch]: Documentation fixes.

View File

@ -365,23 +365,6 @@ message_translate (ClutterBackend *backend,
res = FALSE; res = FALSE;
break; break;
case WM_MOVE:
if (!stage_win32->is_foreign_win)
{
WORD new_xpos = GET_X_LPARAM (msg->lParam);
WORD new_ypos = GET_Y_LPARAM (msg->lParam);
gint old_xpos, old_ypos;
clutter_actor_get_position (CLUTTER_ACTOR (stage),
&old_xpos, &old_ypos);
if (new_xpos != old_xpos || new_ypos != old_ypos)
clutter_actor_set_position (CLUTTER_ACTOR (stage),
new_xpos, new_ypos);
}
res = FALSE;
break;
case WM_SHOWWINDOW: case WM_SHOWWINDOW:
if (msg->wParam) if (msg->wParam)
clutter_stage_win32_map (stage_win32); clutter_stage_win32_map (stage_win32);

View File

@ -59,9 +59,15 @@ clutter_stage_win32_show (ClutterActor *actor)
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor); ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
if (stage_win32->hwnd) if (stage_win32->hwnd)
ShowWindow (stage_win32->hwnd, SW_SHOW); {
/* Force a redraw so that the layout will be run and the correct
size will be allocated to the window before it is
shown. Otherwise a WM_SIZE message will be sent which will
override the user's chosen size */
clutter_redraw (stage_win32->wrapper);
CLUTTER_ACTOR_SET_FLAGS (actor, CLUTTER_ACTOR_MAPPED); ShowWindow (stage_win32->hwnd, SW_SHOW);
}
} }
static void static void
@ -69,34 +75,56 @@ clutter_stage_win32_hide (ClutterActor *actor)
{ {
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor); ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor);
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_MAPPED);
if (stage_win32->hwnd) if (stage_win32->hwnd)
ShowWindow (stage_win32->hwnd, SW_HIDE); ShowWindow (stage_win32->hwnd, SW_HIDE);
} }
static void static void
clutter_stage_win32_query_coords (ClutterActor *self, clutter_stage_win32_get_preferred_width (ClutterActor *self,
ClutterActorBox *box) ClutterUnit for_height,
ClutterUnit *min_width_p,
ClutterUnit *natural_width_p)
{ {
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self); ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
int width;
/* If we're in fullscreen mode then return the size of the screen /* If we're in fullscreen mode then return the size of the screen
instead */ instead */
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
{ width = CLUTTER_UNITS_FROM_DEVICE (stage_win32->fullscreen_rect.right
box->x1 = CLUTTER_UNITS_FROM_INT (stage_win32->fullscreen_rect.left); - stage_win32->fullscreen_rect.left);
box->y1 = CLUTTER_UNITS_FROM_INT (stage_win32->fullscreen_rect.top);
box->x2 = CLUTTER_UNITS_FROM_INT (stage_win32->fullscreen_rect.right);
box->y2 = CLUTTER_UNITS_FROM_INT (stage_win32->fullscreen_rect.bottom);
}
else else
{ width = CLUTTER_UNITS_FROM_DEVICE (stage_win32->win_width);
box->x1 = CLUTTER_UNITS_FROM_INT (stage_win32->win_xpos);
box->y1 = CLUTTER_UNITS_FROM_INT (stage_win32->win_ypos); if (min_width_p)
box->x2 = box->x1 + CLUTTER_UNITS_FROM_INT (stage_win32->win_width); *min_width_p = width;
box->y2 = box->y1 + CLUTTER_UNITS_FROM_INT (stage_win32->win_height);
} if (natural_width_p)
*natural_width_p = width;
}
static void
clutter_stage_win32_get_preferred_height (ClutterActor *self,
ClutterUnit for_width,
ClutterUnit *min_height_p,
ClutterUnit *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 = CLUTTER_UNITS_FROM_DEVICE (stage_win32->fullscreen_rect.bottom
- stage_win32->fullscreen_rect.top);
else
height = CLUTTER_UNITS_FROM_DEVICE (stage_win32->win_height);
if (min_height_p)
*min_height_p = height;
if (natural_height_p)
*natural_height_p = height;
} }
static void static void
@ -123,22 +151,6 @@ get_fullscreen_rect (ClutterStageWin32 *stage_win32)
stage_win32->fullscreen_rect = monitor_info.rcMonitor; stage_win32->fullscreen_rect = monitor_info.rcMonitor;
} }
static void
get_full_window_pos (ClutterStageWin32 *stage_win32,
int xpos_in, int ypos_in,
int *xpos_out, int *ypos_out)
{
gboolean resizable
= clutter_stage_get_user_resizable (stage_win32->wrapper);
/* The window position passed to CreateWindow includes the window
decorations */
*xpos_out = xpos_in - GetSystemMetrics (resizable ? SM_CXSIZEFRAME
: SM_CXFIXEDFRAME);
*ypos_out = ypos_in - GetSystemMetrics (resizable ? SM_CYSIZEFRAME
: SM_CYFIXEDFRAME)
- GetSystemMetrics (SM_CYCAPTION);
}
static void static void
get_full_window_size (ClutterStageWin32 *stage_win32, get_full_window_size (ClutterStageWin32 *stage_win32,
int width_in, int height_in, int width_in, int height_in,
@ -175,50 +187,38 @@ _clutter_stage_win32_get_min_max_info (ClutterStageWin32 *stage_win32,
} }
static void static void
clutter_stage_win32_request_coords (ClutterActor *self, clutter_stage_win32_allocate (ClutterActor *self,
ClutterActorBox *box) const ClutterActorBox *box,
gboolean origin_changed)
{ {
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self); ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self);
gint new_xpos, new_ypos, new_width, new_height; gint new_width, new_height;
int change_flags = SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
new_xpos = CLUTTER_UNITS_TO_INT (MIN (box->x1, box->x2));
new_ypos = CLUTTER_UNITS_TO_INT (MIN (box->y1, box->y2));
new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1)); new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1)); new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
if (new_width != stage_win32->win_width if (new_width != stage_win32->win_width
|| new_height != stage_win32->win_height) || new_height != stage_win32->win_height)
change_flags &= ~SWP_NOSIZE;
if (new_xpos != stage_win32->win_xpos
|| new_ypos != stage_win32->win_ypos)
change_flags &= ~SWP_NOMOVE;
if ((change_flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)
/* Ignore size requests if we are in full screen mode */
&& (stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
{ {
stage_win32->win_xpos = new_xpos; /* Ignore size requests if we are in full screen mode */
stage_win32->win_ypos = new_ypos; if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
stage_win32->win_width = new_width;
stage_win32->win_height = new_height;
if (stage_win32->hwnd != NULL && !stage_win32->is_foreign_win)
{ {
int full_xpos, full_ypos, full_width, full_height; stage_win32->win_width = new_width;
stage_win32->win_height = new_height;
get_full_window_pos (stage_win32, if (stage_win32->hwnd != NULL && !stage_win32->is_foreign_win)
new_xpos, new_ypos, {
&full_xpos, &full_ypos); int full_width, full_height;
get_full_window_size (stage_win32,
new_width, new_height,
&full_width, &full_height);
SetWindowPos (stage_win32->hwnd, NULL, get_full_window_size (stage_win32,
full_xpos, full_ypos, new_width, new_height,
full_width, full_height, &full_width, &full_height);
change_flags);
SetWindowPos (stage_win32->hwnd, NULL,
0, 0,
full_width, full_height,
SWP_NOZORDER | SWP_NOMOVE);
}
} }
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper, CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
@ -226,7 +226,7 @@ clutter_stage_win32_request_coords (ClutterActor *self,
} }
CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class) CLUTTER_ACTOR_CLASS (clutter_stage_win32_parent_class)
->request_coords (self, box); ->allocate (self, box, origin_changed);
} }
static void static void
@ -315,21 +315,17 @@ clutter_stage_win32_set_fullscreen (ClutterStageWindow *stage_window,
} }
else else
{ {
int full_xpos, full_ypos, full_width, full_height; int full_width, full_height;
get_full_window_pos (stage_win32,
stage_win32->win_xpos,
stage_win32->win_ypos,
&full_xpos, &full_ypos);
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,
full_xpos, full_ypos, 0, 0,
full_width, full_height, full_width, full_height,
SWP_NOZORDER); SWP_NOZORDER | SWP_NOMOVE);
} }
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper, CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
@ -418,8 +414,6 @@ clutter_stage_win32_realize (ClutterActor *actor)
{ {
ATOM window_class = clutter_stage_win32_get_window_class (); ATOM window_class = clutter_stage_win32_get_window_class ();
int win_xpos, win_ypos, win_width, win_height; int win_xpos, win_ypos, win_width, win_height;
RECT win_rect;
POINT actual_pos;
if (window_class == 0) if (window_class == 0)
{ {
@ -439,12 +433,8 @@ clutter_stage_win32_realize (ClutterActor *actor)
} }
else else
{ {
if (stage_win32->win_xpos == 0 && stage_win32->win_ypos == 0) win_xpos = win_ypos = CW_USEDEFAULT;
win_xpos = win_ypos = CW_USEDEFAULT;
else
get_full_window_pos (stage_win32,
stage_win32->win_xpos, stage_win32->win_ypos,
&win_xpos, &win_ypos);
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,
@ -468,17 +458,6 @@ clutter_stage_win32_realize (ClutterActor *actor)
goto fail; goto fail;
} }
/* Get the position in case CW_USEDEFAULT was specified */
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0)
{
GetClientRect (stage_win32->hwnd, &win_rect);
actual_pos.x = win_rect.left;
actual_pos.y = win_rect.top;
ClientToScreen (stage_win32->hwnd, &actual_pos);
stage_win32->win_xpos = actual_pos.x;
stage_win32->win_ypos = actual_pos.y;
}
/* 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);
@ -588,8 +567,9 @@ clutter_stage_win32_class_init (ClutterStageWin32Class *klass)
actor_class->show = clutter_stage_win32_show; actor_class->show = clutter_stage_win32_show;
actor_class->hide = clutter_stage_win32_hide; actor_class->hide = clutter_stage_win32_hide;
actor_class->request_coords = clutter_stage_win32_request_coords; actor_class->get_preferred_width = clutter_stage_win32_get_preferred_width;
actor_class->query_coords = clutter_stage_win32_query_coords; 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->realize = clutter_stage_win32_realize;
actor_class->unrealize = clutter_stage_win32_unrealize; actor_class->unrealize = clutter_stage_win32_unrealize;
} }
@ -599,8 +579,6 @@ clutter_stage_win32_init (ClutterStageWin32 *stage)
{ {
stage->hwnd = NULL; stage->hwnd = NULL;
stage->client_dc = NULL; stage->client_dc = NULL;
stage->win_xpos = 0;
stage->win_ypos = 0;
stage->win_width = 640; stage->win_width = 640;
stage->win_height = 480; stage->win_height = 480;
stage->backend = NULL; stage->backend = NULL;
@ -736,8 +714,8 @@ clutter_win32_set_stage_foreign (ClutterStage *stage,
stage_win32->hwnd = hwnd; stage_win32->hwnd = hwnd;
stage_win32->is_foreign_win = TRUE; stage_win32->is_foreign_win = TRUE;
geom.x = window_pos.x; geom.x = 0;
geom.y = window_pos.y; geom.y = 0;
geom.width = client_rect.right - client_rect.left; geom.width = client_rect.right - client_rect.left;
geom.height = client_rect.bottom - client_rect.top; geom.height = client_rect.bottom - client_rect.top;
@ -753,7 +731,7 @@ clutter_stage_win32_map (ClutterStageWin32 *stage_win32)
CLUTTER_ACTOR_SET_FLAGS (stage_win32, CLUTTER_ACTOR_MAPPED); CLUTTER_ACTOR_SET_FLAGS (stage_win32, CLUTTER_ACTOR_MAPPED);
CLUTTER_ACTOR_SET_FLAGS (stage_win32->wrapper, CLUTTER_ACTOR_MAPPED); CLUTTER_ACTOR_SET_FLAGS (stage_win32->wrapper, CLUTTER_ACTOR_MAPPED);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage_win32->wrapper)); clutter_actor_queue_relayout (CLUTTER_ACTOR (stage_win32->wrapper));
} }
void void

View File

@ -46,8 +46,6 @@ struct _ClutterStageWin32
HWND hwnd; HWND hwnd;
HDC client_dc; HDC client_dc;
gint win_xpos;
gint win_ypos;
gint win_width; gint win_width;
gint win_height; gint win_height;
gint scroll_pos; gint scroll_pos;