Skip to content

Commit

Permalink
Port to GTK4 (#105)
Browse files Browse the repository at this point in the history
* zbus: move to non-deprecated attribute macros

* server: move from MainContext::channel to async_channel

* src/server: fix receiver being closed after ignored libinput event

* server: update gtk to 0.18.1

* server: update to gtk-layer-shell 0.8.1

* initial port to gtk4 (compiles but doesn't work properly)

- some icons are broken
- clearing osd window doesn't work
- gtk4_layer_shell crashes more often than not

* rustfmt.toml: fix warning

* server/osd_window: fix clear_osd() not actually removing things

we need to get the next sibling before we remove it from the box.

* server/osd_window: fix missing icons (has_icon no longer works properly)

some icons (notably volume icons) don't seem to be detected by has_icon
properly in all cases, but the icon is drawn correctly. Use
gio::ThemedIcon directly and pass "missing-symbolic" as a fallback name
through there to avoid checking explicitly.

* server/osd_window: fix gtk4-layer-shell crash

* server/osd_window: update window margin when parameters change

This ensures the window margin is always correct. This also fixes an
annoying issue where the monitor scale factor is not always correct (it
never changes back to scale 1 if it was scale 2 at some point) by
transforming the monitor height into window coordinates manually.

Fixes #101.

* server/application: asynchronously send libinput events

* server: remove unused imports

* server/application: clean up gtk imports
  • Loading branch information
Ferdi265 authored Nov 19, 2024
1 parent dbb8b72 commit bf77623
Show file tree
Hide file tree
Showing 8 changed files with 522 additions and 555 deletions.
616 changes: 244 additions & 372 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ toml = "0.8"
serde = "1"
serde_derive = "1"
# GUI Dependencies
gtk = "0.17.1"
gtk-layer-shell = "0.6.1"
gtk = { package = "gtk4", version = "0.9.1" }
gtk-layer-shell = { package = "gtk4-layer-shell", version = "0.4.0" }
shrinkwraprs = "0.3.0"
cascade = "1.0.1"
pulse = { version = "2.26.0", package = "libpulse-binding" }
Expand All @@ -41,3 +41,4 @@ nix = "0.26.2"
blight = "0.7.0"
anyhow = "1.0.75"
thiserror = "1.0.49"
async-channel = "2.3.1"
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ color = "Auto"
unstable_features = false
disable_all_formatting = false
skip_children = false
hide_parse_errors = false
show_parse_errors = true
error_on_line_overflow = false
error_on_unformatted = false
ignore = []
Expand Down
4 changes: 2 additions & 2 deletions src/client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use gtk::{gio::ApplicationFlags, Application};
use gtk::{glib, prelude::*};
use std::env::args_os;
use std::path::PathBuf;
use zbus::{blocking::Connection, dbus_proxy};
use zbus::{blocking::Connection, proxy};

#[dbus_proxy(
#[proxy(
interface = "org.erikreider.swayosd",
default_service = "org.erikreider.swayosd-server",
default_path = "/org/erikreider/swayosd"
Expand Down
6 changes: 3 additions & 3 deletions src/input-backend/dbus_server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use zbus::{dbus_interface, Connection, ConnectionBuilder, SignalContext};
use zbus::{interface, Connection, ConnectionBuilder, SignalContext};

use crate::config::{DBUS_BACKEND_NAME, DBUS_PATH};

pub struct DbusServer;

#[dbus_interface(name = "org.erikreider.swayosd")]
#[interface(name = "org.erikreider.swayosd")]
impl DbusServer {
#[dbus_interface(signal)]
#[zbus(signal)]
pub async fn key_pressed(
signal_ctxt: &SignalContext<'_>,
key_code: u16,
Expand Down
Loading

0 comments on commit bf77623

Please sign in to comment.