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

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to