desktop-shell: add set_panel_position to help place views onscreen

Panels are always assumed to be on the top edge of the output. If this
is not the case views will be placed under the panel, wherever it is,
and maximize doesn't use the correct space allocated for views.

By telling the server on which edge the panel is located, it can
correctly calculate where to put new views and how big maximized views
should be.

[Pekka Paalanen: the user of this protocol so far is Maynard.]

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Jonny Lamb 10 years ago committed by Pekka Paalanen
parent d3d128e07c
commit 765760dc71
  1. 29
      desktop-shell/shell.c
  2. 4
      desktop-shell/shell.h
  3. 25
      protocol/desktop-shell.xml

@ -4124,13 +4124,34 @@ desktop_shell_desktop_ready(struct wl_client *client,
shell_fade_startup(shell);
}
static void
desktop_shell_set_panel_position(struct wl_client *client,
struct wl_resource *resource,
uint32_t position)
{
struct desktop_shell *shell = wl_resource_get_user_data(resource);
if (position != DESKTOP_SHELL_PANEL_POSITION_TOP &&
position != DESKTOP_SHELL_PANEL_POSITION_BOTTOM &&
position != DESKTOP_SHELL_PANEL_POSITION_LEFT &&
position != DESKTOP_SHELL_PANEL_POSITION_RIGHT) {
wl_resource_post_error(resource,
DESKTOP_SHELL_ERROR_INVALID_ARGUMENT,
"bad position argument");
return;
}
shell->panel_position = position;
}
static const struct desktop_shell_interface desktop_shell_implementation = {
desktop_shell_set_background,
desktop_shell_set_panel,
desktop_shell_set_lock_surface,
desktop_shell_unlock,
desktop_shell_set_grab_surface,
desktop_shell_desktop_ready
desktop_shell_desktop_ready,
desktop_shell_set_panel_position
};
static enum shell_surface_type
@ -5344,7 +5365,7 @@ bind_desktop_shell(struct wl_client *client,
struct wl_resource *resource;
resource = wl_resource_create(client, &desktop_shell_interface,
MIN(version, 2), id);
MIN(version, 3), id);
if (client == shell->child.client) {
wl_resource_set_implementation(resource,
@ -6265,7 +6286,7 @@ module_init(struct weston_compositor *ec,
return -1;
if (wl_global_create(ec->wl_display,
&desktop_shell_interface, 2,
&desktop_shell_interface, 3,
shell, bind_desktop_shell) == NULL)
return -1;
@ -6279,6 +6300,8 @@ module_init(struct weston_compositor *ec,
shell->child.deathstamp = weston_compositor_get_time();
shell->panel_position = DESKTOP_SHELL_PANEL_POSITION_TOP;
setup_output_destroy_handler(ec, shell);
loop = wl_display_get_event_loop(ec->wl_display);

@ -26,6 +26,8 @@
#include "compositor.h"
#include "desktop-shell-server-protocol.h"
enum animation_type {
ANIMATION_NONE,
@ -205,6 +207,8 @@ struct desktop_shell {
struct wl_listener output_move_listener;
struct wl_list output_list;
enum desktop_shell_panel_position panel_position;
char *client;
};

@ -1,6 +1,6 @@
<protocol name="desktop">
<interface name="desktop_shell" version="2">
<interface name="desktop_shell" version="3">
<description summary="create desktop widgets and helpers">
Traditional user interfaces can rely on this interface to define the
foundations of typical desktops. Currently it's possible to set up
@ -94,6 +94,29 @@
</description>
</request>
<!-- Version 3 additions -->
<enum name="panel_position">
<entry name="top" value="0"/>
<entry name="bottom" value="1"/>
<entry name="left" value="2"/>
<entry name="right" value="3"/>
</enum>
<enum name="error">
<entry name="invalid_argument" value="0"
summary="an invalid argument was provided in a request"/>
</enum>
<request name="set_panel_position" since="3">
<arg name="position" type="uint"/>
<description summary="set panel position">
Tell the shell which side of the screen the panel is
located. This is so that new windows do not overlap the panel
and maximized windows maximize properly.
</description>
</request>
</interface>
<interface name="screensaver" version="1">

Loading…
Cancel
Save