From 32ce759e4e2eb8c8cfd67a538f9a46c11f4f91dd Mon Sep 17 00:00:00 2001 From: DK Liao Date: Mon, 16 Oct 2023 20:34:11 +0800 Subject: [PATCH] chore(deps): upgrade gtk to 0.18 (#801) * update to gtk 0.18 * Create gtk018.md * Update gtk018.md --- .changes/gtk018.md | 5 +++ Cargo.toml | 23 ++++++------- src/platform_impl/linux/event_loop.rs | 48 +++++++++++++++------------ src/platform_impl/linux/monitor.rs | 2 +- src/platform_impl/linux/util.rs | 5 ++- src/platform_impl/linux/window.rs | 6 ++-- 6 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 .changes/gtk018.md diff --git a/.changes/gtk018.md b/.changes/gtk018.md new file mode 100644 index 000000000..22b1b6ee0 --- /dev/null +++ b/.changes/gtk018.md @@ -0,0 +1,5 @@ +--- +"tao": "minor" +--- + +Updated to gtk 0.18 and Bump MSRV to 1.70.0. diff --git a/Cargo.toml b/Cargo.toml index 468b26f16..f095df160 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ documentation = "https://docs.rs/tao" categories = [ "gui" ] [package.metadata.docs.rs] -features = [ "serde", "dox" ] +features = [ "serde" ] default-target = "x86_64-unknown-linux-gnu" targets = [ "i686-pc-windows-msvc", @@ -31,7 +31,6 @@ members = [ "tao-macros" ] [features] default = [ ] -dox = [ "gtk/dox" ] [build-dependencies] cc = "1" @@ -111,16 +110,16 @@ windows-implement = "0.48.0" ] [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -cairo-rs = "0.16" -gio = "0.16" -glib = "0.16" -glib-sys = "0.16" -gtk = "0.16" -gdk = "0.16" -gdk-sys = "0.16" -gdkx11-sys = "0.16" -gdkwayland-sys = "0.16.0" -gdk-pixbuf = "0.16" +cairo-rs = "0.18" +gio = "0.18" +glib = "0.18" +glib-sys = "0.18" +gtk = "0.18" +gdk = "0.18" +gdk-sys = "0.18" +gdkx11-sys = "0.18" +gdkwayland-sys = "0.18.0" +gdk-pixbuf = "0.18" x11-dl = "2.21" zbus = "3" uuid = { version = "1.3", features = [ "v4" ] } diff --git a/src/platform_impl/linux/event_loop.rs b/src/platform_impl/linux/event_loop.rs index ef736b686..e2354d9cb 100644 --- a/src/platform_impl/linux/event_loop.rs +++ b/src/platform_impl/linux/event_loop.rs @@ -16,8 +16,8 @@ use cairo::{RectangleInt, Region}; use crossbeam_channel::SendError; use gdk::{Cursor, CursorType, EventKey, EventMask, ScrollDirection, WindowEdge, WindowState}; use gio::{prelude::*, Cancellable}; -use glib::{source::Priority, Continue, MainContext}; -use gtk::{prelude::*, Inhibit}; +use glib::{source::Priority, MainContext}; +use gtk::prelude::*; use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle, XlibDisplayHandle}; @@ -207,7 +207,11 @@ impl EventLoop { }) { log::warn!("Fail to send device event to event channel: {}", e); } - Continue(run.load(Ordering::Relaxed)) + if run.load(Ordering::Relaxed) { + glib::ControlFlow::Continue + } else { + glib::ControlFlow::Break + } }); Some(run_device_thread) } else { @@ -422,7 +426,7 @@ impl EventLoop { ); } } - Inhibit(false) + glib::Propagation::Proceed }); window.connect_button_press_event(|window, event| { if !window.is_decorated() && window.is_resizable() && event.button() == 1 { @@ -441,7 +445,7 @@ impl EventLoop { } } - Inhibit(false) + glib::Propagation::Proceed }); window.connect_touch_event(|window, event| { if !window.is_decorated() && window.is_resizable() { @@ -467,7 +471,7 @@ impl EventLoop { } } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -478,7 +482,7 @@ impl EventLoop { }) { log::warn!("Failed to send window close event to event channel: {}", e); } - Inhibit(true) + glib::Propagation::Stop }); let tx_clone = event_tx.clone(); @@ -521,7 +525,7 @@ impl EventLoop { e ); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -535,7 +539,7 @@ impl EventLoop { e ); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -564,7 +568,7 @@ impl EventLoop { e ); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -586,7 +590,7 @@ impl EventLoop { } } } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -599,7 +603,7 @@ impl EventLoop { }) { log::warn!("Failed to send cursor left event to event channel: {}", e); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -625,7 +629,7 @@ impl EventLoop { e ); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -651,7 +655,7 @@ impl EventLoop { e ); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -671,7 +675,7 @@ impl EventLoop { }) { log::warn!("Failed to send scroll event to event channel: {}", e); } - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -695,7 +699,7 @@ impl EventLoop { } else { // stop here we don't want to send the key event // as we emit the `ModifiersChanged` - return Continue(true); + return glib::ControlFlow::Continue; } } @@ -714,7 +718,7 @@ impl EventLoop { log::warn!("Failed to send keyboard event to event channel: {}", e); } } - Continue(true) + glib::ControlFlow::Continue }); let tx_clone = event_tx.clone(); @@ -739,13 +743,13 @@ impl EventLoop { handler(event_key.to_owned(), ElementState::Pressed); ime.filter_keypress(event_key); - Inhibit(false) + glib::Propagation::Proceed }); let handler = keyboard_handler.clone(); window.connect_key_release_event(move |_, event_key| { handler(event_key.to_owned(), ElementState::Released); - Inhibit(false) + glib::Propagation::Proceed }); let tx_clone = event_tx.clone(); @@ -777,7 +781,7 @@ impl EventLoop { ); } } - Inhibit(false) + glib::Propagation::Proceed }); // Receive draw events of the window. @@ -794,7 +798,7 @@ impl EventLoop { cr.set_operator(cairo::Operator::Over); } - Inhibit(false) + glib::Propagation::Proceed }); } } @@ -818,7 +822,7 @@ impl EventLoop { _ => unreachable!(), } } - Continue(true) + glib::ControlFlow::Continue }); // Create event loop itself. diff --git a/src/platform_impl/linux/monitor.rs b/src/platform_impl/linux/monitor.rs index 6eb1c22fc..205f6c9d6 100644 --- a/src/platform_impl/linux/monitor.rs +++ b/src/platform_impl/linux/monitor.rs @@ -2,7 +2,7 @@ // Copyright 2021-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 -use gdk::Display; +use gdk::{prelude::MonitorExt, Display}; use crate::{ dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}, diff --git a/src/platform_impl/linux/util.rs b/src/platform_impl/linux/util.rs index a221e609b..514a04b50 100644 --- a/src/platform_impl/linux/util.rs +++ b/src/platform_impl/linux/util.rs @@ -1,4 +1,7 @@ -use gdk::Display; +use gdk::{ + prelude::{DeviceExt, SeatExt}, + Display, +}; use gtk::traits::{GtkWindowExt, WidgetExt}; use crate::{ diff --git a/src/platform_impl/linux/window.rs b/src/platform_impl/linux/window.rs index 249d07c2f..812e2efed 100644 --- a/src/platform_impl/linux/window.rs +++ b/src/platform_impl/linux/window.rs @@ -14,7 +14,7 @@ use std::{ use gdk::{WindowEdge, WindowState}; use glib::translate::ToGlibPtr; -use gtk::{prelude::*, traits::SettingsExt, Settings}; +use gtk::{prelude::*, Settings}; use raw_window_handle::{ RawDisplayHandle, RawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle, XlibDisplayHandle, XlibWindowHandle, @@ -226,7 +226,7 @@ impl Window { window.set_accept_focus(true); window.disconnect(id); } - Inhibit(false) + glib::Propagation::Proceed }); signal_id.borrow_mut().replace(id); } @@ -261,7 +261,7 @@ impl Window { let state = event.new_window_state(); max_clone.store(state.contains(WindowState::MAXIMIZED), Ordering::Release); minimized_clone.store(state.contains(WindowState::ICONIFIED), Ordering::Release); - Inhibit(false) + glib::Propagation::Proceed }); let scale_factor: Rc = Rc::new(win_scale_factor.into());