Skip to content

Commit d3d7889

Browse files
author
Hidenori Matsubayashi
authored
Make possible to use virtual keyboards with wayland compositors other than Weston (sony#109)
1 parent 870b1ad commit d3d7889

File tree

6 files changed

+46
-966
lines changed

6 files changed

+46
-966
lines changed

cmake/build.cmake

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,24 @@ elseif(${BACKEND_TYPE} STREQUAL "X11")
3434
src/flutter/shell/platform/linux_embedded/window/linuxes_window_x11.cc
3535
src/flutter/shell/platform/linux_embedded/window/native_window_x11.cc)
3636
else()
37-
find_program(WaylandScannerExec NAMES wayland-scanner)
38-
get_filename_component(_infile $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml ABSOLUTE)
39-
set(_client_header ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland/protocol/xdg-shell-client-protocol.h)
40-
set(_code ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland/protocol/xdg-shell-protocol.c)
41-
set_source_files_properties(${_client_header} GENERATED)
42-
set_source_files_properties(${_code} GENERATED)
43-
add_custom_command(
44-
OUTPUT ${_client_header}
45-
COMMAND ${WaylandScannerExec} client-header ${_infile} ${_client_header}
46-
DEPENDS ${_infile} VERBATIM
47-
)
48-
add_custom_command(
49-
OUTPUT ${_code}
50-
COMMAND ${WaylandScannerExec} private-code ${_infile} ${_code}
51-
DEPENDS ${_infile} ${_client_header} VERBATIM
52-
)
37+
include(cmake/generate_wayland_protocols.cmake)
38+
set(_wayland_protocols_xml_dir $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/share/wayland-protocols)
39+
set(_wayland_protocols_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland/protocol)
40+
41+
generate_wayland_client_protocol(
42+
PROTOCOL_FILE ${_wayland_protocols_xml_dir}/stable/xdg-shell/xdg-shell.xml
43+
CODE_FILE ${_wayland_protocols_src_dir}/xdg-shell-protocol.c
44+
HEADER_FILE ${_wayland_protocols_src_dir}/xdg-shell-client-protocol.h)
45+
46+
generate_wayland_client_protocol(
47+
PROTOCOL_FILE ${_wayland_protocols_xml_dir}/unstable/text-input/text-input-unstable-v1.xml
48+
CODE_FILE ${_wayland_protocols_src_dir}/text-input-unstable-v1-protocol.c
49+
HEADER_FILE ${_wayland_protocols_src_dir}/text-input-unstable-v1-client-protocol.h)
5350

5451
add_definitions(-DDISPLAY_BACKEND_TYPE_WAYLAND)
5552
set(DISPLAY_BACKEND_SRC
56-
${_code}
53+
${_wayland_protocols_src_dir}/xdg-shell-protocol.c
54+
${_wayland_protocols_src_dir}/text-input-unstable-v1-protocol.c
5755
src/flutter/shell/platform/linux_embedded/window/linuxes_window_wayland.cc
5856
src/flutter/shell/platform/linux_embedded/window/native_window_wayland.cc)
5957
endif()
@@ -63,15 +61,15 @@ if((${BACKEND_TYPE} STREQUAL "WAYLAND") AND DESKTOP_SHELL)
6361
add_definitions(-DDESKTOP_SHELL)
6462
endif()
6563

66-
# wayland & weston protocols.
64+
# weston private protocols.
6765
set(WAYLAND_PROTOCOL_SRC "")
6866
if((${BACKEND_TYPE} STREQUAL "WAYLAND") AND DESKTOP_SHELL)
6967
set(WAYLAND_PROTOCOL_SRC ${WAYLAND_PROTOCOL_SRC} src/wayland/protocol/weston-desktop-shell-protocol.c)
68+
endif()
7069

71-
if(USE_VIRTUAL_KEYBOARD)
72-
add_definitions(-DUSE_VIRTUAL_KEYBOARD)
73-
set(WAYLAND_PROTOCOL_SRC ${WAYLAND_PROTOCOL_SRC} src/wayland/protocol/text-input-unstable-v1-protocol.c)
74-
endif()
70+
# Use virtual keybard(on-screen keyboard).
71+
if(USE_VIRTUAL_KEYBOARD)
72+
add_definitions(-DUSE_VIRTUAL_KEYBOARD)
7573
endif()
7674

7775
# OpenGL ES version.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
function(generate_wayland_client_protocol)
4+
cmake_parse_arguments(ARGS "" "PROTOCOL_FILE" "CODE_FILE;HEADER_FILE" ${ARGN})
5+
6+
find_program(WaylandScannerExec NAMES wayland-scanner)
7+
8+
get_filename_component(_xml_file ${ARGS_PROTOCOL_FILE} ABSOLUTE)
9+
set_source_files_properties(${ARGS_HEADER_FILE} GENERATED)
10+
set_source_files_properties(${ARGS_CODE_FILE} GENERATED)
11+
12+
add_custom_command(
13+
OUTPUT ${ARGS_HEADER_FILE}
14+
COMMAND ${WaylandScannerExec} client-header ${_xml_file} ${ARGS_HEADER_FILE}
15+
DEPENDS ${_xml_file} VERBATIM
16+
)
17+
18+
add_custom_command(
19+
OUTPUT ${ARGS_CODE_FILE}
20+
COMMAND ${WaylandScannerExec} private-code ${_xml_file} ${ARGS_CODE_FILE}
21+
DEPENDS ${_xml_file} ${ARGS_HEADER_FILE} VERBATIM
22+
)
23+
endfunction()

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Please edit `cmake/user_config.cmake` file.
152152
| ------------- | ------------- |
153153
| BACKEND_TYPE | Select WAYLAND, DRM-GBM, DRM-EGLSTREAM, or X11 as the display backend type (The default setting is WAYLAND) |
154154
| DESKTOP_SHELL | Work as Weston desktop-shell |
155-
| USE_VIRTUAL_KEYBOARD | Use Virtual Keyboard (only when using `DESKTOP_SHELL`) |
155+
| USE_VIRTUAL_KEYBOARD | Use Virtual Keyboard (Only available when you choose Wayland backend) |
156156
| USE_GLES3 | Use OpenGLES3 instead of OpenGLES2 |
157157

158158
## 4. Building Flutter app

src/flutter/shell/platform/linux_embedded/window/linuxes_window_wayland.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "flutter/shell/platform/linux_embedded/window/native_window_wayland.h"
1818
#include "flutter/shell/platform/linux_embedded/window_binding_handler.h"
1919

20+
// These header files are automatically generated by the
21+
// wayland-scanner.
2022
extern "C" {
2123
#include "wayland/protocol/text-input-unstable-v1-client-protocol.h"
2224
#include "wayland/protocol/weston-desktop-shell-client-protocol.h"

0 commit comments

Comments
 (0)