diff --git a/meson.build b/meson.build index 2864d52..9c1391d 100644 --- a/meson.build +++ b/meson.build @@ -119,6 +119,21 @@ xdg_shell_h = custom_target( command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], ) +# wp_content_type_v1 Wayland protocol +wp_content_type_v1_xml = wlproto_dir / 'staging/content-type/content-type-v1.xml' +wp_content_type_v1_c = custom_target( + 'wp-content-type-v1-protocol.c', + output: 'wp-content-type-v1-protocol.c', + input: wp_content_type_v1_xml, + command: [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'] +) +wp_content_type_v1_h = custom_target( + 'wp-content-type-v1-protocol.h', + output: 'wp-content-type-v1-protocol.h', + input: wp_content_type_v1_xml, + command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'] +) + # install sample config install_data('extra/swayimgrc', install_dir: get_option('datadir') / 'swayimg') @@ -194,6 +209,8 @@ sources = [ 'src/formats/tga.c', xdg_shell_h, xdg_shell_c, + wp_content_type_v1_h, + wp_content_type_v1_c, ] if exif.found() sources += 'src/exif.c' diff --git a/src/ui.c b/src/ui.c index d18c64a..a01c0f4 100644 --- a/src/ui.c +++ b/src/ui.c @@ -8,6 +8,7 @@ #include "buildcfg.h" #include "config.h" #include "xdg-shell-protocol.h" +#include "wp-content-type-v1-protocol.h" #include #include @@ -50,6 +51,7 @@ struct ui { struct wl_keyboard* keyboard; struct wl_pointer* pointer; struct wl_surface* surface; + struct wp_content_type_manager_v1* content_type_manager; struct wl_output* output; } wl; @@ -600,6 +602,8 @@ static void on_registry_global(void* data, struct wl_registry* registry, } else if (strcmp(interface, wl_seat_interface.name) == 0) { ctx.wl.seat = wl_registry_bind(registry, name, &wl_seat_interface, 4); wl_seat_add_listener(ctx.wl.seat, &seat_listener, data); + } else if (strcmp(interface, wp_content_type_manager_v1_interface.name) == 0) { + ctx.wl.content_type_manager = wl_registry_bind(registry, name, &wp_content_type_manager_v1_interface, 1); } } @@ -679,6 +683,12 @@ bool ui_init(const char* app_id, size_t width, size_t height) xdg_toplevel_set_fullscreen(ctx.xdg.toplevel, NULL); } + if (ctx.wl.content_type_manager) { + struct wp_content_type_v1* content_type; + content_type = wp_content_type_manager_v1_get_surface_content_type(ctx.wl.content_type_manager, ctx.wl.surface); + wp_content_type_v1_set_content_type(content_type, WP_CONTENT_TYPE_V1_TYPE_PHOTO); + } + wl_surface_commit(ctx.wl.surface); app_watch(wl_display_get_fd(ctx.wl.display), on_wayland_event, NULL); @@ -735,6 +745,9 @@ void ui_destroy(void) if (ctx.wl.compositor) { wl_compositor_destroy(ctx.wl.compositor); } + if (ctx.wl.content_type_manager) { + wp_content_type_manager_v1_destroy(ctx.wl.content_type_manager); + } if (ctx.wl.registry) { wl_registry_destroy(ctx.wl.registry); }