desktop-shell: Add beginning of pop-up menu to panel
This commit is contained in:
parent
dcef9ca23c
commit
bcee9a4b25
|
@ -46,6 +46,7 @@ struct desktop {
|
||||||
|
|
||||||
struct panel {
|
struct panel {
|
||||||
struct window *window;
|
struct window *window;
|
||||||
|
struct window *menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct panel_item {
|
struct panel_item {
|
||||||
|
@ -66,6 +67,21 @@ sigchild_handler(int s)
|
||||||
fprintf(stderr, "child %d exited\n", pid);
|
fprintf(stderr, "child %d exited\n", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_menu(struct panel *panel, struct input *input)
|
||||||
|
{
|
||||||
|
int32_t x, y, width = 200, height = 200;
|
||||||
|
struct display *display;
|
||||||
|
|
||||||
|
input_get_position(input, &x, &y);
|
||||||
|
display = window_get_display(panel->window);
|
||||||
|
panel->menu = window_create_transient(display, panel->window,
|
||||||
|
x - 10, y - 10, width, height);
|
||||||
|
|
||||||
|
window_draw(panel->menu);
|
||||||
|
window_flush(panel->menu);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_activate_item(struct panel *panel, struct panel_item *item)
|
panel_activate_item(struct panel *panel, struct panel_item *item)
|
||||||
{
|
{
|
||||||
|
@ -164,6 +180,11 @@ panel_button_handler(struct window *window,
|
||||||
window_schedule_redraw(panel->window);
|
window_schedule_redraw(panel->window);
|
||||||
if (state == 0)
|
if (state == 0)
|
||||||
panel_activate_item(panel, pi);
|
panel_activate_item(panel, pi);
|
||||||
|
} else if (button == BTN_RIGHT) {
|
||||||
|
if (state)
|
||||||
|
show_menu(panel, input);
|
||||||
|
else
|
||||||
|
window_destroy(panel->menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -862,6 +862,12 @@ window_resize_cairo_window_surface(struct window *window)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct display *
|
||||||
|
window_get_display(struct window *window)
|
||||||
|
{
|
||||||
|
return window->display;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_create_surface(struct window *window)
|
window_create_surface(struct window *window)
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,6 +179,8 @@ window_for_each_item(struct window *window, item_func_t func, void *data);
|
||||||
|
|
||||||
struct item *
|
struct item *
|
||||||
window_get_focus_item(struct window *window);
|
window_get_focus_item(struct window *window);
|
||||||
|
struct display *
|
||||||
|
window_get_display(struct window *window);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_move(struct window *window, struct input *input, uint32_t time);
|
window_move(struct window *window, struct input *input, uint32_t time);
|
||||||
|
|
Loading…
Reference in New Issue