[writing a compositor] Window does not return to previous position on unmaximize

adlo adloconwy at gmail.com
Thu Oct 11 06:31:33 UTC 2018


As far as I can tell my code looks the same as Weston's code. What might I be doing differently that results in the windows not returning to their original position?

Regards

adlo


> On 25 Sep 2018, at 04:41, adlo <adloconwy at gmail.com> wrote:
> 
> Here is some more code that I forgot to include:
> 
> static void
> unset_maximized(struct ShellSurface *shsurf)
> {
>    struct weston_surface *surface =
>        weston_desktop_surface_get_surface(shsurf-
>> desktop_surface);
> 
>    if (shsurf->saved_position_valid)
>        weston_view_set_position(shsurf->view,
>                     shsurf->saved_x, shsurf-
>> saved_y);
> 
>    shsurf->saved_position_valid = false;
> }
> 
> Regards
> 
> adlo
> 
> 
>> On Mon, 2018-09-24 at 04:32 +0100, adlo wrote:
>> I am writing a compositor using libweston. When unmaximizing a
>> window,
>> the window doesn't return to the position it was at before it was
>> maximized. How can I resolve this?
>> 
>> Here is my code:
>> 
>> static void
>> set_maximized_position (struct ShellSurface *shsurf)
>> {
>>    pixman_rectangle32_t area;
>>    struct weston_geometry geometry;
>> 
>>  area.x = shsurf->surface->output->x;
>>  area.y = shsurf->surface->output->y;
>> 
>>    geometry = weston_desktop_surface_get_geometry(shsurf-
>>> desktop_surface);
>> 
>>    weston_view_set_position(shsurf->view,
>>                 area.x - geometry.x,
>>                 area.y - geometry.y);
>> }
>> 
>> static void
>> map(struct TestServer *shell, struct ShellSurface *shsurf,
>>    int32_t sx, int32_t sy)
>> {
>>  if (shsurf->maximized)
>>    set_maximized_position (shsurf);
>>    weston_view_update_transform(shsurf->view);
>> 
>> }
>> 
>> static void
>> desktop_surface_committed(struct weston_desktop_surface
>> *desktop_surface,
>>              int32_t sx, int32_t sy, void *data)
>> {
>>    struct ShellSurface *shsurf =
>>        weston_desktop_surface_get_user_data(desktop_surface);
>>    struct weston_surface *surface =
>>        weston_desktop_surface_get_surface(desktop_surface);
>>    struct weston_view *view = shsurf->view;
>>    struct TestServer *shell = data;
>>    bool was_fullscreen;
>>    bool was_maximized;
>> 
>>    if (surface->width == 0)
>>        return;
>> 
>>  was_maximized = shsurf->maximized;
>> 
>>  shsurf->maximized =
>>    weston_desktop_surface_get_maximized (desktop_surface);
>> 
>>    if (!weston_surface_is_mapped(surface))
>>        map(shell, shsurf, sx, sy);
>> 
>>  if (was_maximized == shsurf->maximized)
>>    return;
>> 
>>  if (was_maximized)
>>    unset_maximized (shsurf);
>> 
>>  if (shsurf->maximized && !shsurf->saved_position_valid)
>>    {
>> 
>>  shsurf->saved_x = shsurf->view->geometry.x;
>>  shsurf->saved_y = shsurf->view->geometry.y;
>>      shsurf->saved_position_valid = true;
>>    }
>> 
>>  weston_view_set_position (shsurf->view,
>>                            shsurf->saved_x, shsurf->saved_y);
>> 
>>  if (shsurf->maximized)
>>    set_maximized_position (shsurf);
>> 
>> }
>> 
>> An earlier version of the rest of my code can be found at:
>> 
>> 
> https://github.com/adlocode/test-libweston-desktop/blob/master/shell.c
>> 
>> Regards
>> 
>> adlo
>> 
> 


More information about the wayland-devel mailing list