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

Upgrade smithay-client-toolkit 0.17 #4777

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2f74847
Nuke Wayland
tzx Jan 4, 2024
a3190db
Connections compile without complaining; time for window
tzx Jan 4, 2024
610ca9c
Compiles after nuking connection and window
tzx Jan 4, 2024
eca7bf4
Wow a message loop, but it does nothing...
tzx Jan 4, 2024
e1fd45f
No termination
tzx Jan 4, 2024
552d8dd
Implement the epoll stuff
tzx Jan 4, 2024
966c347
Window progress: no WindowInner though
tzx Jan 4, 2024
5d1ac89
WaylandWindowInner
tzx Jan 4, 2024
4adb02f
No more todos! but I don't see a window
tzx Jan 5, 2024
3f803ef
Don't block ReadGuard after getting fd -> segfaulting webgpu
tzx Jan 5, 2024
6f6c183
Attempt on Implementing EGL for windows
tzx Jan 5, 2024
4025257
Trying to debug why WSurface has no good object id
tzx Jan 5, 2024
f54bb35
Save the window: no more segfault + wgpu works too
tzx Jan 5, 2024
c3b78fd
I give up :sob:, it's not worth my time
tzx Jan 5, 2024
e6bdfe4
Have user data associated with a surface
tzx Jan 6, 2024
c4d64bb
Implement handling window configuration
tzx Jan 7, 2024
1a2d3ea
Handle panics after handling window configuration
tzx Jan 7, 2024
671931a
Implement do_paint -> renders window and then panics at frame()
tzx Jan 7, 2024
4db59e6
A window renders now
tzx Jan 7, 2024
f31274d
Need to look into window frames
tzx Jan 7, 2024
413f8c5
Implement most of dispatch pending_event
tzx Jan 8, 2024
a24c1ff
Fix delegate dispatch for SurfaceUserData
tzx Jan 8, 2024
3a5f388
Implement getting screens
tzx Jan 8, 2024
4b7dd42
Handle scale factor changes: do nothing
tzx Jan 8, 2024
bf61ea6
Handle window close -> no more crashes
tzx Jan 8, 2024
6c0f7e9
Store OutputState, CompositorState, XdgShell in WaylandState instead …
tzx Jan 8, 2024
6dc6920
Wayland refactor: Put handlers for windows in windows.rs, and separat…
tzx Jan 9, 2024
c2c8d24
Refactor windows to WaylandState
tzx Jan 10, 2024
85bb37b
Implement pressing a key
tzx Jan 10, 2024
3e55fe6
Implement enter + emit_focus -> need to impl keymap
tzx Jan 10, 2024
c278e4d
Implement adding keymap
tzx Jan 10, 2024
3b693a9
Ignore cursor handling for now
tzx Jan 10, 2024
96bda97
Use raw_code for process_wayland_key instead of keysym
tzx Jan 10, 2024
6f24a6c
Don't use xkbcommon feature in smithay so we can use modifiers
tzx Jan 11, 2024
bbfefb3
Nuke pointer
tzx Jan 12, 2024
20af052
Starting pointer implementation
tzx Jan 19, 2024
73db71c
Mouse seems to do something, but it is incorrect
tzx Jan 20, 2024
943796c
Implement forgotten PointerEventKind::Release, mouse features seem to…
tzx Jan 20, 2024
cef845d
Theme the pointer
tzx Jan 20, 2024
92f0f59
Implement copying, pasting does not work
tzx Jan 22, 2024
9327a5e
Implement paste
tzx Jan 22, 2024
e356d54
Implement dispatch_dropped_files
tzx Jan 22, 2024
55b58ee
Ignore drag source handlers (we don't drag from wezterm)
tzx Jan 22, 2024
41237cd
Start IME support
tzx Jan 23, 2024
2652394
Implement inputhandler
tzx Jan 23, 2024
312a528
Implement shutdown for ime
tzx Jan 23, 2024
2a6e6ab
Implement wlr-output-management-unstable
tzx Jan 24, 2024
508169e
Fix making wlr-output-management-unstable optional
tzx Jan 24, 2024
660639b
Implement primary selection support
tzx Jan 24, 2024
7ffdab3
Handle crash when using software/opengl due to active_surface_id
tzx Jan 25, 2024
29f1d08
Make IME support optional since not all compositors support it
tzx Jan 26, 2024
cc6ae70
Initial window frame
tzx Jan 27, 2024
168af9b
Implement working frame actions
tzx Jan 27, 2024
5609eaf
Resize window frame correctly
tzx Jan 27, 2024
837aef4
Don't hardcode egl sizes
tzx Jan 27, 2024
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
Prev Previous commit
Next Next commit
Attempt on Implementing EGL for windows
- wgpu gives segfault so move to EGL
- implement terminating message loop to match prev implementation
- still gives error but no segfault or panic right now
  • Loading branch information
tzx committed Jan 5, 2024
commit 6f6c183ca8d3874bf3d62ecaa02303f37392dd9d
14 changes: 11 additions & 3 deletions window/src/os/wayland/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct WaylandConnection {
pub(crate) next_window_id: AtomicUsize,
pub(crate) windows: RefCell<HashMap<usize, Rc<RefCell<WaylandWindowInner>>>>,

pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>,

pub(crate) connection: RefCell<Connection>,
pub(crate) event_queue: RefCell<EventQueue<WaylandState>>,
pub(crate) globals: RefCell<GlobalList>,
Expand All @@ -54,6 +56,7 @@ impl WaylandConnection {
connection: RefCell::new(conn),
should_terminate: RefCell::new(false),
next_window_id: AtomicUsize::new(1),
gl_connection: RefCell::new(None),
windows: RefCell::new(HashMap::default()),

event_queue: RefCell::new(event_queue),
Expand Down Expand Up @@ -246,12 +249,17 @@ impl ConnectionOps for WaylandConnection {
}

fn terminate_message_loop(&self) {
todo!()
log::trace!("Terminating Message Loop");
*self.should_terminate.borrow_mut() = true;
}

fn run_message_loop(&self) -> anyhow::Result<()> {
// TODO: match
self.run_message_loop_impl()
let res = self.run_message_loop_impl();
// Ensure that we drop these eagerly, to avoid
// noisy errors wrt. global destructors unwinding
// in unexpected places
self.windows.borrow_mut().clear();
res
}

fn screens(&self) -> anyhow::Result<crate::screen::Screens> {
Expand Down
87 changes: 68 additions & 19 deletions window/src/os/wayland/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::Arc;
use std::sync::Mutex;

use anyhow::anyhow;
use async_trait::async_trait;
use config::configuration;
use config::ConfigHandle;
use promise::Future;
Expand All @@ -26,7 +27,7 @@ use smithay_client_toolkit::shell::WaylandSurface;
use wayland_client::globals::GlobalList;
use wayland_client::protocol::wl_surface::WlSurface;
use wayland_client::Proxy;
use wayland_egl::WlEglSurface;
use wayland_egl::{is_available as egl_is_available, WlEglSurface};
use wezterm_font::FontConfiguration;
use wezterm_input_types::KeyboardLedStatus;
use wezterm_input_types::Modifiers;
Expand Down Expand Up @@ -118,6 +119,9 @@ impl WaylandWindow {
let inner = Rc::new(RefCell::new(WaylandWindowInner {
events: WindowEventSender::new(event_handler),
surface,

wegl_surface: None,
gl_state: None,
}));

let window_handle = Window::Wayland(WaylandWindow(window_id));
Expand Down Expand Up @@ -147,6 +151,7 @@ impl WaylandWindow {
}
}

#[async_trait(?Send)]
impl WindowOps for WaylandWindow {
#[doc = r" Show a hidden window"]
fn show(&self) {
Expand All @@ -160,22 +165,17 @@ impl WindowOps for WaylandWindow {
todo!()
}

#[doc = r" Setup opengl for rendering"]
#[must_use]
#[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)]
fn enable_opengl<'life0, 'async_trait>(
&'life0 self,
) -> ::core::pin::Pin<
Box<
dyn ::core::future::Future<Output = anyhow::Result<Rc<glium::backend::Context>>>
+ 'async_trait,
>,
>
where
'life0: 'async_trait,
Self: 'async_trait,
{
todo!()
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
let window = self.0;
promise::spawn::spawn(async move {
if let Some(handle) = Connection::get().unwrap().wayland().window_by_id(window) {
let mut inner = handle.borrow_mut();
inner.enable_opengl()
} else {
anyhow::bail!("invalid window");
}
})
.await
}

#[doc = r" Hide a visible window"]
Expand Down Expand Up @@ -283,8 +283,57 @@ pub struct WaylandWindowInner {
// // wegl_surface is listed before gl_state because it
// // must be dropped before gl_state otherwise the underlying
// // libraries will segfault on shutdown
// wegl_surface: Option<WlEglSurface>,
// gl_state: Option<Rc<glium::backend::Context>>,
wegl_surface: Option<WlEglSurface>,
gl_state: Option<Rc<glium::backend::Context>>,
}

impl WaylandWindowInner {
fn enable_opengl(&mut self) -> anyhow::Result<Rc<glium::backend::Context>> {
let wayland_conn = Connection::get().unwrap().wayland();
let mut wegl_surface = None;

let gl_state = if !egl_is_available() {
Err(anyhow!("!egl_is_available"))
} else {
wegl_surface = Some(WlEglSurface::new(
self.surface.id(),
// TODO: remove the hardcoded stuff
100,
100,
)?);

match wayland_conn.gl_connection.borrow().as_ref() {
Some(glconn) => crate::egl::GlState::create_wayland_with_existing_connection(
glconn,
wegl_surface.as_ref().unwrap(),
),
None => crate::egl::GlState::create_wayland(
Some(wayland_conn.connection.borrow().backend().display_ptr() as *const _),
wegl_surface.as_ref().unwrap(),
),
}
};
let gl_state = gl_state.map(Rc::new).and_then(|state| unsafe {
wayland_conn
.gl_connection
.borrow_mut()
.replace(Rc::clone(state.get_connection()));
Ok(glium::backend::Context::new(
Rc::clone(&state),
true,
if cfg!(debug_assertions) {
glium::debug::DebugCallbackBehavior::DebugMessageOnError
} else {
glium::debug::DebugCallbackBehavior::Ignore
},
)?)
})?;

self.gl_state.replace(gl_state.clone());
self.wegl_surface = wegl_surface;

Ok(gl_state)
}
}

unsafe impl HasRawDisplayHandle for WaylandWindowInner {
Expand Down