[PATCH 6/6] Change the size of Panel and Background after output's is changed
Quanxian Wang
quanxian.wang at intel.com
Wed Feb 26 19:28:05 PST 2014
Panel and background depend on the size of output,
So they have to be bound with output change including
mode, transform and scale.
Before resize the panel and background window,
their min_allocation has to be reset.
Add window_set_min_allocation function
Signed-off-by: Quanxian Wang <quanxian.wang at intel.com>
Reviewed-by: Zhang, Xiong Y <xiong.y.zhang at intel.com>
---
clients/desktop-shell.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
clients/window.c | 7 ++++++
clients/window.h | 2 ++
3 files changed, 69 insertions(+)
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..436e2e8 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -96,6 +96,12 @@ struct background {
uint32_t color;
};
+struct mode {
+ int height;
+ int width;
+ uint32_t refresh;
+};
+
struct output {
struct wl_output *output;
uint32_t server_output_id;
@@ -103,6 +109,8 @@ struct output {
struct panel *panel;
struct background *background;
+ struct mode *mode;
+ uint32_t transform;
};
struct panel_launcher {
@@ -1128,6 +1136,8 @@ output_destroy(struct output *output)
{
background_destroy(output->background);
panel_destroy(output->panel);
+ if (output->mode)
+ free(output->mode);
wl_output_destroy(output->output);
wl_list_remove(&output->link);
@@ -1145,6 +1155,40 @@ desktop_destroy_outputs(struct desktop *desktop)
}
static void
+update_output(struct output *output, int transform)
+{
+ struct panel *panel = output->panel;
+ struct background *background = output->background;
+ int width, height;
+
+ output->transform = transform;
+
+ if (!output || !output->mode)
+ return;
+
+ width = output->mode->width;
+ height = output->mode->height;
+
+ switch (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;
+ }
+
+ /* Set min_allocation of panel */
+ window_set_min_allocation(panel->window, width, 32);
+ 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 +1201,7 @@ output_handle_geometry(void *data,
{
struct output *output = data;
+ update_output(output, transform);
window_set_buffer_transform(output->panel->window, transform);
window_set_buffer_transform(output->background->window, transform);
}
@@ -1169,6 +1214,17 @@ output_handle_mode(void *data,
int height,
int refresh)
{
+ struct output *output = data;
+
+ if (flags & WL_OUTPUT_MODE_CURRENT) {
+ if (!output && !output->mode)
+ return;
+
+ output->mode->width = width;
+ output->mode->height = height;
+ output->mode->refresh = refresh;
+ update_output(output, output->transform);
+ }
}
static void
@@ -1206,6 +1262,10 @@ output_init(struct output *output, struct desktop *desktop)
output->output, surface);
output->background = background_create(desktop);
+ output->mode = (struct mode *)xzalloc(sizeof(*output->mode));
+ if (!output->mode)
+ fprintf(stderr, "No memory for mode allocation.\n");
+
surface = window_get_wl_surface(output->background->window);
desktop_shell_set_background(desktop->shell,
output->output, surface);
diff --git a/clients/window.c b/clients/window.c
index d8d79d0..5d797bb 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3843,6 +3843,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 dec133f..f66079c 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,
--
1.8.1.2
More information about the wayland-devel
mailing list