On Tue, 11 Mar 2014 19:27:19 +0800
Quanxian Wang <[email protected]> wrote:

> 1)
> Width and height of Panel and Background depend on output's, therefore
> they should be bound with output changes including mode, transform and
> scale.
> 
> 2)
> Update the min_allocation before resize the panel and background
> window. Add window_set_min_allocation function because it is invisible
> outside window.c.
> 
> Signed-off-by: Quanxian Wang <[email protected]>
> ---
>  clients/desktop-shell.c | 75 
> +++++++++++++++++++++++++++++++++++++++++++++++--
>  clients/window.c        |  7 +++++
>  clients/window.h        |  2 ++
>  3 files changed, 81 insertions(+), 3 deletions(-)
> 
> diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
> index a0c6b6d..dc98ea1 100644
> --- a/clients/desktop-shell.c
> +++ b/clients/desktop-shell.c
> @@ -103,6 +103,15 @@ struct output {
>  
>       struct panel *panel;
>       struct background *background;
> +     struct {
> +             int height;
> +             int width;
> +             uint32_t refresh;
> +     } mode;
> +
> +     uint32_t interface_version;
> +     uint32_t transform;
> +     uint32_t scale;
>  };
>  
>  struct panel_launcher {
> @@ -1145,6 +1154,39 @@ desktop_destroy_outputs(struct desktop *desktop)
>  }
>  
>  static void
> +update_output(struct output *output)
> +{
> +     struct panel *panel = output->panel;
> +     struct background *background = output->background;
> +     int width, height;
> +
> +     width = output->mode.width;
> +     height = output->mode.height;
> +
> +     switch (output->transform) {
> +     case WL_OUTPUT_TRANSFORM_90:
> +     case WL_OUTPUT_TRANSFORM_270:
> +     case WL_OUTPUT_TRANSFORM_FLIPPED_90:
> +     case WL_OUTPUT_TRANSFORM_FLIPPED_270:
> +             /* Swap width and height */
> +             width = output->mode.height;
> +             height = output->mode.width;
> +             break;
> +     default:
> +             break;
> +     }
> +
> +     width /= output->scale;
> +     height /= output->scale;
> +
> +     window_set_min_allocation(panel->window, width, 32);
> +     window_set_min_allocation(background->window, width, height);
> +
> +     window_schedule_resize(background->window, width, height);
> +     window_schedule_resize(panel->window, width, 32);
> +}
> +
> +static void
>  output_handle_geometry(void *data,
>                         struct wl_output *wl_output,
>                         int x, int y,
> @@ -1157,6 +1199,11 @@ output_handle_geometry(void *data,
>  {
>       struct output *output = data;
>  
> +     output->transform = transform;
> +
> +     if (output->interface_version < 2)
> +             update_output(output);
> +
>       window_set_buffer_transform(output->panel->window, transform);
>       window_set_buffer_transform(output->background->window, transform);
>  }
> @@ -1169,12 +1216,28 @@ output_handle_mode(void *data,
>                  int height,
>                  int refresh)
>  {
> +     struct output *output = data;
> +
> +     if (flags & WL_OUTPUT_MODE_CURRENT) {
> +             if (!output)
> +                     return;
> +
> +             output->mode.width = width;
> +             output->mode.height = height;
> +             output->mode.refresh = refresh;
> +
> +             if (output->interface_version < 2)
> +                     update_output(output);
> +     }
>  }
>  
>  static void
>  output_handle_done(void *data,
>                     struct wl_output *wl_output)
>  {
> +     struct output *output = data;
> +
> +     update_output(output);
>  }
>  
>  static void
> @@ -1184,6 +1247,8 @@ output_handle_scale(void *data,
>  {
>       struct output *output = data;
>  
> +     output->scale  = scale;
> +
>       window_set_buffer_scale(output->panel->window, scale);
>       window_set_buffer_scale(output->background->window, scale);
>  }
> @@ -1212,7 +1277,7 @@ output_init(struct output *output, struct desktop 
> *desktop)
>  }
>  
>  static void
> -create_output(struct desktop *desktop, uint32_t id)
> +create_output(struct desktop *desktop, uint32_t id, uint32_t version)
>  {
>       struct output *output;
>  
> @@ -1220,9 +1285,13 @@ create_output(struct desktop *desktop, uint32_t id)
>       if (!output)
>               return;
>  
> +     output->interface_version = (version < 2) ? version : 2;
>       output->output =
> -             display_bind(desktop->display, id, &wl_output_interface, 2);
> +             display_bind(desktop->display, id,
> +                          &wl_output_interface,
> +                          output->interface_version);
>       output->server_output_id = id;
> +     output->scale = 1;
>  
>       wl_output_add_listener(output->output, &output_listener, output);
>  
> @@ -1247,7 +1316,7 @@ global_handler(struct display *display, uint32_t id,
>                                             desktop->interface_version);
>               desktop_shell_add_listener(desktop->shell, &listener, desktop);
>       } else if (!strcmp(interface, "wl_output")) {
> -             create_output(desktop, id);
> +             create_output(desktop, id, version);
>       }
>  }
>  
> diff --git a/clients/window.c b/clients/window.c
> index c8287e2..6c01222 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -3839,6 +3839,13 @@ undo_resize(struct window *window)
>  }
>  
>  void
> +window_set_min_allocation(struct window *window, int width, int height)
> +{
> +     window->min_allocation.width = width;
> +     window->min_allocation.height = height;
> +}
> +
> +void
>  window_schedule_resize(struct window *window, int width, int height)
>  {
>       /* We should probably get these numbers from the theme. */
> diff --git a/clients/window.h b/clients/window.h
> index 54b848b..b221b76 100644
> --- a/clients/window.h
> +++ b/clients/window.h
> @@ -336,6 +336,8 @@ void
>  window_schedule_redraw(struct window *window);
>  void
>  window_schedule_resize(struct window *window, int width, int height);
> +void
> +window_set_min_allocation(struct window *window, int width, int height);
>  
>  void
>  window_damage(struct window *window, int32_t x, int32_t y,

Hi,

looks fine to me now. :-)
(Didn't test.)


Thanks,
pq
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to