clients/window: Add functions to set/retrieve app_id

Adds appid for all clients using the toolkit, flower, fullscreen, image,
resizor, scaler, smoke, stacking, subsurfaces, terminal,
touch-calibrator, transformed, etc.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2021-09-09 13:52:18 +03:00 committed by Simon Ser
parent 713f02327d
commit b3544c26ad
24 changed files with 60 additions and 1 deletions

View File

@ -232,6 +232,8 @@ calibrator_create(struct display *display, bool enable_button)
calibrator->window = window_create(display);
calibrator->widget = window_add_widget(calibrator->window, calibrator);
window_set_title(calibrator->window, "Wayland calibrator");
window_set_appid(calibrator->window,
"org.freedesktop.weston.wayland-calibrator");
calibrator->display = display;
calibrator->current_test = ARRAY_LENGTH(test_ratios) - 1;

View File

@ -281,6 +281,8 @@ clickdot_create(struct display *display)
clickdot->window = window_create(display);
clickdot->widget = window_frame_create(clickdot->window, clickdot);
window_set_title(clickdot->window, "Wayland ClickDot");
window_set_appid(clickdot->window,
"org.freedesktop.weston.wayland-clickdot");
clickdot->display = display;
clickdot->buffer = NULL;

View File

@ -522,6 +522,7 @@ cliptest_create(struct display *display)
cliptest->window = window_create(display);
cliptest->widget = window_frame_create(cliptest->window, cliptest);
window_set_title(cliptest->window, "cliptest");
window_set_appid(cliptest->window, "org.freedesktop.weston.cliptest");
cliptest->display = display;
window_set_user_data(cliptest->window, cliptest);

View File

@ -423,6 +423,8 @@ confine_create(struct display *display)
confine->window = window_create(display);
confine->widget = window_frame_create(confine->window, confine);
window_set_title(confine->window, "Wayland Confine");
window_set_appid(confine->window,
"org.freedesktop.weston.wayland-confine");
confine->display = display;
confine->buffer = NULL;

View File

@ -367,7 +367,9 @@ int main(int argc, char *argv[])
pc_player->enforced = create_button(pc_player, str_type_enforced);
pc_player->relaxed = create_button(pc_player, str_type_relaxed);
window_set_title(pc_player->window, "Player");
window_set_title(pc_player->window, "Weston Content Protection");
window_set_appid(pc_player->window,
"org.freedesktop.weston.weston-content-protection");
widget_set_redraw_handler(pc_player->widget, redraw_handler);
widget_set_resize_handler(pc_player->widget, resize_handler);
window_schedule_resize(pc_player->window, WIDTH, HEIGHT);

View File

@ -789,6 +789,8 @@ dnd_create(struct display *display)
dnd->window = window_create(display);
dnd->widget = window_frame_create(dnd->window, dnd);
window_set_title(dnd->window, "Wayland Drag and Drop Demo");
window_set_appid(dnd->window,
"org.freedesktop.weston.wayland-drag-and-drop-demo");
dnd->display = display;
dnd->key = 100;

View File

@ -1652,6 +1652,7 @@ main(int argc, char *argv[])
editor.selected_text = NULL;
window_set_title(editor.window, "Text Editor");
window_set_appid(editor.window, "org.freedesktop.weston.text-editor");
window_set_key_handler(editor.window, key_handler);
window_set_keyboard_focus_handler(editor.window,
keyboard_focus_handler);

View File

@ -47,6 +47,7 @@
/** window title */
static char *title = "EventDemo";
static char *appid = "org.freedesktop.weston.eventdemo";
/** window width */
static int width = 500;
@ -400,6 +401,7 @@ eventdemo_create(struct display *d)
} else {
e->widget = window_frame_create(e->window, e);
window_set_title(e->window, title);
window_set_appid(e->window, appid);
}
e->display = d;

View File

@ -187,6 +187,7 @@ int main(int argc, char *argv[])
flower.window = window_create(d);
flower.widget = window_add_widget(flower.window, &flower);
window_set_title(flower.window, "Flower");
window_set_appid(flower.window, "org.freedesktop.weston.flower");
widget_set_resize_handler(flower.widget, resize_handler);
widget_set_redraw_handler(flower.widget, redraw_handler);

View File

@ -550,6 +550,7 @@ int main(int argc, char *argv[])
window_add_widget(fullscreen.window, &fullscreen);
window_set_title(fullscreen.window, "Fullscreen");
window_set_appid(fullscreen.window, "org.freedesktop.weston.fullscreen");
widget_set_transparent(fullscreen.widget, 0);

View File

@ -413,6 +413,7 @@ gears_create(struct display *display)
gears->window = window_create(display);
gears->widget = window_frame_create(gears->window, gears);
window_set_title(gears->window, "Wayland Gears");
window_set_appid(gears->window, "org.freedesktop.weston.wayland-gears");
gears->display = display_get_egl_display(gears->d);
if (gears->display == NULL)

View File

