Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove menus, system tray and global shortcut features #778

Merged
merged 36 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a88ee3b
disable gtk menu creation
amrbashir Jun 8, 2022
226e78e
remove all menu logic for `Window` type
amrbashir Oct 15, 2022
bea298b
remove accelerator handling from tao on Windows
amrbashir Oct 15, 2022
4721428
use std c_void instead of libc
amrbashir Oct 15, 2022
a35759e
fix linux build
amrbashir Oct 15, 2022
02cc14d
fix `pub` on macos
amrbashir Oct 15, 2022
2d617a9
Merge branch 'dev' into muda
amrbashir Oct 15, 2022
6f9fefa
Merge branch 'dev' into muda
amrbashir Oct 19, 2022
6fd0784
fix linux build
amrbashir Oct 20, 2022
6dac3e7
fix build on linux again
amrbashir Oct 20, 2022
b107997
Fix menubar focus using `Alt` on Windows
amrbashir Oct 24, 2022
8ebb07f
Merge branch 'dev' into muda
amrbashir Dec 5, 2022
06b7028
remove tray and menu modules
amrbashir Dec 6, 2022
d0c851b
Merge branch 'dev' into muda
amrbashir Jan 16, 2023
0f826a4
remove global-shortcut
amrbashir Jan 16, 2023
bfd9de4
Merge branch 'dev' into muda
amrbashir Jan 26, 2023
676bd90
Merge branch 'dev' into muda
amrbashir Feb 7, 2023
81a98df
Merge branch 'dev' into muda
amrbashir Mar 14, 2023
0c14178
refactor: rmeove colorsync link
amrbashir Mar 14, 2023
f53f0ab
Merge branch 'dev' into muda
amrbashir May 9, 2023
17691be
Merge branch 'dev' into muda
amrbashir Jul 11, 2023
710d0ee
Merge branch 'dev' into muda
amrbashir Jul 18, 2023
2d13402
remove unsued trait
amrbashir Jul 20, 2023
1f23e82
feat: implement any_thread for EventLoopBuilder on unix
amrbashir Jul 20, 2023
54c24ef
add gtk box by default
amrbashir Jul 24, 2023
4725b52
Merge remote-tracking branch 'origin/dev' into muda
lucasfernog Jul 27, 2023
81ebbe2
publish new versions
lucasfernog Jul 30, 2023
4469962
Merge branch 'release' into muda
lucasfernog Aug 1, 2023
285915c
fix android build
amrbashir Aug 3, 2023
627caa9
fix ios build
amrbashir Aug 3, 2023
949219f
Merge branch 'dev' into muda
amrbashir Aug 10, 2023
8742cb6
change file
amrbashir Aug 10, 2023
be95637
change hit_test argument type
amrbashir Aug 10, 2023
f1a9bf9
fix windows and linux build
amrbashir Aug 10, 2023
db10906
fix ci
amrbashir Aug 10, 2023
95d1223
fix ios
amrbashir Aug 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changes/removed-feats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"tao": "minor"
---

