diff --git a/README.md b/README.md index 82eda2dc..0652ca7c 100644 --- a/README.md +++ b/README.md @@ -168,13 +168,26 @@ Comming soon. We are contributing to support this now. See: https://github.com/f ### Run Fluter app -Wayland compositor (weston) must be running before running the program when you use the Wayland backend. +#### Run with Wayland backend + +Wayland compositor (weston) must be running before running the program. ```Shell $ ./flutter-client ./sample/build/linux/x64/release/bundle ``` -#### Note +#### Run with DRM backend + +You need to switch from GUI which is running X11 or Wayland to the Character User Interface (CUI). In addition, `FLUTTER_DRM_DEVICE` must be set properly. The default value is `/dev/dri/card0`. + +```Shell +$ Ctrl + Alt + F3 # Switching to CUI +$ FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-backend ./sample/build/linux/x64/release/bundle +``` + +If you want to switch back from CUI to GUI, run `Ctrl + Alt + F2` keys in a terminal. + +##### Note You need to run this program by a user who has the permission to access the input devices(/dev/input/xxx), if you use the DRM backend. Generally, it is a root user or a user who belongs to an input group. ## 5. Settings of weston.ini file (Only when you use weston desktop-shell) diff --git a/examples/flutter-drm-backend/README.md b/examples/flutter-drm-backend/README.md index d6d4145d..d40ce64d 100644 --- a/examples/flutter-drm-backend/README.md +++ b/examples/flutter-drm-backend/README.md @@ -10,3 +10,16 @@ $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-backend .. $ make ``` + +## Running Flutter app + +You need to switch from GUI which is running X11 or Wayland to the Character User Interface (CUI). In addition, `FLUTTER_DRM_DEVICE` must be set properly. The default value is `/dev/dri/card0`. + +```Shell +$ Ctrl + Alt + F3 # Switching to CUI +$ FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-backend FLUTTER_BUNDLE_PATH +``` + +Note that replace `FLUTTER_BUNDLE_PATH` with the flutter bundle path you want to use like ./sample/build/linux/x64/release/bundle. + +If you want to switch back from CUI to GUI, run `Ctrl + Alt + F2` keys in a terminal. diff --git a/src/flutter/shell/platform/linux_embedded/window/linuxes_window_drm.cc b/src/flutter/shell/platform/linux_embedded/window/linuxes_window_drm.cc index 2383a2de..a9fffb93 100644 --- a/src/flutter/shell/platform/linux_embedded/window/linuxes_window_drm.cc +++ b/src/flutter/shell/platform/linux_embedded/window/linuxes_window_drm.cc @@ -13,7 +13,8 @@ namespace flutter { -static constexpr char kDrmDeviceFilename[] = "/dev/dri/card0"; +static constexpr char kFlutterDrmDeviceEnvironmentKey[] = "FLUTTER_DRM_DEVICE"; +static constexpr char kDrmDeviceDefaultFilename[] = "/dev/dri/card0"; const libinput_interface LinuxesWindowDrm::kLibinputInterface = { .open_restricted = [](const char* path, int flags, void* user_data) -> int { @@ -29,8 +30,7 @@ const libinput_interface LinuxesWindowDrm::kLibinputInterface = { LinuxesWindowDrm::LinuxesWindowDrm(FlutterWindowMode window_mode, int32_t width, int32_t height, bool show_cursor) - : display_valid_(false), - is_pending_cursor_add_event_(false) { + : display_valid_(false), is_pending_cursor_add_event_(false) { window_mode_ = window_mode; current_width_ = width; current_height_ = height; @@ -97,7 +97,13 @@ bool LinuxesWindowDrm::DispatchEvent() { } bool LinuxesWindowDrm::CreateRenderSurface(int32_t width, int32_t height) { - native_window_ = std::make_unique(kDrmDeviceFilename); + auto device_filename = std::getenv(kFlutterDrmDeviceEnvironmentKey); + if ((!device_filename) || (device_filename[0] == '\0')) { + LINUXES_LOG(WARNING) << kFlutterDrmDeviceEnvironmentKey + << " is not set, use " << kDrmDeviceDefaultFilename; + device_filename = const_cast(kDrmDeviceDefaultFilename); + } + native_window_ = std::make_unique(device_filename); if (!native_window_->IsValid()) { LINUXES_LOG(ERROR) << "Failed to create the native window"; return false;