From 1093e32325f08a7649e1dec23f324d077e8cab2f Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 29 Feb 2020 15:21:42 +0000 Subject: [PATCH 01/14] sizing: Use physical dimensions of the display to determine optimal keyboard height. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parameters fudged appropriately to preserve dimensions from the original design targting Librem5: - 720×1440 results in 420px height, via max finger size - 1440×720 results in 360px height, via not exceeding half the display In absence of physical dimensions, a pixel is assumed to measure half the size as on the Librem5, and then shrunk by the current display scale factor.This gives the ability to test in nested phoc at selected scale factors like before (2x being most accurate), and keeps the right size in QEMU. --- src/outputs.rs | 56 +++++++++++++++++++++++++++++++++++++++++++++-- src/ui_manager.rs | 46 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/outputs.rs b/src/outputs.rs index 29f4e78c..39b06e92 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -129,7 +129,7 @@ pub mod c { outputs: COutputs, wl_output: WlOutput, _x: i32, _y: i32, - _phys_width: i32, _phys_height: i32, + phys_width: i32, phys_height: i32, _subpixel: i32, _make: *const c_char, _model: *const c_char, transform: i32, @@ -145,8 +145,23 @@ pub mod c { let output_state: Option<&mut OutputState> = find_output_mut(&mut collection, wl_output) .map(|o| &mut o.pending); + match output_state { - Some(state) => { state.transform = Some(transform) }, + Some(state) => { + state.transform = Some(transform); + state.phys_size = { + if (phys_width > 0) & (phys_height > 0) { + Some(SizeMM { width: phys_width, height: phys_height }) + } else { + log_print!( + logging::Level::Surprise, + "Impossible physical dimensions: {}mm × {}mm", + phys_width, phys_height, + ); + None + } + } + }, None => log_print!( logging::Level::Warning, "Got geometry on unknown output", @@ -299,6 +314,12 @@ pub struct Size { pub height: u32, } +#[derive(Clone)] +pub struct SizeMM { + pub width: i32, + pub height: i32, +} + /// wl_output mode #[derive(Clone)] struct Mode { @@ -309,6 +330,7 @@ struct Mode { #[derive(Clone)] pub struct OutputState { current_mode: Option, + phys_size: Option, transform: Option, pub scale: i32, } @@ -323,6 +345,7 @@ impl OutputState { fn uninitialized() -> OutputState { OutputState { current_mode: None, + phys_size: None, transform: None, scale: 1, } @@ -334,6 +357,35 @@ impl OutputState { OutputState { current_mode: Some(Mode { width, height } ), transform: Some(transform), + phys_size: _, + scale: _, + } => Some( + match transform { + Transform::Normal + | Transform::Rotated180 + | Transform::Flipped + | Transform::FlippedRotated180 => Size { + width: *width as u32, + height: *height as u32, + }, + _ => Size { + width: *height as u32, + height: *width as u32, + }, + } + ), + _ => None, + } + } + + /// Returns transformed dimensions + pub fn get_phys_size(&self) -> Option { + use self::c::Transform; + match self { + OutputState { + current_mode: _, + transform: Some(transform), + phys_size: Some(SizeMM { width, height }), scale: _, } => Some( match transform { diff --git a/src/ui_manager.rs b/src/ui_manager.rs index c7af6521..5f56fcf1 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -8,6 +8,8 @@ */ use std::cmp::min; + +use ::logging; use ::outputs::c::OutputHandle; mod c { @@ -57,6 +59,43 @@ pub struct Manager { } impl Manager { + /// The largest ideal heigth for the keyboard as a whole + /// judged by the ease of hitting targets within. + /// Ideally related to finger size, the crammedness of the layout, + /// distance from display, and motor skills of the user. + // FIXME: Start by making this aware of display's dpi, + // then layout number of rows. + fn get_max_target_height(&self) -> u32 { + let layout_rows = 4; // FIXME: use number from layout. + let (scale, px_size, phys_size) = (&self.output).as_ref() + .and_then(|o| o.get_state()) + .map(|os| (os.scale as u32, os.get_pixel_size(), os.get_phys_size())) + .unwrap_or((1, None, None)); + + let finger_height_px = match (px_size, phys_size) { + (Some(px_size), Some(phys_size)) => { + // Fudged to result in 420px from the original design. + // That gives about 9.5mm per finger height. + // Maybe floats are not the best choice here, + // but it gets rounded ASAP. Consider rationals. + let keyboard_fraction_of_display: f64 = 420. / 1440.; + let keyboard_mm = keyboard_fraction_of_display * 130.; + let finger_height_mm = keyboard_mm / 4.; + // TODO: Take into account target shape/area, not just height. + finger_height_mm * px_size.height as f64 / phys_size.height as f64 + }, + (_, None) => scale as f64 * 52.5, // match total 420px at scale 2 from original design + (None, Some(_)) => { + log_print!( + logging::Level::Surprise, + "Output has physical size data but no pixel info", + ); + scale as f64 * 52.5 + }, + }; + (layout_rows as f64 * finger_height_px) as u32 + } + fn get_perceptual_height(&self) -> Option { let output_info = (&self.output).as_ref() .and_then(|o| o.get_state()) @@ -71,8 +110,11 @@ impl Manager { 360 }; - // Don't exceed half the display size - min(height, px_size.height / 2) / scale + // Don't exceed half the display size. + let height = min(height, px_size.height / 2); + // Don't waste screen space by exceeding best target height. + let height = min(height, self.get_max_target_height()); + height / scale }), Some((scale, None)) => Some(360 / scale), None => None, -- GitLab From fa5c7c63d9b579f0b237735ea60068eeaecef62f Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 2 Mar 2020 08:14:01 +0000 Subject: [PATCH 02/14] ui_manager: Calculate max_height in a purer fashion --- src/ui_manager.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ui_manager.rs b/src/ui_manager.rs index 5f56fcf1..95fc7218 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -10,6 +10,7 @@ use std::cmp::min; use ::logging; +use ::outputs::OutputState; use ::outputs::c::OutputHandle; mod c { @@ -65,12 +66,10 @@ impl Manager { /// distance from display, and motor skills of the user. // FIXME: Start by making this aware of display's dpi, // then layout number of rows. - fn get_max_target_height(&self) -> u32 { + fn get_max_target_height(output: &OutputState) -> u32 { let layout_rows = 4; // FIXME: use number from layout. - let (scale, px_size, phys_size) = (&self.output).as_ref() - .and_then(|o| o.get_state()) - .map(|os| (os.scale as u32, os.get_pixel_size(), os.get_phys_size())) - .unwrap_or((1, None, None)); + let px_size = output.get_pixel_size(); + let phys_size = output.get_phys_size(); let finger_height_px = match (px_size, phys_size) { (Some(px_size), Some(phys_size)) => { @@ -84,13 +83,13 @@ impl Manager { // TODO: Take into account target shape/area, not just height. finger_height_mm * px_size.height as f64 / phys_size.height as f64 }, - (_, None) => scale as f64 * 52.5, // match total 420px at scale 2 from original design + (_, None) => output.scale as f64 * 52.5, // match total 420px at scale 2 from original design (None, Some(_)) => { log_print!( logging::Level::Surprise, "Output has physical size data but no pixel info", ); - scale as f64 * 52.5 + output.scale as f64 * 52.5 }, }; (layout_rows as f64 * finger_height_px) as u32 @@ -99,9 +98,13 @@ impl Manager { fn get_perceptual_height(&self) -> Option { let output_info = (&self.output).as_ref() .and_then(|o| o.get_state()) - .map(|os| (os.scale as u32, os.get_pixel_size())); + .map(|os| ( + os.scale as u32, + os.get_pixel_size(), + Manager::get_max_target_height(&os), + )); match output_info { - Some((scale, Some(px_size))) => Some({ + Some((scale, Some(px_size), target_height)) => Some({ let height = if (px_size.width < 720) & (px_size.width > 0) { px_size.width * 7 / 12 // to match 360×210 } else if px_size.width < 1080 { @@ -113,10 +116,10 @@ impl Manager { // Don't exceed half the display size. let height = min(height, px_size.height / 2); // Don't waste screen space by exceeding best target height. - let height = min(height, self.get_max_target_height()); + let height = min(height, target_height); height / scale }), - Some((scale, None)) => Some(360 / scale), + Some((scale, None, _)) => Some(360 / scale), None => None, } } -- GitLab From f6fc6c83dcc8faeac7f158bfd503a826dd80a530 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 2 Mar 2020 09:58:24 +0000 Subject: [PATCH 03/14] outputs: Pass output updates Introduce a callback in `outputs::Outputs` that calls on every `wl_output.done`, and a dummy consumer in `ui_manager`. This is sufficient to detect display height changes. --- src/outputs.rs | 76 ++++++++++++++++++++++++++++++++++++++--------- src/server-main.c | 2 +- src/ui_manager.h | 2 +- src/ui_manager.rs | 44 ++++++++++++++++++++++++--- src/util.rs | 5 ++++ 5 files changed, 109 insertions(+), 20 deletions(-) diff --git a/src/outputs.rs b/src/outputs.rs index 39b06e92..5dc31f9f 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -1,5 +1,10 @@ +/* Copyright (C) 2019-2020 Purism SPC + * SPDX-License-Identifier: GPL-3.0+ + */ + /*! Managing Wayland outputs */ +use std::cell::RefCell; use std::vec::Vec; use ::logging; @@ -103,7 +108,7 @@ pub mod c { ) -> i32; } - type COutputs = ::util::c::Wrapped; + pub type COutputs = ::util::c::Wrapped; /// A stable reference to an output. #[derive(Clone)] @@ -202,19 +207,27 @@ pub mod c { } extern fn outputs_handle_done( - outputs: COutputs, + outputs_raw: COutputs, wl_output: WlOutput, ) { - let outputs = outputs.clone_ref(); - let mut collection = outputs.borrow_mut(); - let output = find_output_mut(&mut collection, wl_output); - match output { - Some(output) => { output.current = output.pending.clone(); } - None => log_print!( - logging::Level::Warning, - "Got done on unknown output", - ), - }; + let outputs = outputs_raw.clone_ref(); + { + let mut collection = RefCell::borrow_mut(&outputs); + let output = find_output_mut(&mut collection, wl_output); + match output { + Some(output) => { output.current = output.pending.clone(); } + None => log_print!( + logging::Level::Warning, + "Got done on unknown output", + ), + }; + } + let collection = RefCell::borrow(&outputs); + if let Some(ref cb) = &collection.update_cb { + let mut cb = RefCell::borrow_mut(cb); + let cb = Box::as_mut(&mut cb); + cb(OutputHandle { wl_output, outputs: outputs_raw }); + } } extern fn outputs_handle_scale( @@ -239,7 +252,10 @@ pub mod c { #[no_mangle] pub extern "C" fn squeek_outputs_new() -> COutputs { - COutputs::new(Outputs { outputs: Vec::new() }) + COutputs::new(Outputs { + outputs: Vec::new(), + update_cb: None, + }) } #[no_mangle] @@ -308,7 +324,7 @@ pub mod c { } /// Generic size -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Size { pub width: u32, pub height: u32, @@ -413,6 +429,38 @@ pub struct Output { current: OutputState, } +/// The manager of all outputs. +// This is the target of several callbacks, +// so it should only be used with a stable place in memory, like `Rc`. +// It should not be instantiated externally or copied, +// or it will not receive those callbacks and be somewhat of an empty shell. +// It should be safe to use as long as the fields are not `pub`, +// and there's no `Clone`, and this module's API only ever gives out +// references wrapped in `Rc`. +// For perfectness, it would only ever give out immutable opaque references, +// but that's not practical at the moment. +// `mem::swap` could replace the value inside, +// but as long as the swap is atomic, +// that should not cause an inconsistent state. pub struct Outputs { outputs: Vec, + // The RefCell is here to let the function be called + // while holding only a read-reference to `Outputs`. + // Otherwise anything trying to get useful data from OutputHandle + // will fail to acquire reference to Outputs. + // TODO: Maybe pass only current state along with Outputs and Output hash. + // The only reason a full OutputHandle is here + // is to be able to track the right Output. + update_cb: Option>>, +} + +impl Outputs { + /// The function will get called whenever + /// any output changes or is removed or created. + /// If output handle doesn't return state, the output just went down. + /// It cannot modify anything in Outputs. + // FIXME: handle output destruction + pub fn set_update_cb(&mut self, callback: Box) { + self.update_cb = Some(RefCell::new(callback)); + } } diff --git a/src/server-main.c b/src/server-main.c index f3f5edb8..7037cb7d 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -203,7 +203,7 @@ main (int argc, char **argv) g_warning("Wayland input method interface not available"); } - instance.ui_manager = squeek_uiman_new(); + instance.ui_manager = squeek_uiman_new(instance.wayland.outputs); instance.settings_context = eekboard_context_service_new(&instance.layout_choice); diff --git a/src/ui_manager.h b/src/ui_manager.h index 57d3cc70..d61dc535 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -7,7 +7,7 @@ struct ui_manager; -struct ui_manager *squeek_uiman_new(); +struct ui_manager *squeek_uiman_new(struct squeek_outputs *outputs); void squeek_uiman_set_output(struct ui_manager *uiman, struct squeek_output_handle output); uint32_t squeek_uiman_get_perceptual_height(struct ui_manager *uiman); diff --git a/src/ui_manager.rs b/src/ui_manager.rs index 95fc7218..657674c9 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -7,20 +7,30 @@ * Coordinates this based on information collated from all possible sources. */ +use std::cell::RefCell; use std::cmp::min; +use std::rc::Rc; use ::logging; -use ::outputs::OutputState; +use ::outputs::{ Outputs, OutputState}; use ::outputs::c::OutputHandle; mod c { use super::*; + use ::outputs::c::COutputs; use ::util::c::Wrapped; #[no_mangle] pub extern "C" - fn squeek_uiman_new() -> Wrapped { - Wrapped::new(Manager { output: None }) + fn squeek_uiman_new(outputs: COutputs) -> Wrapped { + let uiman_raw = Wrapped::new(Manager { output: None }); + if !outputs.is_null() { + let uiman = uiman_raw.clone_ref(); + let outputs = outputs.clone_ref(); + let mut outputs = outputs.borrow_mut(); + register_output_man(uiman, &mut outputs); + } + uiman_raw } /// Used to size the layer surface containing all the OSK widgets. @@ -43,7 +53,7 @@ mod c { ) { let uiman = uiman.clone_ref(); let mut uiman = uiman.borrow_mut(); - uiman.output = Some(output); + uiman.set_output(output) } } @@ -123,4 +133,30 @@ impl Manager { None => None, } } + + fn set_output(&mut self, output: OutputHandle) { + self.output = Some(output); + } + + fn handle_output_change(&mut self, output: OutputHandle) { + match output.get_state() { + Some(os) => { + println!("{:?}", os.get_pixel_size()); + } + None => { + println!("gone"); + } + } + } +} + +fn register_output_man( + ui_man: Rc>, + output_man: &mut Outputs, +) { + let ui_man = ui_man.clone(); + output_man.set_update_cb(Box::new(move |output: OutputHandle| { + let mut ui_man = ui_man.borrow_mut(); + ui_man.handle_output_change(output) + })) } diff --git a/src/util.rs b/src/util.rs index 767c32ea..83213d3a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -94,6 +94,7 @@ pub mod c { } /// Extracts the reference to the data. /// It may cause problems if attempted in more than one place + // FIXME: check for null pub unsafe fn unwrap(self) -> Rc> { Rc::from_raw(self.0) } @@ -107,6 +108,10 @@ pub mod c { Rc::into_raw(used_rc); // prevent dropping the original reference rc } + + pub fn is_null(&self) -> bool { + self.0.is_null() + } } impl Clone for Wrapped { -- GitLab From 7dd2866b177c2401d249adf7560c328339dfda67 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 2 Mar 2020 14:15:53 +0000 Subject: [PATCH 04/14] ui manager: Update state and calculate new size on ouptut change --- src/outputs.rs | 22 +++++++++--- src/ui_manager.rs | 86 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 79 insertions(+), 29 deletions(-) diff --git a/src/outputs.rs b/src/outputs.rs index 5dc31f9f..c6b0b428 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -22,7 +22,7 @@ pub mod c { // Defined in C #[repr(transparent)] - #[derive(Clone, PartialEq, Copy)] + #[derive(Clone, PartialEq, Copy, Hash)] pub struct WlOutput(*const c_void); #[repr(C)] @@ -68,7 +68,7 @@ pub mod c { } /// Map to `wl_output.transform` values - #[derive(Clone)] + #[derive(Clone, PartialEq)] pub enum Transform { Normal = 0, Rotated90 = 1, @@ -126,6 +126,10 @@ pub mod c { let outputs = outputs.borrow(); find_output(&outputs, self.wl_output.clone()).map(|o| o.current.clone()) } + + pub fn get_id(&self) -> OutputId { + OutputId { wl_output: self.wl_output } + } } // Defined in Rust @@ -330,20 +334,20 @@ pub struct Size { pub height: u32, } -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct SizeMM { pub width: i32, pub height: i32, } /// wl_output mode -#[derive(Clone)] +#[derive(Clone, PartialEq)] struct Mode { width: i32, height: i32, } -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct OutputState { current_mode: Option, phys_size: Option, @@ -423,6 +427,14 @@ impl OutputState { } } +/// A comparable ID of an output +#[derive(Clone, PartialEq, Hash)] +pub struct OutputId { + // WlOutput is a unique pointer, so it will not repeat + // even if there are multiple output managers. + wl_output: c::WlOutput, +} + pub struct Output { output: c::WlOutput, pending: OutputState, diff --git a/src/ui_manager.rs b/src/ui_manager.rs index 657674c9..8489a789 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -12,9 +12,12 @@ use std::cmp::min; use std::rc::Rc; use ::logging; -use ::outputs::{ Outputs, OutputState}; +use ::outputs::{ OutputId, Outputs, OutputState}; use ::outputs::c::OutputHandle; +// Traits +use ::logging::Warn; + mod c { use super::*; use ::outputs::c::COutputs; @@ -23,7 +26,7 @@ mod c { #[no_mangle] pub extern "C" fn squeek_uiman_new(outputs: COutputs) -> Wrapped { - let uiman_raw = Wrapped::new(Manager { output: None }); + let uiman_raw = Wrapped::new(Manager::new()); if !outputs.is_null() { let uiman = uiman_raw.clone_ref(); let outputs = outputs.clone_ref(); @@ -42,7 +45,7 @@ mod c { let uiman = uiman.clone_ref(); let uiman = uiman.borrow(); // TODO: what to do when there's no output? - uiman.get_perceptual_height().unwrap_or(0) + uiman.state.get_perceptual_height().unwrap_or(0) } #[no_mangle] @@ -58,18 +61,14 @@ mod c { } /// Stores current state of all things influencing what the UI should look like. -pub struct Manager { - /// Shared output handle, current state updated whenever it's needed. - // TODO: Stop assuming that the output never changes. - // (There's no way for the output manager to update the ui manager.) - // FIXME: Turn into an OutputState and apply relevant connections elsewhere. - // Otherwise testability and predictablity is low. - output: Option, +#[derive(Clone, PartialEq)] +pub struct ManagerState { + current_output: Option<(OutputId, OutputState)>, //// Pixel size of the surface. Needs explicit updating. //surface_size: Option, } -impl Manager { +impl ManagerState { /// The largest ideal heigth for the keyboard as a whole /// judged by the ease of hitting targets within. /// Ideally related to finger size, the crammedness of the layout, @@ -106,12 +105,11 @@ impl Manager { } fn get_perceptual_height(&self) -> Option { - let output_info = (&self.output).as_ref() - .and_then(|o| o.get_state()) - .map(|os| ( + let output_info = (&self.current_output).as_ref() + .map(|(_id, os)| ( os.scale as u32, os.get_pixel_size(), - Manager::get_max_target_height(&os), + ManagerState::get_max_target_height(&os), )); match output_info { Some((scale, Some(px_size), target_height)) => Some({ @@ -133,20 +131,60 @@ impl Manager { None => None, } } - +} + +pub struct Manager { + state: ManagerState, +} + +impl Manager { + fn new() -> Manager { + Manager { + state: ManagerState { current_output: None }, + } + } fn set_output(&mut self, output: OutputHandle) { - self.output = Some(output); + let output_state = output.get_state() + .or_warn( + &mut logging::Print, + logging::Problem::Bug, + // This is really bad. It only happens when the layer surface + // is placed, and it happens once. + // The layer surface is on an output that can't be tracked. + "Tried to set output that's not known to exist. Ignoring.", + ); + self.state.current_output = output_state.map( + |state| (output.get_id(), state) + ); + // TODO: At the time of writing, this function is only used once, + // before the layer surface is initialized. + // Therefore it doesn't update anything. Maybe it should in the future, + // if it sees more use. } fn handle_output_change(&mut self, output: OutputHandle) { - match output.get_state() { - Some(os) => { - println!("{:?}", os.get_pixel_size()); - } - None => { - println!("gone"); + let (id, output_state) = match &self.state.current_output { + Some((id, state)) => { + if *id != output.get_id() { return } // Not the current output. + else { (id, state) } + }, + None => return, // Keyboard isn't on any output. + }; + if let Some(new_output_state) = output.get_state() { + if new_output_state != *output_state { + let new_state = ManagerState { + current_output: Some((id.clone(), new_output_state)), + ..self.state.clone() + }; + let new_height = new_state.get_perceptual_height(); + if new_height != self.state.get_perceptual_height() { + println!("New height: {:?}", new_height); + //update_layer_surface_height(new_height); + // TODO: here hard-size the keyboard and suggestion box too. + } + self.state = new_state; } - } + }; } } -- GitLab From b409df15bbc4190760bfa51fee140ae5e040c45f Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 2 Mar 2020 14:50:45 +0000 Subject: [PATCH 05/14] ui: Update UI state based on output events --- src/meson.build | 1 + src/server-context-service.c | 1 + src/ui_manager.c | 8 ++++++ src/ui_manager.h | 3 +- src/ui_manager.rs | 53 ++++++++++++++++++++++++++++++++---- 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 src/ui_manager.c diff --git a/src/meson.build b/src/meson.build index 4537164b..e2744ccc 100644 --- a/src/meson.build +++ b/src/meson.build @@ -15,6 +15,7 @@ sources = [ 'dbus.c', 'imservice.c', 'server-context-service.c', + 'ui_manager.c', 'wayland.c', '../eek/eek.c', '../eek/eek-element.c', diff --git a/src/server-context-service.c b/src/server-context-service.c index 46811ce4..d8f6b365 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -139,6 +139,7 @@ make_window (ServerContextService *context) NULL ); + squeek_uiman_set_surface(context->manager, context->window); g_object_connect (context->window, "signal::destroy", G_CALLBACK(on_destroy), context, "signal::map", G_CALLBACK(on_notify_map), context, diff --git a/src/ui_manager.c b/src/ui_manager.c new file mode 100644 index 00000000..daa8bdf1 --- /dev/null +++ b/src/ui_manager.c @@ -0,0 +1,8 @@ +#include "eek/layersurface.h" + +void squeek_manager_set_surface_height(PhoshLayerSurface *surface, uint32_t desired_height) { + phosh_layer_surface_set_size(surface, 0, + (gint)desired_height); + phosh_layer_surface_set_exclusive_zone(surface, (gint)desired_height); + phosh_layer_surface_wl_surface_commit (surface); +} diff --git a/src/ui_manager.h b/src/ui_manager.h index d61dc535..9ef14524 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -2,13 +2,14 @@ #define UI_MANAGER__ #include - +#include "eek/layersurface.h" #include "outputs.h" struct ui_manager; struct ui_manager *squeek_uiman_new(struct squeek_outputs *outputs); void squeek_uiman_set_output(struct ui_manager *uiman, struct squeek_output_handle output); +void squeek_uiman_set_surface(struct ui_manager *uiman, PhoshLayerSurface *surface); uint32_t squeek_uiman_get_perceptual_height(struct ui_manager *uiman); #endif diff --git a/src/ui_manager.rs b/src/ui_manager.rs index 8489a789..ebcd1011 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -20,9 +20,24 @@ use ::logging::Warn; mod c { use super::*; + use std::os::raw::c_void; use ::outputs::c::COutputs; use ::util::c::Wrapped; + #[derive(Clone, Copy)] + #[repr(C)] + pub struct PhoshLayerSurface(*const c_void); + + extern "C" { + // Rustc wrongly assumes + // that COutputs allows C direct access to the underlying RefCell. + #[allow(improper_ctypes)] + pub fn squeek_manager_set_surface_height( + surface: PhoshLayerSurface, + height: u32, + ); + } + #[no_mangle] pub extern "C" fn squeek_uiman_new(outputs: COutputs) -> Wrapped { @@ -58,6 +73,18 @@ mod c { let mut uiman = uiman.borrow_mut(); uiman.set_output(output) } + + #[no_mangle] + pub extern "C" + fn squeek_uiman_set_surface( + uiman: Wrapped, + surface: PhoshLayerSurface, + ) { + let uiman = uiman.clone_ref(); + let mut uiman = uiman.borrow_mut(); + // Surface is not state, so doesn't need to propagate updates. + uiman.surface = Some(surface); + } } /// Stores current state of all things influencing what the UI should look like. @@ -135,12 +162,14 @@ impl ManagerState { pub struct Manager { state: ManagerState, + surface: Option, } impl Manager { fn new() -> Manager { Manager { - state: ManagerState { current_output: None }, + state: ManagerState { current_output: None, }, + surface: None, } } fn set_output(&mut self, output: OutputHandle) { @@ -176,11 +205,23 @@ impl Manager { current_output: Some((id.clone(), new_output_state)), ..self.state.clone() }; - let new_height = new_state.get_perceptual_height(); - if new_height != self.state.get_perceptual_height() { - println!("New height: {:?}", new_height); - //update_layer_surface_height(new_height); - // TODO: here hard-size the keyboard and suggestion box too. + if let Some(surface) = &self.surface { + let new_height = new_state.get_perceptual_height(); + if new_height != self.state.get_perceptual_height() { + // TODO: here hard-size the keyboard and suggestion box too. + match new_height { + Some(new_height) => unsafe { + c::squeek_manager_set_surface_height( + *surface, + new_height, + ) + } + None => log_print!( + logging::Level::Bug, + "Can't calculate new size", + ), + } + } } self.state = new_state; } -- GitLab From b19938da010816b8f9ac21f2decce26484cec16f Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 2 Mar 2020 15:52:35 +0000 Subject: [PATCH 06/14] ui: Fix old Rust borrowing --- src/ui_manager.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui_manager.rs b/src/ui_manager.rs index ebcd1011..e35c323b 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -195,12 +195,12 @@ impl Manager { let (id, output_state) = match &self.state.current_output { Some((id, state)) => { if *id != output.get_id() { return } // Not the current output. - else { (id, state) } + else { (id.clone(), state.clone()) } }, None => return, // Keyboard isn't on any output. }; if let Some(new_output_state) = output.get_state() { - if new_output_state != *output_state { + if new_output_state != output_state { let new_state = ManagerState { current_output: Some((id.clone(), new_output_state)), ..self.state.clone() -- GitLab From e504154571abd126a8ef23cf0adee9a54bad2907 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 10:25:08 +0000 Subject: [PATCH 07/14] managers: Turn gsettings management into a separate piece. --- eekboard/eekboard-context-service.c | 127 +++++++++++++++------------- eekboard/eekboard-context-service.h | 12 ++- src/server-main.c | 5 +- 3 files changed, 81 insertions(+), 63 deletions(-) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index a97f1231..3335eed7 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -47,7 +47,6 @@ static guint signals[LAST_SIGNAL] = { 0, }; struct _EekboardContextServicePrivate { LevelKeyboard *keyboard; // currently used keyboard - GSettings *settings; // Owned reference // Maybe TODO: it's used only for fetching layout type. // Maybe let UI push the type to this structure? @@ -160,34 +159,9 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque } } -static void eekboard_context_service_update_settings_layout(EekboardContextService *context) { - g_autofree gchar *keyboard_layout = NULL; - g_autofree gchar *keyboard_type = NULL; - settings_get_layout(context->priv->settings, - &keyboard_type, &keyboard_layout); - - if (g_strcmp0(context->layout->layout_name, keyboard_layout) != 0 || context->layout->overlay_name) { - g_free(context->layout->overlay_name); - context->layout->overlay_name = NULL; - if (keyboard_layout) { - g_free(context->layout->layout_name); - context->layout->layout_name = g_strdup(keyboard_layout); - } - // This must actually update the UI. - eekboard_context_service_use_layout(context, context->layout); - } -} - -static gboolean -settings_handle_layout_changed(GSettings *s, - gpointer keys, gint n_keys, - gpointer user_data) { - (void)s; - (void)keys; - (void)n_keys; - EekboardContextService *context = user_data; - eekboard_context_service_update_settings_layout(context); - return TRUE; +static void +eekboard_context_service_init (EekboardContextService *self) { + self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self); } static void @@ -237,36 +211,6 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) pspec); } -static void -eekboard_context_service_init (EekboardContextService *self) -{ - self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self); - const char *schema_name = "org.gnome.desktop.input-sources"; - GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default(); - if (ssrc) { - GSettingsSchema *schema = g_settings_schema_source_lookup(ssrc, - schema_name, - TRUE); - if (schema) { - // Not referencing the found schema directly, - // because it's not clear how... - self->priv->settings = g_settings_new (schema_name); - gulong conn_id = g_signal_connect(self->priv->settings, "change-event", - G_CALLBACK(settings_handle_layout_changed), - self); - if (conn_id == 0) { - g_warning ("Could not connect to gsettings updates, " - "automatic layout changing unavailable"); - } - } else { - g_warning("Gsettings schema %s is not installed on the system. " - "Layout switching unavailable", schema_name); - } - } else { - g_warning("No gsettings schemas installed. Layout switching unavailable."); - } -} - /** * eekboard_context_service_destroy: * @context: an #EekboardContextService @@ -321,7 +265,6 @@ EekboardContextService *eekboard_context_service_new(struct squeek_layout_state { EekboardContextService *context = g_object_new (EEKBOARD_TYPE_CONTEXT_SERVICE, NULL); context->layout = state; - eekboard_context_service_update_settings_layout(context); eekboard_context_service_use_layout(context, context->layout); return context; } @@ -336,3 +279,67 @@ void eekboard_context_service_set_submission(EekboardContextService *context, st void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) { context->priv->ui = ui; } + +static void settings_update_layout(struct gsettings_tracker *self) { + // The layout in the param must be the same layout as held by context. + g_autofree gchar *keyboard_layout = NULL; + g_autofree gchar *keyboard_type = NULL; + settings_get_layout(self->gsettings, + &keyboard_type, &keyboard_layout); + + if (g_strcmp0(self->layout->layout_name, keyboard_layout) != 0 || self->layout->overlay_name) { + g_free(self->layout->overlay_name); + self->layout->overlay_name = NULL; + if (keyboard_layout) { + g_free(self->layout->layout_name); + self->layout->layout_name = g_strdup(keyboard_layout); + } + // This must actually update the UI. + eekboard_context_service_use_layout(self->context, self->layout); + } +} + +static gboolean +handle_layout_changed(GSettings *s, + gpointer keys, gint n_keys, + gpointer user_data) { + (void)s; + (void)keys; + (void)n_keys; + struct gsettings_tracker *self = user_data; + settings_update_layout(self); + return TRUE; +} + +void eek_gsettings_tracker_init(struct gsettings_tracker *tracker, EekboardContextService *context, struct squeek_layout_state *layout) +{ + tracker->layout = layout; + tracker->context = context; + + const char *schema_name = "org.gnome.desktop.input-sources"; + GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default(); + if (ssrc) { + GSettingsSchema *schema = g_settings_schema_source_lookup(ssrc, + schema_name, + TRUE); + if (schema) { + // Not referencing the found schema directly, + // because it's not clear how... + tracker->gsettings = g_settings_new (schema_name); + gulong conn_id = g_signal_connect(tracker->gsettings, "change-event", + G_CALLBACK(handle_layout_changed), + tracker); + if (conn_id == 0) { + g_warning ("Could not connect to gsettings updates, " + "automatic layout changing unavailable"); + } + } else { + g_warning("Gsettings schema %s is not installed on the system. " + "Layout switching unavailable", schema_name); + } + } else { + g_warning("No gsettings schemas installed. Layout switching unavailable."); + } + + settings_update_layout(tracker); +} diff --git a/eekboard/eekboard-context-service.h b/eekboard/eekboard-context-service.h index 8547e3e7..06ea108e 100644 --- a/eekboard/eekboard-context-service.h +++ b/eekboard/eekboard-context-service.h @@ -47,7 +47,7 @@ typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate; /** * EekboardContextService: * - * Handles layout state, gsettings, and virtual-keyboard. + * Handles layout state, and virtual-keyboard. * * TODO: Restrict to managing keyboard layouts, and maybe button repeats, * and the virtual keyboard protocol. @@ -82,6 +82,16 @@ struct _EekboardContextServiceClass { GType eekboard_context_service_get_type (void) G_GNUC_CONST; + +/// Handles gsettings os-level keyboard layout switches. +struct gsettings_tracker { + GSettings *gsettings; // Owned reference + EekboardContextService *context; // Unowned + struct squeek_layout_state *layout; // Unowned +}; + +void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, EekboardContextService *context, struct squeek_layout_state *layout); + EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state); void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission); void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui); diff --git a/src/server-main.c b/src/server-main.c index 7037cb7d..31825d97 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -42,11 +42,12 @@ struct squeekboard { struct squeek_wayland wayland; // Just hooks. DBusHandler *dbus_handler; // Controls visibility of the OSK. - EekboardContextService *settings_context; // Gsettings hooks. + EekboardContextService *settings_context; // Currently used layout & keyboard. ServerContextService *ui_context; // mess, includes the entire UI struct submission *submission; // Wayland text input handling. struct squeek_layout_state layout_choice; // Currently wanted layout. struct ui_manager *ui_manager; // UI shape tracker/chooser. TODO: merge with layuot choice + struct gsettings_tracker gsettings_tracker; // Gsettings handling. }; @@ -206,7 +207,7 @@ main (int argc, char **argv) instance.ui_manager = squeek_uiman_new(instance.wayland.outputs); instance.settings_context = eekboard_context_service_new(&instance.layout_choice); - + eek_gsettings_tracker_init(&instance.gsettings_tracker, instance.settings_context, &instance.layout_choice); // set up dbus // TODO: make dbus errors non-always-fatal -- GitLab From 16d7fcae7c3b958e625d5b537002faf648d546f6 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 11:16:49 +0000 Subject: [PATCH 08/14] eekboard context: Remove unused struct --- eekboard/eekboard-context-service.c | 7 ------- src/server-main.c | 1 - 2 files changed, 8 deletions(-) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index 3335eed7..a1339930 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -48,9 +48,6 @@ static guint signals[LAST_SIGNAL] = { 0, }; struct _EekboardContextServicePrivate { LevelKeyboard *keyboard; // currently used keyboard - // Maybe TODO: it's used only for fetching layout type. - // Maybe let UI push the type to this structure? - ServerContextService *ui; // unowned reference /// Needed for keymap changes after keyboard updates struct submission *submission; // unowned }; @@ -276,10 +273,6 @@ void eekboard_context_service_set_submission(EekboardContextService *context, st } } -void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) { - context->priv->ui = ui; -} - static void settings_update_layout(struct gsettings_tracker *self) { // The layout in the param must be the same layout as held by context. g_autofree gchar *keyboard_layout = NULL; diff --git a/src/server-main.c b/src/server-main.c index 31825d97..0397f727 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -300,7 +300,6 @@ main (int argc, char **argv) if (instance.dbus_handler) { dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context); } - eekboard_context_service_set_ui(instance.settings_context, instance.ui_context); session_register(); -- GitLab From 710509a67127b164d175f862e451472aa269ed50 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 11:26:53 +0000 Subject: [PATCH 09/14] eekboard context: Remove some unused code --- eekboard/eekboard-context-service.c | 32 +---------------------------- eekboard/eekboard-context-service.h | 15 -------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index a1339930..29056690 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -35,13 +35,6 @@ enum { PROP_LAST }; -enum { - DESTROYED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - #define EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServicePrivate)) @@ -177,22 +170,6 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) gobject_class->set_property = eekboard_context_service_set_property; gobject_class->get_property = eekboard_context_service_get_property; gobject_class->dispose = eekboard_context_service_dispose; - /** - * EekboardContextService::destroyed: - * @context: an #EekboardContextService - * - * Emitted when @context is destroyed. - */ - signals[DESTROYED] = - g_signal_new (I_("destroyed"), - G_TYPE_FROM_CLASS(gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(EekboardContextServiceClass, destroyed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); /** * EekboardContextService:keyboard: @@ -208,17 +185,10 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) pspec); } -/** - * eekboard_context_service_destroy: - * @context: an #EekboardContextService - * - * Destroy @context. - */ void eekboard_context_service_destroy (EekboardContextService *context) { - g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_signal_emit (context, signals[DESTROYED], 0); + (void)context; } /** diff --git a/eekboard/eekboard-context-service.h b/eekboard/eekboard-context-service.h index 06ea108e..aeae2bf5 100644 --- a/eekboard/eekboard-context-service.h +++ b/eekboard/eekboard-context-service.h @@ -51,9 +51,6 @@ typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate; * * TODO: Restrict to managing keyboard layouts, and maybe button repeats, * and the virtual keyboard protocol. - * - * The #EekboardContextService structure contains only private data - * and should only be accessed using the provided API. */ struct _EekboardContextService { GObject parent; @@ -61,20 +58,10 @@ struct _EekboardContextService { struct squeek_layout_state *layout; // Unowned }; -/** - * EekboardContextServiceClass: - * @create_keyboard: virtual function for create a keyboard from string - * @enabled: class handler for #EekboardContextService::enabled signal - * @disabled: class handler for #EekboardContextService::disabled signal - */ struct _EekboardContextServiceClass { /*< private >*/ GObjectClass parent_class; - /*< public >*/ - /* signals */ - void (*destroyed) (EekboardContextService *self); - /*< private >*/ /* padding */ gpointer pdummy[24]; @@ -94,8 +81,6 @@ void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, EekboardConte EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state); void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission); -void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui); -void eekboard_context_service_destroy (EekboardContextService *context); LevelKeyboard *eekboard_context_service_get_keyboard(EekboardContextService *context); void eekboard_context_service_set_keymap(EekboardContextService *context, -- GitLab From 6abaa36db85adc4dfe5f67da4962667811c7b4ff Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 11:44:08 +0000 Subject: [PATCH 10/14] eekboard_context: Rename --- src/server-main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server-main.c b/src/server-main.c index 0397f727..9e98fb14 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -42,7 +42,7 @@ struct squeekboard { struct squeek_wayland wayland; // Just hooks. DBusHandler *dbus_handler; // Controls visibility of the OSK. - EekboardContextService *settings_context; // Currently used layout & keyboard. + EekboardContextService *layout_holder; // Currently used layout & keyboard. ServerContextService *ui_context; // mess, includes the entire UI struct submission *submission; // Wayland text input handling. struct squeek_layout_state layout_choice; // Currently wanted layout. @@ -206,8 +206,8 @@ main (int argc, char **argv) instance.ui_manager = squeek_uiman_new(instance.wayland.outputs); - instance.settings_context = eekboard_context_service_new(&instance.layout_choice); - eek_gsettings_tracker_init(&instance.gsettings_tracker, instance.settings_context, &instance.layout_choice); + instance.layout_holder = eekboard_context_service_new(&instance.layout_choice); + eek_gsettings_tracker_init(&instance.gsettings_tracker, instance.layout_holder, &instance.layout_choice); // set up dbus // TODO: make dbus errors non-always-fatal @@ -280,12 +280,12 @@ main (int argc, char **argv) instance.submission = get_submission(instance.wayland.input_method_manager, instance.wayland.virtual_keyboard_manager, instance.wayland.seat, - instance.settings_context); + instance.layout_holder); - eekboard_context_service_set_submission(instance.settings_context, instance.submission); + eekboard_context_service_set_submission(instance.layout_holder, instance.submission); ServerContextService *ui_context = server_context_service_new( - instance.settings_context, + instance.layout_holder, instance.submission, &instance.layout_choice, instance.ui_manager); -- GitLab From 4007754de9ec8fdae0b591d4886ba9b85e1e8df2 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 11:53:31 +0000 Subject: [PATCH 11/14] eekboard_context: Rename to LayoutHolder --- eek/eek-gtk-keyboard.c | 6 ++--- eek/eek-gtk-keyboard.h | 2 +- eek/eek-types.h | 2 +- eekboard/eekboard-context-service.c | 38 ++++++++++++++--------------- eekboard/eekboard-context-service.h | 38 ++++++++++++----------------- src/imservice.c | 2 +- src/layout.h | 4 +-- src/server-context-service.c | 4 +-- src/server-context-service.h | 2 +- src/server-main.c | 2 +- src/submission.h | 4 +-- 11 files changed, 49 insertions(+), 55 deletions(-) diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index 4d07b7c0..7c7c1fe6 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -45,7 +45,7 @@ typedef struct _EekGtkKeyboardPrivate { EekRenderer *renderer; // owned, nullable - EekboardContextService *eekboard_context; // unowned reference + LayoutHolder *eekboard_context; // unowned reference struct submission *submission; // unowned reference struct squeek_layout_state *layout; // unowned @@ -343,7 +343,7 @@ on_notify_keyboard (GObject *object, EekGtkKeyboard *self) { (void)spec; EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (self); - priv->keyboard = eekboard_context_service_get_keyboard(EEKBOARD_CONTEXT_SERVICE(object)); + priv->keyboard = eekboard_context_service_get_keyboard(LAYOUT_HOLDER(object)); if (priv->renderer) { eek_renderer_free(priv->renderer); } @@ -356,7 +356,7 @@ on_notify_keyboard (GObject *object, * Returns: a #GtkWidget */ GtkWidget * -eek_gtk_keyboard_new (EekboardContextService *eekservice, +eek_gtk_keyboard_new (LayoutHolder *eekservice, struct submission *submission, struct squeek_layout_state *layout) { diff --git a/eek/eek-gtk-keyboard.h b/eek/eek-gtk-keyboard.h index 7570ac05..eeca80b9 100644 --- a/eek/eek-gtk-keyboard.h +++ b/eek/eek-gtk-keyboard.h @@ -48,7 +48,7 @@ struct _EekGtkKeyboardClass }; GType eek_gtk_keyboard_get_type (void) G_GNUC_CONST; -GtkWidget *eek_gtk_keyboard_new (EekboardContextService *eekservice, struct submission *submission, struct squeek_layout_state *layout); +GtkWidget *eek_gtk_keyboard_new (LayoutHolder *eekservice, struct submission *submission, struct squeek_layout_state *layout); G_END_DECLS #endif /* EEK_GTK_KEYBOARD_H */ diff --git a/eek/eek-types.h b/eek/eek-types.h index 5d993191..7330181e 100644 --- a/eek/eek-types.h +++ b/eek/eek-types.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS typedef struct _EekBounds EekBounds; -typedef struct _EekboardContextService EekboardContextService; +typedef struct _LayoutHolder LayoutHolder; typedef struct _ServerContextService ServerContextService; typedef struct _LevelKeyboard LevelKeyboard; diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index 29056690..66c863a1 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -35,17 +35,17 @@ enum { PROP_LAST }; -#define EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServicePrivate)) +#define LAYOUT_HOLDER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, LayoutHolderPrivate)) -struct _EekboardContextServicePrivate { +struct _LayoutHolderPrivate { LevelKeyboard *keyboard; // currently used keyboard /// Needed for keymap changes after keyboard updates struct submission *submission; // unowned }; -G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (LayoutHolder, layout_holder, G_TYPE_OBJECT); static void eekboard_context_service_set_property (GObject *object, @@ -67,7 +67,7 @@ eekboard_context_service_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object); + LayoutHolder *context = LAYOUT_HOLDER(object); switch (prop_id) { case PROP_KEYBOARD: @@ -82,7 +82,7 @@ eekboard_context_service_get_property (GObject *object, static void eekboard_context_service_dispose (GObject *object) { - G_OBJECT_CLASS (eekboard_context_service_parent_class)-> + G_OBJECT_CLASS (layout_holder_parent_class)-> dispose (object); } @@ -105,7 +105,7 @@ settings_get_layout(GSettings *settings, char **type, char **layout) } void -eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *state) { +eekboard_context_service_use_layout(LayoutHolder *context, struct squeek_layout_state *state) { gchar *layout_name = state->overlay_name; if (layout_name == NULL) { @@ -150,8 +150,8 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque } static void -eekboard_context_service_init (EekboardContextService *self) { - self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self); +layout_holder_init (LayoutHolder *self) { + self->priv = LAYOUT_HOLDER_GET_PRIVATE(self); } static void @@ -161,7 +161,7 @@ eekboard_context_service_constructed (GObject *object) } static void -eekboard_context_service_class_init (EekboardContextServiceClass *klass) +layout_holder_class_init (LayoutHolderClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GParamSpec *pspec; @@ -186,7 +186,7 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) } void -eekboard_context_service_destroy (EekboardContextService *context) +eekboard_context_service_destroy (LayoutHolder *context) { (void)context; } @@ -199,12 +199,12 @@ eekboard_context_service_destroy (EekboardContextService *context) * Returns: (transfer none): an #EekKeyboard */ LevelKeyboard * -eekboard_context_service_get_keyboard (EekboardContextService *context) +eekboard_context_service_get_keyboard (LayoutHolder *context) { return context->priv->keyboard; } -void eekboard_context_service_set_hint_purpose(EekboardContextService *context, +void eekboard_context_service_set_hint_purpose(LayoutHolder *context, uint32_t hint, uint32_t purpose) { if (context->layout->hint != hint || context->layout->purpose != purpose) { @@ -215,7 +215,7 @@ void eekboard_context_service_set_hint_purpose(EekboardContextService *context, } void -eekboard_context_service_set_overlay(EekboardContextService *context, const char* name) { +eekboard_context_service_set_overlay(LayoutHolder *context, const char* name) { if (g_strcmp0(context->layout->overlay_name, name)) { g_free(context->layout->overlay_name); context->layout->overlay_name = g_strdup(name); @@ -224,19 +224,19 @@ eekboard_context_service_set_overlay(EekboardContextService *context, const char } const char* -eekboard_context_service_get_overlay(EekboardContextService *context) { +eekboard_context_service_get_overlay(LayoutHolder *context) { return context->layout->overlay_name; } -EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state) +LayoutHolder *eekboard_context_service_new(struct squeek_layout_state *state) { - EekboardContextService *context = g_object_new (EEKBOARD_TYPE_CONTEXT_SERVICE, NULL); + LayoutHolder *context = g_object_new (EEKBOARD_TYPE_LAYOUT_HOLDER, NULL); context->layout = state; eekboard_context_service_use_layout(context, context->layout); return context; } -void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) { +void eekboard_context_service_set_submission(LayoutHolder *context, struct submission *submission) { context->priv->submission = submission; if (context->priv->submission) { submission_set_keyboard(context->priv->submission, context->priv->keyboard); @@ -274,7 +274,7 @@ handle_layout_changed(GSettings *s, return TRUE; } -void eek_gsettings_tracker_init(struct gsettings_tracker *tracker, EekboardContextService *context, struct squeek_layout_state *layout) +void eek_gsettings_tracker_init(struct gsettings_tracker *tracker, LayoutHolder *context, struct squeek_layout_state *layout) { tracker->layout = layout; tracker->context = context; diff --git a/eekboard/eekboard-context-service.h b/eekboard/eekboard-context-service.h index aeae2bf5..de51fba8 100644 --- a/eekboard/eekboard-context-service.h +++ b/eekboard/eekboard-context-service.h @@ -30,35 +30,30 @@ G_BEGIN_DECLS -#define EEKBOARD_CONTEXT_SERVICE_PATH "/org/fedorahosted/Eekboard/Context_%d" -#define EEKBOARD_CONTEXT_SERVICE_INTERFACE "org.fedorahosted.Eekboard.Context" - -#define EEKBOARD_TYPE_CONTEXT_SERVICE (eekboard_context_service_get_type()) -#define EEKBOARD_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextService)) +#define EEKBOARD_TYPE_LAYOUT_HOLDER (layout_holder_get_type()) +#define LAYOUT_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, LayoutHolder)) #define EEKBOARD_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass)) #define EEKBOARD_IS_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE)) #define EEKBOARD_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE)) #define EEKBOARD_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass)) -typedef struct _EekboardContextServiceClass EekboardContextServiceClass; -typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate; +typedef struct _LayoutHolderClass LayoutHolderClass; +typedef struct _LayoutHolderPrivate LayoutHolderPrivate; /** - * EekboardContextService: - * * Handles layout state, and virtual-keyboard. * * TODO: Restrict to managing keyboard layouts, and maybe button repeats, * and the virtual keyboard protocol. */ -struct _EekboardContextService { +struct _LayoutHolder { GObject parent; - EekboardContextServicePrivate *priv; + LayoutHolderPrivate *priv; struct squeek_layout_state *layout; // Unowned }; -struct _EekboardContextServiceClass { +struct _LayoutHolderClass { /*< private >*/ GObjectClass parent_class; @@ -67,29 +62,28 @@ struct _EekboardContextServiceClass { gpointer pdummy[24]; }; -GType eekboard_context_service_get_type - (void) G_GNUC_CONST; +GType layout_holder_get_type(void) G_GNUC_CONST; /// Handles gsettings os-level keyboard layout switches. struct gsettings_tracker { GSettings *gsettings; // Owned reference - EekboardContextService *context; // Unowned + LayoutHolder *context; // Unowned struct squeek_layout_state *layout; // Unowned }; -void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, EekboardContextService *context, struct squeek_layout_state *layout); +void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, LayoutHolder *context, struct squeek_layout_state *layout); -EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state); -void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission); -LevelKeyboard *eekboard_context_service_get_keyboard(EekboardContextService *context); +LayoutHolder *eekboard_context_service_new(struct squeek_layout_state *state); +void eekboard_context_service_set_submission(LayoutHolder *context, struct submission *submission); +LevelKeyboard *eekboard_context_service_get_keyboard(LayoutHolder *context); -void eekboard_context_service_set_keymap(EekboardContextService *context, +void eekboard_context_service_set_keymap(LayoutHolder *context, const LevelKeyboard *keyboard); -void eekboard_context_service_set_hint_purpose(EekboardContextService *context, +void eekboard_context_service_set_hint_purpose(LayoutHolder *context, uint32_t hint, uint32_t purpose); void -eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *layout); +eekboard_context_service_use_layout(LayoutHolder *context, struct squeek_layout_state *layout); G_END_DECLS #endif /* EEKBOARD_CONTEXT_SERVICE_H */ diff --git a/src/imservice.c b/src/imservice.c index b6b04784..9412bddc 100644 --- a/src/imservice.c +++ b/src/imservice.c @@ -26,7 +26,7 @@ static const struct zwp_input_method_v2_listener input_method_listener = { struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager, struct zwp_virtual_keyboard_manager_v1 *vkmanager, struct wl_seat *seat, - EekboardContextService *state) { + LayoutHolder *state) { struct zwp_input_method_v2 *im = NULL; if (immanager) { im = zwp_input_method_manager_v2_get_input_method(immanager, seat); diff --git a/src/layout.h b/src/layout.h index 756f90d5..c4d50592 100644 --- a/src/layout.h +++ b/src/layout.h @@ -47,7 +47,7 @@ void squeek_layout_release(struct squeek_layout *layout, struct submission *submission, struct transformation widget_to_layout, uint32_t timestamp, - EekboardContextService *manager, + LayoutHolder *manager, EekGtkKeyboard *ui_keyboard); void squeek_layout_release_all_only(struct squeek_layout *layout, struct submission *submission, @@ -61,7 +61,7 @@ void squeek_layout_drag(struct squeek_layout *layout, struct submission *submission, double x_widget, double y_widget, struct transformation widget_to_layout, - uint32_t timestamp, EekboardContextService *manager, + uint32_t timestamp, LayoutHolder *manager, EekGtkKeyboard *ui_keyboard); void squeek_layout_draw_all_changed(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr, struct submission *submission); void squeek_draw_layout_base_view(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr); diff --git a/src/server-context-service.c b/src/server-context-service.c index d8f6b365..23d94283 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -39,7 +39,7 @@ typedef struct _ServerContextServiceClass ServerContextServiceClass; struct _ServerContextService { GObject parent; - EekboardContextService *state; // unowned + LayoutHolder *state; // unowned /// Needed for instantiating the widget struct submission *submission; // unowned struct squeek_layout_state *layout; @@ -312,7 +312,7 @@ server_context_service_init (ServerContextService *state) { } ServerContextService * -server_context_service_new (EekboardContextService *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman) +server_context_service_new (LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman) { ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL); ui->submission = submission; diff --git a/src/server-context-service.h b/src/server-context-service.h index a69f85ae..6040f8e1 100644 --- a/src/server-context-service.h +++ b/src/server-context-service.h @@ -37,7 +37,7 @@ typedef struct _ServerContextService ServerContextService; GType server_context_service_get_type (void) G_GNUC_CONST; -ServerContextService *server_context_service_new(EekboardContextService *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman); +ServerContextService *server_context_service_new(LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman); enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *); void server_context_service_show_keyboard (ServerContextService *context); void server_context_service_hide_keyboard (ServerContextService *context); diff --git a/src/server-main.c b/src/server-main.c index 9e98fb14..cdbe1eb9 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -42,7 +42,7 @@ struct squeekboard { struct squeek_wayland wayland; // Just hooks. DBusHandler *dbus_handler; // Controls visibility of the OSK. - EekboardContextService *layout_holder; // Currently used layout & keyboard. + LayoutHolder *layout_holder; // Currently used layout & keyboard. ServerContextService *ui_context; // mess, includes the entire UI struct submission *submission; // Wayland text input handling. struct squeek_layout_state layout_choice; // Currently wanted layout. diff --git a/src/submission.h b/src/submission.h index e2ebbbfd..a4379b4a 100644 --- a/src/submission.h +++ b/src/submission.h @@ -10,10 +10,10 @@ struct submission; struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager, struct zwp_virtual_keyboard_manager_v1 *vkmanager, struct wl_seat *seat, - EekboardContextService *state); + LayoutHolder *state); // Defined in Rust -struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state); +struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, LayoutHolder *state); void submission_set_ui(struct submission *self, ServerContextService *ui_context); void submission_set_keyboard(struct submission *self, LevelKeyboard *keyboard); #endif -- GitLab From 33039e65cb345b9e55222a2a50be1e47f1a24e52 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 5 Mar 2020 11:55:20 +0000 Subject: [PATCH 12/14] layout_holder: Remove unused functions --- eekboard/eekboard-context-service.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index 66c863a1..cc284ae9 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -79,13 +79,6 @@ eekboard_context_service_get_property (GObject *object, } } -static void -eekboard_context_service_dispose (GObject *object) -{ - G_OBJECT_CLASS (layout_holder_parent_class)-> - dispose (object); -} - static void settings_get_layout(GSettings *settings, char **type, char **layout) { @@ -154,22 +147,14 @@ layout_holder_init (LayoutHolder *self) { self->priv = LAYOUT_HOLDER_GET_PRIVATE(self); } -static void -eekboard_context_service_constructed (GObject *object) -{ - (void)object; -} - static void layout_holder_class_init (LayoutHolderClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GParamSpec *pspec; - gobject_class->constructed = eekboard_context_service_constructed; gobject_class->set_property = eekboard_context_service_set_property; gobject_class->get_property = eekboard_context_service_get_property; - gobject_class->dispose = eekboard_context_service_dispose; /** * EekboardContextService:keyboard: -- GitLab From 6d7360a23024771fe0849af98a80b9862bd21270 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 7 Mar 2020 15:33:10 +0000 Subject: [PATCH 13/14] layout_holder: Rename functions used from C --- eek/eek-gtk-keyboard.c | 8 +++---- eekboard/eekboard-context-service.c | 35 ++++++++++------------------- eekboard/eekboard-context-service.h | 8 +++---- src/server-main.c | 4 ++-- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index 7c7c1fe6..656c09a9 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -126,7 +126,7 @@ eek_gtk_keyboard_real_size_allocate (GtkWidget *self, if (priv->layout->arrangement != new_type) { priv->layout->arrangement = new_type; - eekboard_context_service_use_layout(priv->eekboard_context, priv->layout); + eek_layout_holder_use_layout(priv->eekboard_context, priv->layout); } if (priv->renderer) @@ -158,7 +158,7 @@ static void drag(EekGtkKeyboard *self, if (!priv->keyboard) { return; } - squeek_layout_drag(eekboard_context_service_get_keyboard(priv->eekboard_context)->layout, + squeek_layout_drag(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout, priv->submission, x, y, eek_renderer_get_transformation(priv->renderer), time, priv->eekboard_context, self); @@ -170,7 +170,7 @@ static void release(EekGtkKeyboard *self, guint32 time) if (!priv->keyboard) { return; } - squeek_layout_release(eekboard_context_service_get_keyboard(priv->eekboard_context)->layout, + squeek_layout_release(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout, priv->submission, eek_renderer_get_transformation(priv->renderer), time, priv->eekboard_context, self); @@ -343,7 +343,7 @@ on_notify_keyboard (GObject *object, EekGtkKeyboard *self) { (void)spec; EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (self); - priv->keyboard = eekboard_context_service_get_keyboard(LAYOUT_HOLDER(object)); + priv->keyboard = eek_layout_holder_get_keyboard(LAYOUT_HOLDER(object)); if (priv->renderer) { eek_renderer_free(priv->renderer); } diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index cc284ae9..eb91c380 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -62,7 +62,7 @@ eekboard_context_service_set_property (GObject *object, } static void -eekboard_context_service_get_property (GObject *object, +layout_holder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) @@ -98,7 +98,7 @@ settings_get_layout(GSettings *settings, char **type, char **layout) } void -eekboard_context_service_use_layout(LayoutHolder *context, struct squeek_layout_state *state) { +eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *state) { gchar *layout_name = state->overlay_name; if (layout_name == NULL) { @@ -154,12 +154,10 @@ layout_holder_class_init (LayoutHolderClass *klass) GParamSpec *pspec; gobject_class->set_property = eekboard_context_service_set_property; - gobject_class->get_property = eekboard_context_service_get_property; + gobject_class->get_property = layout_holder_get_property; /** - * EekboardContextService:keyboard: - * - * An #EekKeyboard currently active in this context. + * An #LevelKeyboard currently active in this context. */ pspec = g_param_spec_pointer("keyboard", "Keyboard", @@ -170,21 +168,12 @@ layout_holder_class_init (LayoutHolderClass *klass) pspec); } -void -eekboard_context_service_destroy (LayoutHolder *context) -{ - (void)context; -} - /** - * eekboard_context_service_get_keyboard: - * @context: an #EekboardContextService - * * Get keyboard currently active in @context. - * Returns: (transfer none): an #EekKeyboard + * Returns: (transfer none): a LevelKeyboard */ LevelKeyboard * -eekboard_context_service_get_keyboard (LayoutHolder *context) +eek_layout_holder_get_keyboard (LayoutHolder *context) { return context->priv->keyboard; } @@ -195,7 +184,7 @@ void eekboard_context_service_set_hint_purpose(LayoutHolder *context, if (context->layout->hint != hint || context->layout->purpose != purpose) { context->layout->hint = hint; context->layout->purpose = purpose; - eekboard_context_service_use_layout(context, context->layout); + eek_layout_holder_use_layout(context, context->layout); } } @@ -204,7 +193,7 @@ eekboard_context_service_set_overlay(LayoutHolder *context, const char* name) { if (g_strcmp0(context->layout->overlay_name, name)) { g_free(context->layout->overlay_name); context->layout->overlay_name = g_strdup(name); - eekboard_context_service_use_layout(context, context->layout); + eek_layout_holder_use_layout(context, context->layout); } } @@ -213,15 +202,15 @@ eekboard_context_service_get_overlay(LayoutHolder *context) { return context->layout->overlay_name; } -LayoutHolder *eekboard_context_service_new(struct squeek_layout_state *state) +LayoutHolder *eek_layout_holder_new(struct squeek_layout_state *state) { LayoutHolder *context = g_object_new (EEKBOARD_TYPE_LAYOUT_HOLDER, NULL); context->layout = state; - eekboard_context_service_use_layout(context, context->layout); + eek_layout_holder_use_layout(context, context->layout); return context; } -void eekboard_context_service_set_submission(LayoutHolder *context, struct submission *submission) { +void eek_layout_holder_set_submission(LayoutHolder *context, struct submission *submission) { context->priv->submission = submission; if (context->priv->submission) { submission_set_keyboard(context->priv->submission, context->priv->keyboard); @@ -243,7 +232,7 @@ static void settings_update_layout(struct gsettings_tracker *self) { self->layout->layout_name = g_strdup(keyboard_layout); } // This must actually update the UI. - eekboard_context_service_use_layout(self->context, self->layout); + eek_layout_holder_use_layout(self->context, self->layout); } } diff --git a/eekboard/eekboard-context-service.h b/eekboard/eekboard-context-service.h index de51fba8..6763c4ff 100644 --- a/eekboard/eekboard-context-service.h +++ b/eekboard/eekboard-context-service.h @@ -73,9 +73,9 @@ struct gsettings_tracker { void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, LayoutHolder *context, struct squeek_layout_state *layout); -LayoutHolder *eekboard_context_service_new(struct squeek_layout_state *state); -void eekboard_context_service_set_submission(LayoutHolder *context, struct submission *submission); -LevelKeyboard *eekboard_context_service_get_keyboard(LayoutHolder *context); +LayoutHolder *eek_layout_holder_new(struct squeek_layout_state *state); +void eek_layout_holder_set_submission(LayoutHolder *context, struct submission *submission); +LevelKeyboard *eek_layout_holder_get_keyboard(LayoutHolder *context); void eekboard_context_service_set_keymap(LayoutHolder *context, const LevelKeyboard *keyboard); @@ -84,6 +84,6 @@ void eekboard_context_service_set_hint_purpose(LayoutHolder *context, uint32_t hint, uint32_t purpose); void -eekboard_context_service_use_layout(LayoutHolder *context, struct squeek_layout_state *layout); +eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *layout); G_END_DECLS #endif /* EEKBOARD_CONTEXT_SERVICE_H */ diff --git a/src/server-main.c b/src/server-main.c index cdbe1eb9..cafa9bed 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -206,7 +206,7 @@ main (int argc, char **argv) instance.ui_manager = squeek_uiman_new(instance.wayland.outputs); - instance.layout_holder = eekboard_context_service_new(&instance.layout_choice); + instance.layout_holder = eek_layout_holder_new(&instance.layout_choice); eek_gsettings_tracker_init(&instance.gsettings_tracker, instance.layout_holder, &instance.layout_choice); // set up dbus @@ -282,7 +282,7 @@ main (int argc, char **argv) instance.wayland.seat, instance.layout_holder); - eekboard_context_service_set_submission(instance.layout_holder, instance.submission); + eek_layout_holder_set_submission(instance.layout_holder, instance.submission); ServerContextService *ui_context = server_context_service_new( instance.layout_holder, -- GitLab From 9ce2cf254bdbcc698d666fa017486be9b3725553 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 7 Mar 2020 15:40:17 +0000 Subject: [PATCH 14/14] layout_state: Don't always operate on the global instance --- eek/eek-gtk-keyboard.c | 5 +++-- eekboard/eekboard-context-service.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index 656c09a9..f2fb2397 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -124,9 +124,10 @@ eek_gtk_keyboard_real_size_allocate (GtkWidget *self, (uint32_t)(allocation->width - allocation->x) * scale, (uint32_t)(allocation->height - allocation->y) * scale); if (priv->layout->arrangement != new_type) { - priv->layout->arrangement = new_type; + struct squeek_layout_state layout = *priv->layout; + layout.arrangement = new_type; - eek_layout_holder_use_layout(priv->eekboard_context, priv->layout); + eek_layout_holder_use_layout(priv->eekboard_context, &layout); } if (priv->renderer) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index eb91c380..4cb350dc 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -99,6 +99,7 @@ settings_get_layout(GSettings *settings, char **type, char **layout) void eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *state) { + *context->layout = *state; gchar *layout_name = state->overlay_name; if (layout_name == NULL) { -- GitLab