Skip to content

Commit

Permalink
make context menu only for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Sep 2, 2023
1 parent 686d147 commit ca5ebdb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ use floem_reactive::{with_scope, RwSignal, Scope};
use floem_renderer::Renderer;
use kurbo::{Affine, Point, Rect, Size, Vec2};

#[cfg(target_os = "linux")]
use winit::window::WindowId;
use winit::{
dpi::{LogicalPosition, LogicalSize},
event::{ElementState, Ime, MouseButton, MouseScrollDelta},
keyboard::{Key, ModifiersState},
window::CursorIcon,
};

#[cfg(target_os = "linux")]
use crate::views::{container_box, stack, Decorators};
use crate::{
action::exec_after,
animate::{AnimPropKind, AnimUpdateMsg, AnimValue, AnimatedProp, SizeUnit},
Expand Down Expand Up @@ -624,9 +628,9 @@ impl WindowHandle {
#[cfg(target_os = "windows")]
self.show_context_menu(platform_menu, pos);
#[cfg(target_os = "linux")]
self.show_context_menu(menu, platform_menu, pos);
self.context_menu
.set(Some((menu, pos.unwrap_or(self.cursor_position))));
{
self.show_context_menu(menu, platform_menu, pos);
}
}
UpdateMessage::WindowMenu { menu } => {
// let platform_menu = menu.platform_menu();
Expand Down Expand Up @@ -937,6 +941,14 @@ fn context_menu_view(
context_menu: RwSignal<Option<(Menu, Point)>>,
window_size: RwSignal<Size>,
) -> impl View {
use floem_reactive::create_effect;
use peniko::Color;

use crate::{
app::{add_app_update_event, AppUpdateEvent},
views::{empty, label, list},
};

let context_menu_items = cx.create_memo(move |_| {
context_menu.with(|menu| {
menu.as_ref().map(|menu: &(Menu, Point)| {
Expand Down

0 comments on commit ca5ebdb

Please sign in to comment.