compositor, shell: add and use weston_surface_set_position()
Another shorthand like weston_surface_configure(). Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
+12
-3
@@ -518,6 +518,15 @@ weston_surface_configure(struct weston_surface *surface,
|
|||||||
surface->geometry.dirty = 1;
|
surface->geometry.dirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
weston_surface_set_position(struct weston_surface *surface,
|
||||||
|
GLfloat x, GLfloat y)
|
||||||
|
{
|
||||||
|
surface->geometry.x = x;
|
||||||
|
surface->geometry.y = y;
|
||||||
|
surface->geometry.dirty = 1;
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT uint32_t
|
WL_EXPORT uint32_t
|
||||||
weston_compositor_get_time(void)
|
weston_compositor_get_time(void)
|
||||||
{
|
{
|
||||||
@@ -1364,9 +1373,9 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
|
|||||||
device->grab->x, device->grab->y);
|
device->grab->x, device->grab->y);
|
||||||
|
|
||||||
if (wd->sprite) {
|
if (wd->sprite) {
|
||||||
wd->sprite->geometry.x = device->x - wd->hotspot_x;
|
weston_surface_set_position(wd->sprite,
|
||||||
wd->sprite->geometry.y = device->y - wd->hotspot_y;
|
device->x - wd->hotspot_x,
|
||||||
wd->sprite->geometry.dirty = 1;
|
device->y - wd->hotspot_y);
|
||||||
|
|
||||||
weston_compositor_schedule_repaint(ec);
|
weston_compositor_schedule_repaint(ec);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,6 +398,10 @@ void
|
|||||||
weston_surface_configure(struct weston_surface *surface,
|
weston_surface_configure(struct weston_surface *surface,
|
||||||
GLfloat x, GLfloat y, int width, int height);
|
GLfloat x, GLfloat y, int width, int height);
|
||||||
|
|
||||||
|
void
|
||||||
|
weston_surface_set_position(struct weston_surface *surface,
|
||||||
|
GLfloat x, GLfloat y);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_surface_assign_output(struct weston_surface *surface);
|
weston_surface_assign_output(struct weston_surface *surface);
|
||||||
|
|
||||||
|
|||||||
+18
-26
@@ -346,9 +346,9 @@ reset_shell_surface_type(struct shell_surface *surface)
|
|||||||
{
|
{
|
||||||
switch (surface->type) {
|
switch (surface->type) {
|
||||||
case SHELL_SURFACE_FULLSCREEN:
|
case SHELL_SURFACE_FULLSCREEN:
|
||||||
surface->surface->geometry.x = surface->saved_x;
|
weston_surface_set_position(surface->surface,
|
||||||
surface->surface->geometry.y = surface->saved_y;
|
surface->saved_x,
|
||||||
surface->surface->geometry.dirty = 1;
|
surface->saved_y);
|
||||||
surface->surface->fullscreen_output = NULL;
|
surface->surface->fullscreen_output = NULL;
|
||||||
break;
|
break;
|
||||||
case SHELL_SURFACE_PANEL:
|
case SHELL_SURFACE_PANEL:
|
||||||
@@ -402,10 +402,8 @@ shell_surface_set_transient(struct wl_client *client,
|
|||||||
|
|
||||||
/* assign to parents output */
|
/* assign to parents output */
|
||||||
es->output = pes->output;
|
es->output = pes->output;
|
||||||
|
weston_surface_set_position(es, pes->geometry.x + x,
|
||||||
es->geometry.x = pes->geometry.x + x;
|
pes->geometry.y + y);
|
||||||
es->geometry.y = pes->geometry.y + y;
|
|
||||||
es->geometry.dirty = 1;
|
|
||||||
|
|
||||||
shsurf->type = SHELL_SURFACE_TRANSIENT;
|
shsurf->type = SHELL_SURFACE_TRANSIENT;
|
||||||
}
|
}
|
||||||
@@ -436,9 +434,9 @@ shell_surface_set_fullscreen(struct wl_client *client,
|
|||||||
|
|
||||||
shsurf->saved_x = es->geometry.x;
|
shsurf->saved_x = es->geometry.x;
|
||||||
shsurf->saved_y = es->geometry.y;
|
shsurf->saved_y = es->geometry.y;
|
||||||
es->geometry.x = (output->current->width - es->geometry.width) / 2;
|
weston_surface_set_position(es,
|
||||||
es->geometry.y = (output->current->height - es->geometry.height) / 2;
|
(output->current->width - es->geometry.width) / 2,
|
||||||
es->geometry.dirty = 1;
|
(output->current->height - es->geometry.height) / 2);
|
||||||
es->fullscreen_output = output;
|
es->fullscreen_output = output;
|
||||||
shsurf->type = SHELL_SURFACE_FULLSCREEN;
|
shsurf->type = SHELL_SURFACE_FULLSCREEN;
|
||||||
}
|
}
|
||||||
@@ -533,9 +531,7 @@ shell_map_popup(struct shell_surface *shsurf, uint32_t time)
|
|||||||
}
|
}
|
||||||
wl_list_insert(es->geometry.transformation_list.prev,
|
wl_list_insert(es->geometry.transformation_list.prev,
|
||||||
&shsurf->popup.parent_transform.link);
|
&shsurf->popup.parent_transform.link);
|
||||||
es->geometry.x = shsurf->popup.x;
|
weston_surface_set_position(es, shsurf->popup.x, shsurf->popup.y);
|
||||||
es->geometry.y = shsurf->popup.y;
|
|
||||||
es->geometry.dirty = 1;
|
|
||||||
|
|
||||||
shsurf->popup.grab.input_device = device;
|
shsurf->popup.grab.input_device = device;
|
||||||
shsurf->popup.time = device->grab_time;
|
shsurf->popup.time = device->grab_time;
|
||||||
@@ -747,9 +743,8 @@ desktop_shell_set_background(struct wl_client *client,
|
|||||||
|
|
||||||
wl_list_insert(&shell->backgrounds, &shsurf->link);
|
wl_list_insert(&shell->backgrounds, &shsurf->link);
|
||||||
|
|
||||||
surface->geometry.x = shsurf->output->x;
|
weston_surface_set_position(surface, shsurf->output->x,
|
||||||
surface->geometry.y = shsurf->output->y;
|
shsurf->output->y);
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
wl_resource_post_event(resource,
|
wl_resource_post_event(resource,
|
||||||
DESKTOP_SHELL_CONFIGURE,
|
DESKTOP_SHELL_CONFIGURE,
|
||||||
@@ -786,9 +781,8 @@ desktop_shell_set_panel(struct wl_client *client,
|
|||||||
|
|
||||||
wl_list_insert(&shell->panels, &shsurf->link);
|
wl_list_insert(&shell->panels, &shsurf->link);
|
||||||
|
|
||||||
surface->geometry.x = shsurf->output->x;
|
weston_surface_set_position(surface, shsurf->output->x,
|
||||||
surface->geometry.y = shsurf->output->y;
|
shsurf->output->y);
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
wl_resource_post_event(resource,
|
wl_resource_post_event(resource,
|
||||||
DESKTOP_SHELL_CONFIGURE,
|
DESKTOP_SHELL_CONFIGURE,
|
||||||
@@ -1266,12 +1260,10 @@ static void
|
|||||||
center_on_output(struct weston_surface *surface, struct weston_output *output)
|
center_on_output(struct weston_surface *surface, struct weston_output *output)
|
||||||
{
|
{
|
||||||
struct weston_mode *mode = output->current;
|
struct weston_mode *mode = output->current;
|
||||||
|
GLfloat x = (mode->width - surface->geometry.width) / 2;
|
||||||
|
GLfloat y = (mode->height - surface->geometry.height) / 2;
|
||||||
|
|
||||||
surface->geometry.x =
|
weston_surface_set_position(surface, output->x + x, output->y + y);
|
||||||
output->x + (mode->width - surface->geometry.width) / 2;
|
|
||||||
surface->geometry.y =
|
|
||||||
output->y + (mode->height - surface->geometry.height) / 2;
|
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1304,8 +1296,8 @@ map(struct weston_shell *base,
|
|||||||
/* initial positioning, see also configure() */
|
/* initial positioning, see also configure() */
|
||||||
switch (surface_type) {
|
switch (surface_type) {
|
||||||
case SHELL_SURFACE_TOPLEVEL:
|
case SHELL_SURFACE_TOPLEVEL:
|
||||||
surface->geometry.x = 10 + random() % 400;
|
weston_surface_set_position(surface, 10 + random() % 400,
|
||||||
surface->geometry.y = 10 + random() % 400;
|
10 + random() % 400);
|
||||||
break;
|
break;
|
||||||
case SHELL_SURFACE_SCREENSAVER:
|
case SHELL_SURFACE_SCREENSAVER:
|
||||||
case SHELL_SURFACE_FULLSCREEN:
|
case SHELL_SURFACE_FULLSCREEN:
|
||||||
|
|||||||
+4
-14
@@ -110,9 +110,7 @@ tablet_shell_map(struct weston_shell *base, struct weston_surface *surface,
|
|||||||
struct tablet_shell *shell =
|
struct tablet_shell *shell =
|
||||||
container_of(base, struct tablet_shell, shell);
|
container_of(base, struct tablet_shell, shell);
|
||||||
|
|
||||||
surface->geometry.x = 0;
|
weston_surface_configure(surface, 0, 0, width, height);
|
||||||
surface->geometry.y = 0;
|
|
||||||
surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
if (surface == shell->lockscreen_surface) {
|
if (surface == shell->lockscreen_surface) {
|
||||||
/* */
|
/* */
|
||||||
@@ -134,8 +132,6 @@ tablet_shell_map(struct weston_shell *base, struct weston_surface *surface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wl_list_insert(&shell->compositor->surface_list, &surface->link);
|
wl_list_insert(&shell->compositor->surface_list, &surface->link);
|
||||||
weston_surface_configure(surface, surface->geometry.x,
|
|
||||||
surface->geometry.y, width, height);
|
|
||||||
weston_surface_assign_output(surface);
|
weston_surface_assign_output(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +164,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
|
|||||||
struct tablet_shell *shell = resource->data;
|
struct tablet_shell *shell = resource->data;
|
||||||
struct weston_surface *es = surface_resource->data;
|
struct weston_surface *es = surface_resource->data;
|
||||||
|
|
||||||
es->geometry.x = 0;
|
weston_surface_set_position(es, 0, 0);
|
||||||
es->geometry.y = 0;
|
|
||||||
es->geometry.dirty = 1;
|
|
||||||
shell->lockscreen_surface = es;
|
shell->lockscreen_surface = es;
|
||||||
shell->lockscreen_listener.func = handle_lockscreen_surface_destroy;
|
shell->lockscreen_listener.func = handle_lockscreen_surface_destroy;
|
||||||
wl_list_insert(es->surface.resource.destroy_listener_list.prev,
|
wl_list_insert(es->surface.resource.destroy_listener_list.prev,
|
||||||
@@ -203,9 +197,7 @@ tablet_shell_set_switcher(struct wl_client *client,
|
|||||||
* layer idea, we should be able to hit the framerate on the
|
* layer idea, we should be able to hit the framerate on the
|
||||||
* fade/zoom in. */
|
* fade/zoom in. */
|
||||||
shell->switcher_surface = es;
|
shell->switcher_surface = es;
|
||||||
shell->switcher_surface->geometry.x = 0;
|
weston_surface_set_position(shell->switcher_surface, 0, 0);
|
||||||
shell->switcher_surface->geometry.y = 0;
|
|
||||||
shell->switcher_surface->geometry.dirty = 1;
|
|
||||||
|
|
||||||
shell->switcher_listener.func = handle_switcher_surface_destroy;
|
shell->switcher_listener.func = handle_switcher_surface_destroy;
|
||||||
wl_list_insert(es->surface.resource.destroy_listener_list.prev,
|
wl_list_insert(es->surface.resource.destroy_listener_list.prev,
|
||||||
@@ -220,9 +212,7 @@ tablet_shell_set_homescreen(struct wl_client *client,
|
|||||||
struct tablet_shell *shell = resource->data;
|
struct tablet_shell *shell = resource->data;
|
||||||
|
|
||||||
shell->home_surface = surface_resource->data;
|
shell->home_surface = surface_resource->data;
|
||||||
shell->home_surface->geometry.x = 0;
|
weston_surface_set_position(shell->home_surface, 0, 0);
|
||||||
shell->home_surface->geometry.y = 0;
|
|
||||||
shell->home_surface->geometry.dirty = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user