diff --git a/src/lib.rs b/src/lib.rs index 6051250d..9fe36843 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,5 @@ mod style; mod submission; pub mod tests; pub mod util; -mod ui_manager; mod vkeyboard; mod xdg; diff --git a/src/outputs.rs b/src/outputs.rs index 327923d3..13c1b5d3 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -118,26 +118,6 @@ pub mod c { /// Wrapping Outputs is required for calling its methods from C type COutputs = Wrapped; - /// A stable reference to an output. - #[derive(Clone)] - #[repr(C)] - pub struct OutputHandle { - wl_output: WlOutput, - outputs: COutputs, - } - - impl OutputHandle { - // Cannot return an Output reference - // because COutputs is too deeply wrapped - pub fn get_state(&self) -> Option { - let outputs = self.outputs.clone_ref(); - let outputs = outputs.borrow(); - outputs - .find_output(self.wl_output.clone()) - .map(|o| o.current.clone()) - } - } - // Defined in Rust // Callbacks from the output listener follow @@ -303,17 +283,6 @@ pub mod c { .unwrap_or(WlOutput::null()) } - #[no_mangle] - pub extern "C" - fn squeek_outputs_get_current(raw_collection: COutputs) -> OutputHandle { - let collection = raw_collection.clone_ref(); - let collection = collection.borrow(); - OutputHandle { - wl_output: collection.outputs[0].0.output.clone(), - outputs: raw_collection.clone(), - } - } - // TODO: handle unregistration } @@ -437,14 +406,6 @@ impl Outputs { } } - fn find_output(&self, wl_output: c::WlOutput) -> Option<&Output> { - self.outputs - .iter() - .find_map(|(o, _global)| - if o.output == wl_output { Some(o) } else { None } - ) - } - fn find_output_mut(&mut self, wl_output: c::WlOutput) -> Option<&mut Output> { diff --git a/src/server-context-service.c b/src/server-context-service.c index 23fe42d7..6e65aa11 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -42,7 +42,6 @@ struct _ServerContextService { /// Needed for instantiating the widget struct submission *submission; // unowned struct squeek_layout_state *layout; - struct ui_manager *manager; // unowned struct squeek_state_manager *state_manager; // shared reference PhoshLayerSurface *window; @@ -315,13 +314,12 @@ init (ServerContextService *self) { } ServerContextService * -server_context_service_new (EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman, struct squeek_state_manager *state_manager) +server_context_service_new (EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct squeek_state_manager *state_manager) { ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL); ui->submission = submission; ui->state = self; ui->layout = layout; - ui->manager = uiman; ui->state_manager = state_manager; init(ui); return ui; diff --git a/src/server-context-service.h b/src/server-context-service.h index 588aeb5d..599da818 100644 --- a/src/server-context-service.h +++ b/src/server-context-service.h @@ -20,7 +20,6 @@ #include "src/layout.h" #include "src/submission.h" -#include "ui_manager.h" G_BEGIN_DECLS @@ -29,7 +28,7 @@ G_BEGIN_DECLS /** Manages the lifecycle of the window displaying layouts. */ G_DECLARE_FINAL_TYPE (ServerContextService, server_context_service, SERVER, CONTEXT_SERVICE, GObject) -ServerContextService *server_context_service_new(EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman, struct squeek_state_manager *state_manager); +ServerContextService *server_context_service_new(EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct squeek_state_manager *state_manager); enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *); G_END_DECLS #endif /* SERVER_CONTEXT_SERVICE_H */ diff --git a/src/server-main.c b/src/server-main.c index ec72aecc..57381ccf 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -33,7 +33,6 @@ #include "outputs.h" #include "submission.h" #include "server-context-service.h" -#include "ui_manager.h" #include "wayland.h" #include @@ -56,8 +55,6 @@ struct squeekboard { ServerContextService *ui_context; // mess, includes the entire UI /// Currently wanted layout. TODO: merge into state::Application struct squeek_layout_state layout_choice; - /// UI shape tracker/chooser. TODO: merge into state::Application - struct ui_manager *ui_manager; }; @@ -400,8 +397,6 @@ main (int argc, char **argv) // Also initializes wayland struct rsobjects rsobjects = squeek_init(); - instance.ui_manager = squeek_uiman_new(); - instance.settings_context = eekboard_context_service_new(&instance.layout_choice); // set up dbus @@ -446,7 +441,6 @@ main (int argc, char **argv) instance.settings_context, rsobjects.submission, &instance.layout_choice, - instance.ui_manager, rsobjects.state_manager); if (!ui_context) { g_error("Could not initialize GUI"); diff --git a/src/submission.h b/src/submission.h index ed1093f8..5ee2f727 100644 --- a/src/submission.h +++ b/src/submission.h @@ -5,7 +5,6 @@ #include "virtual-keyboard-unstable-v1-client-protocol.h" #include "eek/eek-types.h" #include "main.h" -#include "src/ui_manager.h" struct squeek_layout; diff --git a/src/ui_manager.h b/src/ui_manager.h deleted file mode 100644 index b5f1734e..00000000 --- a/src/ui_manager.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UI_MANAGER__ -#define UI_MANAGER__ - -#include - -#include "eek/eek-types.h" -#include "outputs.h" -#include "main.h" - -struct ui_manager; - -struct ui_manager *squeek_uiman_new(void); -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); - -struct vis_manager; - -struct vis_manager *squeek_visman_new(struct squeek_state_manager *state_manager); -#endif diff --git a/src/ui_manager.rs b/src/ui_manager.rs deleted file mode 100644 index b189a479..00000000 --- a/src/ui_manager.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2020, 2021 Purism SPC - * SPDX-License-Identifier: GPL-3.0+ - */ - -/*! Centrally manages the shape of the UI widgets, and the choice of layout. - * - * Coordinates this based on information collated from all possible sources. - */ - -use std::cmp::min; -use ::outputs::c::OutputHandle; - - -pub mod c { - use super::*; - use ::util::c::Wrapped; - - #[no_mangle] - pub extern "C" - fn squeek_uiman_new() -> Wrapped { - Wrapped::new(Manager { output: None }) - } - - /// Used to size the layer surface containing all the OSK widgets. - #[no_mangle] - pub extern "C" - fn squeek_uiman_get_perceptual_height( - uiman: Wrapped, - ) -> u32 { - 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) - } - - #[no_mangle] - pub extern "C" - fn squeek_uiman_set_output( - uiman: Wrapped, - output: OutputHandle, - ) { - let uiman = uiman.clone_ref(); - let mut uiman = uiman.borrow_mut(); - uiman.output = Some(output); - } -} - -/// 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, - //// Pixel size of the surface. Needs explicit updating. - //surface_size: Option, -} - -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())); - match output_info { - Some((scale, Some(px_size))) => 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 { - 360 + (1080 - px_size.width) * 60 / 360 // smooth transition - } else { - 360 - }; - - // Don't exceed half the display size - min(height, px_size.height / 2) / scale - }), - Some((scale, None)) => Some(360 / scale), - None => None, - } - } -}