This release contains a number of **breaking changes** that aimed at removing menus, system-tray and global-shortcuts features which have been moved to different crates, [`muda`](https://github.com/tauri-apps/muda/), [`tray-icon`](https://github.com/tauri-apps/tray-icon/) and [`global-hotkey`](https://github.com/tauri-apps/global-hotkey) and here is a summary of the changes:

- Removed `tray` crago feature flag.
- Removed `accelerator`, `menu`, `system_tray` and `global_shortcut` modules and all associated types.
- Removed `Event::MenuEvent`, `Event::TrayEvent`, `Event::GlobalShortcutEvent`, `TrayEvent` and `Rectangle` types.
- Added `EventLoopBuilder` type.
- Removed `EventLoop::with_user_event`, instead use `EventLoopBuilder::<T>::with_user_event().build()`.
- Removed `EventLoopExtWindows`, `EventLoopExtMacOS` and `EventLoopExtUnix`, instead use `EventLoopBuilderExtWindows`, `EventLoopBuilderExtMacOS` and `EventLoopBuilderExtUnix`.
- Changed `WindowExtWindows::hinstance`, `WindowExtWindows::hwnd` and `MonitorHandleExtWindow::hmonitor` to return `isize` instead of `*const c_void`
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ jobs:
# Ubuntu with default features
- { id: ubuntu, target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
# Ubuntu without features
- { id: ubuntu-without-feat, target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: --no-default-features }
- {
id: ubuntu-without-feat,
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
options: --no-default-features,
}
# macOS
- { id: macos, target: x86_64-apple-darwin, os: macos-latest }
# Android on Ubuntu
- { id: android, target: aarch64-linux-android, os: ubuntu-latest, cmd: "apk --" }
- {
id: android,
target: aarch64-linux-android,
os: ubuntu-latest,
cmd: "apk --",
}
# iOS on Ubuntu
- { id: ios, target: aarch64-apple-ios, os: macos-latest }

Expand Down Expand Up @@ -85,18 +95,18 @@ jobs:

- name: Build with all features enabled
shell: bash
run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,tray,$FEATURES
run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES

- name: Build tests with all features enabled
shell: bash
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,tray,$FEATURES
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES

- name: Run tests with all features enabled
shell: bash
if: (
!contains(matrix.platform.target, 'android') &&
!contains(matrix.platform.target, 'ios'))
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,tray,$FEATURES
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES

test_tao_macros:
runs-on: ubuntu-latest
Expand Down
21 changes: 9 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.21.1"
description = "Cross-platform window manager library."
authors = [
"Tauri Programme within The Commons Conservancy",
"The winit contributors"
"The winit contributors",
]
edition = "2021"
rust-version = "1.56"
Expand All @@ -13,26 +13,25 @@ license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/tauri-apps/tao"
documentation = "https://docs.rs/tao"
categories = [ "gui" ]
categories = ["gui"]

[package.metadata.docs.rs]
features = [ "serde", "tray", "dox" ]
features = ["serde", "dox"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"i686-pc-windows-msvc",
"x86_64-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin"
"x86_64-apple-darwin",
]

[workspace]
members = [ "tao-macros" ]
members = ["tao-macros"]

[features]
default = [ ]
dox = [ "gtk/dox" ]
tray = [ "libappindicator", "dirs-next" ]
default = []
dox = ["gtk/dox"]

[build-dependencies]
cc = "1"
Expand All @@ -42,7 +41,7 @@ instant = "0.1"
lazy_static = "1"
libc = "0.2"
log = "0.4"
serde = { version = "1", optional = true, features = [ "serde_derive" ] }
serde = { version = "1", optional = true, features = ["serde_derive"] }
raw-window-handle = "0.5"
bitflags = "1"
crossbeam-channel = "0.5"
Expand Down Expand Up @@ -105,7 +104,7 @@ windows-implement = "0.48.0"
"Win32_UI_Input_Touch",
"Win32_UI_Shell",
"Win32_UI_TextServices",
"Win32_UI_WindowsAndMessaging"
"Win32_UI_WindowsAndMessaging",
]

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
Expand All @@ -119,8 +118,6 @@ gdk-sys = "0.16"
gdkx11-sys = "0.16"
gdkwayland-sys = "0.16.0"
gdk-pixbuf = "0.16"
libappindicator = { version = "0.8.0", optional = true }
dirs-next = { version = "2.0.0", optional = true }
x11-dl = "2.21"
zbus = "3"
uuid = { version = "1.3", features = [ "v4" ] }
Expand Down
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ Windows, macOS, Linux, iOS and Android. Built for you, maintained for Tauri.
TAO provides the following features, which can be enabled in your `Cargo.toml` file:

- `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).
- `tray`: Enables system tray and more menu item variants on **Linux**.
This feature requires either `libayatana-appindicator` or `libappindicator` package installed.
You can still create those types if you disable it. They just don't create the actual objects. We set this flag because some implementations require more installed packages.

## Platform-specific notes

Expand Down Expand Up @@ -55,30 +52,14 @@ Gtk and its related libraries are used to build the support of Linux. Be sure to
sudo pacman -S gtk3
```

For `tray` feature:

```bash
sudo pacman -S libappindicator-gtk3
```

#### Debian / Ubuntu:

```bash
sudo apt install libgtk-3-dev
```

For `tray` feature, choose one of following packages:

```bash
sudo apt install libappindicator3-dev
```

```bash
sudo apt install libayatana-appindicator3-dev
```

### Acknowledgement

This is a fork of [winit](https://crates.io/crates/winit) which replaces Linux's port to Gtk.
We need it not only because of webkit2gtk, but also a lot of Desktop Environment features like menu bar, system tray, global shortcuts etc.
We need it not only because of webkit2gtk, but also a lot of Desktop Environment features like menu bar, and tray icons.
In the future, we want to make these features more modular as separate crates. So we can switch back to winit and also benefit the whole community.
19 changes: 0 additions & 19 deletions build.rs

This file was deleted.

8 changes: 2 additions & 6 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# Examples

Run the `cargo run --example <file_name>` to see how each example works.

- `control_flow`: tell event loop what to do in the next iteration, after the current one's finished.
- `custom_events`: user can create custom events and emit or listen to them through tao.
- `fullscreen`: example for configuring different screen sizes, and video modes.
- `global_shortcut`: listen to hotkeys (shortcuts) stored in a hotkey manager.
- `handling_close`: close window with a warning.
- `request_redraw_threaded`: same as request_redraw but multithreaded.
- `request_redraw`: an event emitted when it's needed to redraw (when resizing window for example).
- `timer`: an example that makes a timer which suspend the thread for some time.
- `window_run_return`: similar to run function of EventLoop, but accept non-move closures and returns control flow to the caller when exit.
- `window_debug`: example that debugs with eprintln.


## Quite self-explainatory examples.
- `accelerator`: take hotkey as input.

- `cursor_grab`: prevent the cursor from going outside the window.
- `cursor`: set different cursor icons.
- `custom_menu`: user can create custom menu.
- `drag_window`: allow dragging window when hold left mouse and move.
- `min_max_size`: set smallest/largest window size you can zoom.
- `minimize`: minimize window.
Expand All @@ -32,5 +30,3 @@ Run the `cargo run --example <file_name>` to see how each example works.
- `video_modes`: example that lists all video modes of primary monitor
- `window_icon`: add window icon.
- `window`: example that makes a window.
- `system_tray`: add icon to your system tray, click icon to start.
- `system_tray_no_menu`: like system_tray, but no menu when right click icon.
55 changes: 0 additions & 55 deletions examples/accelerator.rs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/custom_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
env_logger::init();
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
event_loop::{ControlFlow, EventLoopBuilder},
window::WindowBuilder,
};

Expand All @@ -16,7 +16,7 @@ fn main() {
Timer,
}

let event_loop = EventLoop::<CustomEvent>::with_user_event();
let event_loop = EventLoopBuilder::<CustomEvent>::with_user_event().build();

let _window = WindowBuilder::new()
.with_title("A fantastic window!")
Expand Down
Loading