diff --git a/src/common.rs b/src/common.rs index e75e34f..2afaf58 100644 --- a/src/common.rs +++ b/src/common.rs @@ -17,6 +17,8 @@ use cosmic_greeter_daemon::{BgSource, CosmicCompConfig, UserData}; use std::{collections::HashMap, sync::Arc}; use wayland_client::protocol::wl_output::WlOutput; +pub const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.; + #[derive(Debug, Clone, Eq, PartialEq)] pub struct ActiveLayout { pub layout: String, diff --git a/src/greeter.rs b/src/greeter.rs index fb5cc94..c88931b 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -46,7 +46,7 @@ use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use zbus::{Connection, proxy}; use crate::{ - common::{self, Common}, + common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT}, fl, }; @@ -381,7 +381,6 @@ pub struct App { impl App { fn menu(&self, id: SurfaceId) -> Element { - const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.; let window_width = self .common .window_size diff --git a/src/locker.rs b/src/locker.rs index 625496c..ac7c3d4 100644 --- a/src/locker.rs +++ b/src/locker.rs @@ -36,7 +36,7 @@ use tokio::{sync::mpsc, task}; use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use crate::{ - common::{self, Common}, + common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT}, fl, }; @@ -293,8 +293,20 @@ impl App { .on_press(message), ) }; - let dropdown_menu = |items| { - widget::container(widget::column::with_children(items)) + let dropdown_menu = |items: Vec<_>| { + let item_cnt = items.len(); + + let items = widget::column::with_children(items); + let items = if item_cnt > 7 { + Element::from( + widget::scrollable(items) + .height(Length::Fixed(DEFAULT_MENU_ITEM_HEIGHT * 7.)), + ) + } else { + Element::from(items) + }; + + widget::container(items) .padding(1) //TODO: move style to libcosmic .class(theme::Container::custom(|theme| {