xdg-shell: Add show_window_menu request
This commit is contained in:
parent
de8bd50d35
commit
81ff075bf4
@ -2228,61 +2228,19 @@ frame_get_pointer_image_for_location(struct window_frame *frame,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
frame_menu_func(void *data, struct input *input, int index)
|
|
||||||
{
|
|
||||||
struct window *window = data;
|
|
||||||
struct display *display;
|
|
||||||
|
|
||||||
switch (index) {
|
|
||||||
case 0: /* close */
|
|
||||||
window_close(window);
|
|
||||||
break;
|
|
||||||
case 1: /* move to workspace above */
|
|
||||||
display = window->display;
|
|
||||||
if (display->workspace > 0)
|
|
||||||
workspace_manager_move_surface(
|
|
||||||
display->workspace_manager,
|
|
||||||
window->main_surface->surface,
|
|
||||||
display->workspace - 1);
|
|
||||||
break;
|
|
||||||
case 2: /* move to workspace below */
|
|
||||||
display = window->display;
|
|
||||||
if (display->workspace < display->workspace_count - 1)
|
|
||||||
workspace_manager_move_surface(
|
|
||||||
display->workspace_manager,
|
|
||||||
window->main_surface->surface,
|
|
||||||
display->workspace + 1);
|
|
||||||
break;
|
|
||||||
case 3: /* fullscreen */
|
|
||||||
/* we don't have a way to get out of fullscreen for now */
|
|
||||||
if (window->fullscreen_handler)
|
|
||||||
window->fullscreen_handler(window, window->user_data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
window_show_frame_menu(struct window *window,
|
window_show_frame_menu(struct window *window,
|
||||||
struct input *input, uint32_t time)
|
struct input *input, uint32_t time)
|
||||||
{
|
{
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
int count;
|
|
||||||
|
|
||||||
static const char *entries[] = {
|
|
||||||
"Close",
|
|
||||||
"Move to workspace above", "Move to workspace below",
|
|
||||||
"Fullscreen"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (window->fullscreen_handler)
|
|
||||||
count = ARRAY_LENGTH(entries);
|
|
||||||
else
|
|
||||||
count = ARRAY_LENGTH(entries) - 1;
|
|
||||||
|
|
||||||
|
if (window->xdg_surface) {
|
||||||
input_get_position(input, &x, &y);
|
input_get_position(input, &x, &y);
|
||||||
window_show_menu(window->display, input, time, window,
|
xdg_surface_show_window_menu(window->xdg_surface,
|
||||||
x - 10, y - 10, frame_menu_func, entries, count);
|
input_get_seat(input),
|
||||||
|
window->display->serial,
|
||||||
|
x - 10, y - 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -3416,6 +3416,17 @@ xdg_surface_set_app_id(struct wl_client *client,
|
|||||||
shsurf->class = strdup(app_id);
|
shsurf->class = strdup(app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xdg_surface_show_window_menu(struct wl_client *client,
|
||||||
|
struct wl_resource *surface_resource,
|
||||||
|
struct wl_resource *seat_resource,
|
||||||
|
uint32_t serial,
|
||||||
|
int32_t x,
|
||||||
|
int32_t y)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_surface_set_title(struct wl_client *client,
|
xdg_surface_set_title(struct wl_client *client,
|
||||||
struct wl_resource *resource, const char *title)
|
struct wl_resource *resource, const char *title)
|
||||||
@ -3528,6 +3539,7 @@ static const struct xdg_surface_interface xdg_surface_implementation = {
|
|||||||
xdg_surface_set_margin,
|
xdg_surface_set_margin,
|
||||||
xdg_surface_set_title,
|
xdg_surface_set_title,
|
||||||
xdg_surface_set_app_id,
|
xdg_surface_set_app_id,
|
||||||
|
xdg_surface_show_window_menu,
|
||||||
xdg_surface_move,
|
xdg_surface_move,
|
||||||
xdg_surface_resize,
|
xdg_surface_resize,
|
||||||
xdg_surface_ack_configure,
|
xdg_surface_ack_configure,
|
||||||
|
@ -198,6 +198,26 @@
|
|||||||
<arg name="app_id" type="string"/>
|
<arg name="app_id" type="string"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
|
<request name="show_window_menu">
|
||||||
|
<description summary="show the window menu">
|
||||||
|
Clients implementing client-side decorations might want to show
|
||||||
|
a context menu when right-clicking on the decorations, giving the
|
||||||
|
user a menu that they can use to maximize or minimize the window.
|
||||||
|
|
||||||
|
This request asks the compositor to pop up such a window menu at
|
||||||
|
the given position, relative to the parent surface. There are
|
||||||
|
no guarantees as to what the window menu contains.
|
||||||
|
|
||||||
|
Your surface must have focus on the seat passed in to pop up the
|
||||||
|
window menu.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<arg name="seat" type="object" interface="wl_seat" summary="the seat to pop the window up on"/>
|
||||||
|
<arg name="serial" type="uint" summary="serial of the event to pop up the window for"/>
|
||||||
|
<arg name="x" type="int" summary="the x position to pop up the window menu at"/>
|
||||||
|
<arg name="y" type="int" summary="the y position to pop up the window menu at"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
<request name="move">
|
<request name="move">
|
||||||
<description summary="start an interactive move">
|
<description summary="start an interactive move">
|
||||||
Start a pointer-driven move of the surface.
|
Start a pointer-driven move of the surface.
|
||||||
|
Loading…
Reference in New Issue
Block a user