Skip to content

Commit c68fb44

Browse files
committed
[linux] Implement popUpWindowMenu metnod #141
1 parent c243222 commit c68fb44

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

example/linux/flutter/generated_plugins.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
77
window_manager
88
)
99

10-
list(APPEND FLUTTER_FFI_PLUGIN_LIST
11-
)
12-
1310
set(PLUGIN_BUNDLED_LIBRARIES)
1411

1512
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -18,8 +15,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
1815
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
1916
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
2017
endforeach(plugin)
21-
22-
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
23-
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
24-
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
25-
endforeach(ffi_plugin)

linux/window_manager_plugin.cc

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,19 @@ static FlMethodResponse* set_always_on_top(WindowManagerPlugin* self,
357357

358358
static FlMethodResponse* is_always_on_bottom(WindowManagerPlugin* self) {
359359
return FL_METHOD_RESPONSE(fl_method_success_response_new(
360-
fl_value_new_bool(self->_is_always_on_bottom))
361-
);
360+
fl_value_new_bool(self->_is_always_on_bottom)));
362361
}
363362

364-
static FlMethodResponse* set_always_on_bottom(
365-
WindowManagerPlugin* self,
366-
FlValue* args) {
367-
bool isAlwaysOnBottom = fl_value_get_bool(
368-
fl_value_lookup_string(args, "isAlwaysOnBottom")
369-
);
363+
static FlMethodResponse* set_always_on_bottom(WindowManagerPlugin* self,
364+
FlValue* args) {
365+
bool isAlwaysOnBottom =
366+
fl_value_get_bool(fl_value_lookup_string(args, "isAlwaysOnBottom"));
370367

371368
gtk_window_set_keep_below(get_window(self), isAlwaysOnBottom);
372369
self->_is_always_on_bottom = isAlwaysOnBottom;
373370

374-
return FL_METHOD_RESPONSE(fl_method_success_response_new(
375-
fl_value_new_bool(true)
376-
));
371+
return FL_METHOD_RESPONSE(
372+
fl_method_success_response_new(fl_value_new_bool(true)));
377373
}
378374

379375
static FlMethodResponse* get_title(WindowManagerPlugin* self) {
@@ -440,6 +436,24 @@ static FlMethodResponse* get_opacity(WindowManagerPlugin* self) {
440436
fl_method_success_response_new(fl_value_new_float(1)));
441437
}
442438

439+
static FlMethodResponse* pop_up_window_menu(WindowManagerPlugin* self) {
440+
GdkDisplay* display = gdk_display_get_default();
441+
GdkSeat* seat = gdk_display_get_default_seat(display);
442+
GdkDevice* pointer = gdk_seat_get_pointer(seat);
443+
444+
int x, y;
445+
gdk_device_get_position(pointer, NULL, &x, &y);
446+
447+
GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS);
448+
event->key.window = get_gdk_window(self);
449+
event->button.x_root = x;
450+
event->button.y_root = y;
451+
gdk_window_show_window_menu(get_gdk_window(self), event);
452+
453+
return FL_METHOD_RESPONSE(
454+
fl_method_success_response_new(fl_value_new_float(1)));
455+
}
456+
443457
static FlMethodResponse* start_dragging(WindowManagerPlugin* self) {
444458
auto window = get_window(self);
445459
auto screen = gtk_window_get_screen(window);
@@ -613,6 +627,8 @@ static void window_manager_plugin_handle_method_call(
613627
response = set_skip_taskbar(self, args);
614628
} else if (strcmp(method, "getOpacity") == 0) {
615629
response = get_opacity(self);
630+
} else if (strcmp(method, "popUpWindowMenu") == 0) {
631+
response = pop_up_window_menu(self);
616632
} else if (strcmp(method, "startDragging") == 0) {
617633
response = start_dragging(self);
618634
} else if (strcmp(method, "startResizing") == 0) {

0 commit comments

Comments
 (0)