@ -383,6 +383,7 @@ image_create(struct display *display, const char *filename,
image->window = window_create(display);
image->widget = window_frame_create(image->window, image);
window_set_title(image->window, title);
window_set_appid(image->window, "org.freedesktop.weston.wayland-image");
image->display = display;
image->image_counter = image_counter;
*image_counter += 1;

View File

@ -1021,6 +1021,8 @@ keyboard_create(struct virtual_keyboard *virtual_keyboard)
virtual_keyboard->keyboard = keyboard;
window_set_title(keyboard->window, "Virtual keyboard");
window_set_appid(keyboard->window,
"org.freedesktop.weston.virtual-keyboard");
window_set_user_data(keyboard->window, keyboard);
widget_set_redraw_handler(keyboard->widget, redraw_handler);

View File

@ -807,6 +807,8 @@ nested_create(struct display *display)
nested->window = window_create(display);
nested->widget = window_frame_create(nested->window, nested);
window_set_title(nested->window, "Wayland Nested");
window_set_appid(nested->window,
"org.freedesktop.weston.wayland-nested");
nested->display = display;
window_set_user_data(nested->window, nested);

View File

@ -392,6 +392,8 @@ resizor_create(struct display *display)
resizor->window = window_create(display);
resizor->widget = window_frame_create(resizor->window, resizor);
window_set_title(resizor->window, "Wayland Resizor");
window_set_appid(resizor->window,
"org.freedesktop.weston.wayland-resizor");
resizor->display = display;
window_set_key_handler(resizor->window, key_handler);

View File

@ -303,6 +303,7 @@ main(int argc, char *argv[])
box.window = window_create(d);
box.widget = window_add_widget(box.window, &box);
window_set_title(box.window, "Scaler Test Box");
window_set_appid(box.window, "org.freedesktop.weston.scaler-test-box");
window_set_buffer_scale(box.window, BUFFER_SCALE);
widget_set_resize_handler(box.widget, resize_handler);

View File

@ -285,6 +285,7 @@ int main(int argc, char *argv[])
smoke.window = window_create(d);
smoke.widget = window_add_widget(smoke.window, &smoke);
window_set_title(smoke.window, "smoke");
window_set_appid(smoke.window, "org.freedesktop.weston.smoke");
window_set_buffer_type(smoke.window, WINDOW_BUFFER_TYPE_SHM);
clock_gettime(CLOCK_MONOTONIC, &ts);

View File

@ -74,6 +74,7 @@ new_window(struct stacking *stacking, struct window *parent_window)
new_widget = window_frame_create(new_window, new_window);
window_set_title(new_window, "Stacking Test");
window_set_appid(new_window, "org.freedesktop.weston.stacking-test");
window_set_key_handler(new_window, key_handler);
window_set_keyboard_focus_handler(new_window, keyboard_focus_handler);
window_set_fullscreen_handler(new_window, fullscreen_handler);

View File

@ -733,6 +733,8 @@ demoapp_create(struct display *display)
app->window = window_create(app->display);
app->widget = window_frame_create(app->window, app);
window_set_title(app->window, "Wayland Sub-surface Demo");
window_set_appid(app->window,
"org.freedesktop.weston.wayland-sub-surface-demo");
window_set_key_handler(app->window, key_handler);
window_set_user_data(app->window, app);

View File

@ -2949,6 +2949,8 @@ terminal_create(struct display *display)
terminal->widget = window_frame_create(terminal->window, terminal);
terminal->title = xstrdup("Wayland Terminal");
window_set_title(terminal->window, terminal->title);
window_set_appid(terminal->window,
"org.freedesktop.weston.wayland-terminal");
widget_set_transparent(terminal->widget, 0);
init_state_machine(&terminal->state_machine);

View File

@ -557,6 +557,8 @@ calibrator_create(struct display *display, const char *match_name)
cal->widget = window_add_widget(cal->window, cal);
window_inhibit_redraw(cal->window);
window_set_title(cal->window, "Touchscreen calibrator");
window_set_appid(cal->window,
"org.freedesktop.weston.touchscreen-calibrator");
cal->display = display;
widget_set_redraw_handler(cal->widget, redraw_handler);

View File

@ -277,6 +277,8 @@ int main(int argc, char *argv[])
window_add_widget(transformed.window, &transformed);
window_set_title(transformed.window, "Transformed");
window_set_appid(transformed.window,
"org.freedesktop.weston.transformed");
widget_set_transparent(transformed.widget, 0);
widget_set_default_cursor(transformed.widget, CURSOR_BLANK);

View File

@ -230,6 +230,7 @@ struct window {
struct display *display;
struct wl_list window_output_list;
char *title;
char *appid;
struct rectangle saved_allocation;
struct rectangle min_allocation;
struct rectangle pending_allocation;
@ -1609,6 +1610,7 @@ window_destroy(struct window *window)
wl_list_remove(&window->link);
free(window->title);
free(window->appid);
free(window);
}
@ -4826,6 +4828,22 @@ window_get_title(struct window *window)
return window->title;
}
void
window_set_appid(struct window *window, const char *appid)
{
assert(!window->appid);
window->appid = strdup(appid);
if (window->xdg_toplevel)
xdg_toplevel_set_app_id(window->xdg_toplevel, window->appid);
}
const char *
window_get_appid(struct window *window)
{
return window->appid;
}
void
window_set_text_cursor_position(struct window *window, int32_t x, int32_t y)
{

View File

@ -500,9 +500,15 @@ window_set_locked_pointer_motion_handler(
void
window_set_title(struct window *window, const char *title);
void
window_set_appid(struct window *window, const char *appid);
const char *
window_get_title(struct window *window);
const char *
window_get_appid(struct window *window);
void
window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);