scaling: Add GSettings for adjusting the height of the panel
Part-of: <https://gitlab.gnome.org/World/Phosh/squeekboard/-/merge_requests/679>
This commit is contained in:
14
README.md
14
README.md
@ -63,6 +63,7 @@ Running
|
|||||||
$ cd ../build/
|
$ cd ../build/
|
||||||
$ src/squeekboard
|
$ src/squeekboard
|
||||||
```
|
```
|
||||||
|
|
||||||
If no compatible Wayland compositor is running yet, you can use Phoc (after installing it):
|
If no compatible Wayland compositor is running yet, you can use Phoc (after installing it):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -82,6 +83,7 @@ Alternatively, force panel visibility manually with:
|
|||||||
```sh
|
```sh
|
||||||
$ busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
|
$ busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
|
||||||
```
|
```
|
||||||
|
|
||||||
or by using the environment-variable `SQUEEKBOARD_DEBUG=force_show`.
|
or by using the environment-variable `SQUEEKBOARD_DEBUG=force_show`.
|
||||||
|
|
||||||
### What the compositor has to support
|
### What the compositor has to support
|
||||||
@ -95,6 +97,18 @@ It's strongly recommended to support:
|
|||||||
|
|
||||||
- input-method-v2
|
- input-method-v2
|
||||||
|
|
||||||
|
Settings
|
||||||
|
--------
|
||||||
|
|
||||||
|
To see a list of available settings, use the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ gsettings list-keys sm.puri.Squeekboard
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: If the keyboard is open when the settings for the panel-height are changed, the height of the keyboard will not change until it is opened again, or the layout is changed.
|
||||||
|
While using Phosh, one can long-click/long-tap the home-bar at the bottom, to open and close the keyboard.
|
||||||
|
|
||||||
Developing
|
Developing
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|||||||
3
cargo.sh
3
cargo.sh
@ -12,6 +12,9 @@ SOURCE_DIR="$(dirname "$SCRIPT_PATH")"
|
|||||||
CARGO_TARGET_DIR="$(pwd)"
|
CARGO_TARGET_DIR="$(pwd)"
|
||||||
export CARGO_TARGET_DIR
|
export CARGO_TARGET_DIR
|
||||||
|
|
||||||
|
GSETTINGS_SCHEMA_DIR="${CARGO_TARGET_DIR}/data:${GSETTINGS_SCHEMA_DIR}"
|
||||||
|
export GSETTINGS_SCHEMA_DIR
|
||||||
|
|
||||||
cd "$SOURCE_DIR"
|
cd "$SOURCE_DIR"
|
||||||
|
|
||||||
# the 'run" command takes arguments at the end,
|
# the 'run" command takes arguments at the end,
|
||||||
|
|||||||
@ -1,5 +1,37 @@
|
|||||||
gnome = import('gnome')
|
gnome = import('gnome')
|
||||||
|
|
||||||
|
#workaround due to https://github.com/mesonbuild/meson/issues/1687
|
||||||
|
copy_schema = custom_target('copy-gschema-to-builddir',
|
||||||
|
input: 'sm.puri.Squeekboard.gschema.xml',
|
||||||
|
output: 'sm.puri.Squeekboard.gschema.xml',
|
||||||
|
command: ['cp', '@INPUT@', '@OUTPUT@']
|
||||||
|
)
|
||||||
|
schemas = ['sm.puri.Squeekboard.gschema.xml']
|
||||||
|
compile_schemas = custom_target('glib-compile-schemas',
|
||||||
|
build_by_default: true,
|
||||||
|
output: 'gschemas.compiled',
|
||||||
|
install: false,
|
||||||
|
command: [find_program('glib-compile-schemas'),
|
||||||
|
meson.current_build_dir()
|
||||||
|
],
|
||||||
|
depends: [copy_schema]
|
||||||
|
)
|
||||||
|
install_data(
|
||||||
|
schemas,
|
||||||
|
install_dir: schemasdir
|
||||||
|
)
|
||||||
|
|
||||||
|
compile_schemas = find_program('glib-compile-schemas', required: false)
|
||||||
|
if compile_schemas.found()
|
||||||
|
test('Validate schema file', compile_schemas,
|
||||||
|
args: ['--strict', '--dry-run', meson.current_source_dir()])
|
||||||
|
endif
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
schemas,
|
||||||
|
install_dir: 'share/glib-2.0/schemas'
|
||||||
|
)
|
||||||
|
|
||||||
squeekboard_resources = gnome.compile_resources(
|
squeekboard_resources = gnome.compile_resources(
|
||||||
'squeekboard-resources',
|
'squeekboard-resources',
|
||||||
'squeekboard.gresources.xml',
|
'squeekboard.gresources.xml',
|
||||||
|
|||||||
32
data/sm.puri.Squeekboard.gschema.xml
Normal file
32
data/sm.puri.Squeekboard.gschema.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<schemalist>
|
||||||
|
<schema id="sm.puri.Squeekboard"
|
||||||
|
path="/sm/puri/Squeekboard/" >
|
||||||
|
<key name='scale-in-horizontal-screen-orientation' type='d'>
|
||||||
|
<range min="0.50" max="2.00"/>
|
||||||
|
<default>1.00</default>
|
||||||
|
<summary>The multiplier for the height of the panel while the screen is in landscape-orientation</summary>
|
||||||
|
<description>
|
||||||
|
The height of the panel for the layout is multiplied by this value,
|
||||||
|
while the screen is in landscape-orientation.
|
||||||
|
Changing this is currently mostly useful for custom layouts,
|
||||||
|
or to work around scaling-issues, because the layout-aspect-ratio is fixed.
|
||||||
|
There is an upper limit of 2/3 of the screen.
|
||||||
|
For square screens, the setting for screens in landscape-orientation is used.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name='scale-in-vertical-screen-orientation' type='d'>
|
||||||
|
<range min="0.50" max="2.00"/>
|
||||||
|
<default>1.00</default>
|
||||||
|
<summary>The multiplier for the height of the panel while the screen is in portrait-orientation</summary>
|
||||||
|
<description>
|
||||||
|
The height of the panel for the layout is multiplied by this value,
|
||||||
|
while the screen is in portrait-orientation.
|
||||||
|
Changing this is currently mostly useful for custom layouts,
|
||||||
|
or to work around scaling-issues, because the layout-aspect-ratio is fixed.
|
||||||
|
There is an upper limit of 2/3 of the screen.
|
||||||
|
For square screens, the setting for screens in landscape-orientation is used.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
||||||
|
|
||||||
1
debian/squeekboard.install
vendored
1
debian/squeekboard.install
vendored
@ -1,4 +1,5 @@
|
|||||||
tools/squeekboard-restyled usr/bin
|
tools/squeekboard-restyled usr/bin
|
||||||
usr/bin/squeekboard /usr/bin
|
usr/bin/squeekboard /usr/bin
|
||||||
usr/share/applications/*.desktop usr/share/squeekboard/
|
usr/share/applications/*.desktop usr/share/squeekboard/
|
||||||
|
usr/share/glib-2.0/schemas/
|
||||||
usr/share/locale/
|
usr/share/locale/
|
||||||
|
|||||||
@ -70,6 +70,7 @@ else
|
|||||||
depdatadir = get_option('depdatadir')
|
depdatadir = get_option('depdatadir')
|
||||||
endif
|
endif
|
||||||
dbusdir = join_paths(depdatadir, 'dbus-1/interfaces')
|
dbusdir = join_paths(depdatadir, 'dbus-1/interfaces')
|
||||||
|
schemasdir = datadir / 'glib-2.0' / 'schemas'
|
||||||
|
|
||||||
conf_data = configuration_data()
|
conf_data = configuration_data()
|
||||||
conf_data.set_quoted('GETTEXT_PACKAGE', 'squeekboard')
|
conf_data.set_quoted('GETTEXT_PACKAGE', 'squeekboard')
|
||||||
@ -111,3 +112,7 @@ subdir('protocols')
|
|||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('tools')
|
subdir('tools')
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
|
|
||||||
|
gnome.post_install(
|
||||||
|
glib_compile_schemas: true,
|
||||||
|
)
|
||||||
57
src/state.rs
57
src/state.rs
@ -19,6 +19,8 @@ use crate::panel;
|
|||||||
use crate::panel::PixelSize;
|
use crate::panel::PixelSize;
|
||||||
use crate::popover;
|
use crate::popover;
|
||||||
use crate::util::Rational;
|
use crate::util::Rational;
|
||||||
|
use gio::Settings;
|
||||||
|
use gdk::prelude::SettingsExt;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
@ -390,6 +392,10 @@ Outcome:
|
|||||||
|
|
||||||
let screen_aspect_ratio = {px_size.height as f64 / px_size.width as f64};
|
let screen_aspect_ratio = {px_size.height as f64 / px_size.width as f64};
|
||||||
|
|
||||||
|
let gsettings = Settings::new("sm.puri.Squeekboard");
|
||||||
|
let scale_setting_horizontal = gsettings.double("scale-in-horizontal-screen-orientation");
|
||||||
|
let scale_setting_vertical = gsettings.double("scale-in-vertical-screen-orientation");
|
||||||
|
|
||||||
// Reduce height, to match what the layout can fill.
|
// Reduce height, to match what the layout can fill.
|
||||||
// For this, we need to guess if normal or wide will be picked.
|
// For this, we need to guess if normal or wide will be picked.
|
||||||
// This must match `eek_gtk_keyboard.c::get_type`.
|
// This must match `eek_gtk_keyboard.c::get_type`.
|
||||||
@ -417,17 +423,28 @@ Outcome:
|
|||||||
(layout_aspect_ratio * px_size.width as i32).ceil() as u32,
|
(layout_aspect_ratio * px_size.width as i32).ceil() as u32,
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
let panel_height = {
|
||||||
PixelSize {
|
if arrangement == ArrangementKind::Base && screen_width < screen_height {
|
||||||
scale_factor: output.scale as u32,
|
|
||||||
// Set the height of the panel for the layout.
|
|
||||||
pixels: if arrangement == ArrangementKind::Base && screen_width < screen_height {
|
|
||||||
cmp::min((px_size.height as f64 / (screen_aspect_ratio / (7.0 / 12.0))) as u32, px_size.height / 2)}
|
cmp::min((px_size.height as f64 / (screen_aspect_ratio / (7.0 / 12.0))) as u32, px_size.height / 2)}
|
||||||
else if arrangement == ArrangementKind::Wide && screen_width < screen_height {
|
else if arrangement == ArrangementKind::Wide && screen_width < screen_height {
|
||||||
cmp::min((px_size.height as f64 / (screen_aspect_ratio / (5.0 / 16.0))) as u32, px_size.height / 2)}
|
cmp::min((px_size.height as f64 / (screen_aspect_ratio / (5.0 / 16.0))) as u32, px_size.height / 2)}
|
||||||
else if arrangement == ArrangementKind::Wide {
|
else if arrangement == ArrangementKind::Wide {
|
||||||
cmp::min(cmp::max(px_size.height / 3 as u32, recommended_panel_height), px_size.height / 2)}
|
cmp::min(cmp::max(px_size.height / 3 as u32, recommended_panel_height), px_size.height / 2)}
|
||||||
else {px_size.height / 2},
|
else {px_size.height / 2}
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
PixelSize {
|
||||||
|
scale_factor: output.scale as u32,
|
||||||
|
// Set the height of the panel for the layout.
|
||||||
|
pixels: if screen_width < screen_height {
|
||||||
|
cmp::min((panel_height as f64 * scale_setting_vertical) as u32,
|
||||||
|
(px_size.height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmp::min((panel_height as f64 * scale_setting_horizontal) as u32,
|
||||||
|
(px_size.height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
arrangement,
|
arrangement,
|
||||||
)
|
)
|
||||||
@ -737,6 +754,11 @@ pub mod test {
|
|||||||
// scaling-tests
|
// scaling-tests
|
||||||
fn scaling_test_base(pixel_width: i32, pixel_height: i32, physical_width: i32, physical_height: i32, scale: i32, expected_pixel_height: u32) {
|
fn scaling_test_base(pixel_width: i32, pixel_height: i32, physical_width: i32, physical_height: i32, scale: i32, expected_pixel_height: u32) {
|
||||||
use crate::outputs::{Mode, Geometry, c, Size};
|
use crate::outputs::{Mode, Geometry, c, Size};
|
||||||
|
|
||||||
|
let gsettings = Settings::new("sm.puri.Squeekboard");
|
||||||
|
let scale_setting_horizontal = gsettings.double("scale-in-horizontal-orientation");
|
||||||
|
let scale_setting_vertical = gsettings.double("scale-in-vertical-orientation");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Application::get_preferred_height_and_arrangement(&OutputState {
|
Application::get_preferred_height_and_arrangement(&OutputState {
|
||||||
current_mode: Some(Mode {
|
current_mode: Some(Mode {
|
||||||
@ -755,7 +777,14 @@ pub mod test {
|
|||||||
Some((
|
Some((
|
||||||
PixelSize {
|
PixelSize {
|
||||||
scale_factor: scale as u32,
|
scale_factor: scale as u32,
|
||||||
pixels: expected_pixel_height,
|
pixels: if pixel_width < pixel_height {
|
||||||
|
cmp::min((expected_pixel_height as f64 * scale_setting_vertical) as u32,
|
||||||
|
(pixel_height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmp::min((expected_pixel_height as f64 * scale_setting_horizontal) as u32,
|
||||||
|
(pixel_height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ArrangementKind::Base,
|
ArrangementKind::Base,
|
||||||
)),
|
)),
|
||||||
@ -764,6 +793,11 @@ pub mod test {
|
|||||||
|
|
||||||
fn scaling_test_wide(pixel_width: i32, pixel_height: i32, physical_width: i32, physical_height: i32, scale: i32, expected_pixel_height: u32) {
|
fn scaling_test_wide(pixel_width: i32, pixel_height: i32, physical_width: i32, physical_height: i32, scale: i32, expected_pixel_height: u32) {
|
||||||
use crate::outputs::{Mode, Geometry, c, Size};
|
use crate::outputs::{Mode, Geometry, c, Size};
|
||||||
|
|
||||||
|
let gsettings = Settings::new("sm.puri.Squeekboard");
|
||||||
|
let scale_setting_horizontal = gsettings.double("scale-in-horizontal-orientation");
|
||||||
|
let scale_setting_vertical = gsettings.double("scale-in-vertical-orientation");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Application::get_preferred_height_and_arrangement(&OutputState {
|
Application::get_preferred_height_and_arrangement(&OutputState {
|
||||||
current_mode: Some(Mode {
|
current_mode: Some(Mode {
|
||||||
@ -782,7 +816,14 @@ pub mod test {
|
|||||||
Some((
|
Some((
|
||||||
PixelSize {
|
PixelSize {
|
||||||
scale_factor: scale as u32,
|
scale_factor: scale as u32,
|
||||||
pixels: expected_pixel_height,
|
pixels: if pixel_width < pixel_height {
|
||||||
|
cmp::min((expected_pixel_height as f64 * scale_setting_vertical) as u32,
|
||||||
|
(pixel_height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmp::min((expected_pixel_height as f64 * scale_setting_horizontal) as u32,
|
||||||
|
(pixel_height as f64 * (2.0 / 3.0)) as u32)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ArrangementKind::Wide,
|
ArrangementKind::Wide,
|
||||||
)),
|
)),
|
||||||
|
|||||||
Reference in New Issue
Block a user