Skip to content

Commit

Permalink
Merge pull request #17 from ids1024/update-smithay
Browse files Browse the repository at this point in the history
Update for changes in `smithay`
  • Loading branch information
Drakulix committed Aug 21, 2024
2 parents cdc652e + f9033b6 commit 0d0b4ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ xkbcommon = "0.7"
[dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "74ef59a3f"
rev = "e27fd27ca"
default-features = false
features = ["renderer_glow", "wayland_frontend"]

Expand All @@ -40,6 +40,6 @@ tracing-subscriber = "0.3"
[dev-dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "74ef59a3f"
rev = "e27fd27ca"
default-features = false
features = ["backend_winit"]
25 changes: 14 additions & 11 deletions examples/integrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use smithay::{
pointer::{AxisFrame, ButtonEvent, MotionEvent},
SeatHandler, SeatState,
},
reexports::wayland_server::protocol::wl_surface::WlSurface,
utils::{Rectangle, Transform, SERIAL_COUNTER},
};
use smithay_egui::EguiState;
Expand All @@ -33,6 +34,7 @@ struct State(SeatState<State>);
impl SeatHandler for State {
type KeyboardFocus = EguiState;
type PointerFocus = EguiState;
type TouchFocus = WlSurface;
fn seat_state(&mut self) -> &mut SeatState<Self> {
&mut self.0
}
Expand All @@ -47,7 +49,7 @@ fn main() -> Result<()> {
// create an `EguiState`. Usually this would be part of your global smithay state
let egui = EguiState::new(Rectangle::from_loc_and_size(
(0, 0),
backend.window_size().physical_size.to_logical(1),
backend.window_size().to_logical(1),
));
// you might also need additional structs to store your ui-state, like the demo_lib does
let mut demo_ui = egui_demo_lib::DemoWindows::default();
Expand Down Expand Up @@ -95,7 +97,7 @@ fn main() -> Result<()> {
let pos = event.position();
pointer.motion(
&mut state,
Some((egui.clone(), (0, 0).into())),
Some((egui.clone(), (0., 0.).into())),
&MotionEvent {
location: (pos.x, pos.y).into(),
serial: SERIAL_COUNTER.next_serial(),
Expand All @@ -119,29 +121,29 @@ fn main() -> Result<()> {
InputEvent::PointerAxis { event } => {
let horizontal_amount =
event.amount(Axis::Horizontal).unwrap_or_else(|| {
event.amount_discrete(Axis::Horizontal).unwrap_or(0.0) * 3.0
event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 15.0 / 120.
});
let vertical_amount = event.amount(Axis::Vertical).unwrap_or_else(|| {
event.amount_discrete(Axis::Vertical).unwrap_or(0.0) * 3.0
event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 15.0 / 120.
});
let horizontal_amount_discrete = event.amount_discrete(Axis::Horizontal);
let vertical_amount_discrete = event.amount_discrete(Axis::Vertical);
let horizontal_amount_discrete = event.amount_v120(Axis::Horizontal);
let vertical_amount_discrete = event.amount_v120(Axis::Vertical);

{
let mut frame =
AxisFrame::new(event.time_msec()).source(event.source());
if horizontal_amount != 0.0 {
frame = frame.value(Axis::Horizontal, horizontal_amount);
if let Some(discrete) = horizontal_amount_discrete {
frame = frame.discrete(Axis::Horizontal, discrete as i32);
frame = frame.v120(Axis::Horizontal, discrete as i32);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Horizontal);
}
if vertical_amount != 0.0 {
frame = frame.value(Axis::Vertical, vertical_amount);
if let Some(discrete) = vertical_amount_discrete {
frame = frame.discrete(Axis::Vertical, discrete as i32);
frame = frame.v120(Axis::Vertical, discrete as i32);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Vertical);
Expand All @@ -153,9 +155,9 @@ fn main() -> Result<()> {
},
_ => {}
}
})?;
});

let size = backend.window_size().physical_size;
let size = backend.window_size();
// Here we compute the rendered egui frame
let egui_frame: TextureRenderElement<GlesTexture> = egui
.render(
Expand All @@ -175,7 +177,7 @@ fn main() -> Result<()> {
{
let mut frame = renderer.render(size, Transform::Flipped180)?;
frame.clear(
[1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0].into(),
&[Rectangle::from_loc_and_size((0, 0), size)],
)?;
RenderElement::<GlowRenderer>::draw(
Expand All @@ -184,6 +186,7 @@ fn main() -> Result<()> {
egui_frame.src(),
egui_frame.geometry(1.0.into()),
&[Rectangle::from_loc_and_size((0, 0), size)],
&[],
)?;
}
backend.submit(None)?;
Expand Down
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use smithay::{
input::keyboard::{Keysym as KeysymU32, ModifiersState},
};
use xkbcommon::xkb;
pub use xkbcommon::xkb::{keysyms, Keycode, Keysym};
pub use xkbcommon::xkb::{Keycode, Keysym};

use std::convert::TryFrom;

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl EguiState {
let physical_area = area.to_physical(int_scale);
{
let mut frame = renderer.render(physical_area.size, Transform::Normal)?;
frame.clear([0.0, 0.0, 0.0, 0.0], &[physical_area])?;
frame.clear([0.0, 0.0, 0.0, 0.0].into(), &[physical_area])?;
painter.paint_and_update_textures(
[physical_area.size.w as u32, physical_area.size.h as u32],
int_scale as f32,
Expand Down

0 comments on commit 0d0b4ca

Please sign in to comment.