server: clean unneeded deref_mut calls

This commit is contained in:
En-En 2025-08-06 18:24:27 +00:00 committed by Supreeeme
parent cbabd591a3
commit e0d1dad25a
2 changed files with 10 additions and 22 deletions

View file

@ -718,7 +718,6 @@ impl Event for client::wl_keyboard::Event {
impl Event for client::wl_touch::Event { impl Event for client::wl_touch::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
match self { match self {
Self::Down { Self::Down {
serial, serial,
@ -1034,7 +1033,7 @@ impl OutputEvent {
y, y,
state, state,
); );
let state = state.deref_mut(); let global_output_offset = state.global_output_offset;
let (output, dimensions, xdg) = state let (output, dimensions, xdg) = state
.world .world
@ -1044,8 +1043,8 @@ impl OutputEvent {
.unwrap(); .unwrap();
output.geometry( output.geometry(
x - state.global_output_offset.x.value, x - global_output_offset.x.value,
y - state.global_output_offset.y.value, y - global_output_offset.y.value,
physical_width, physical_width,
physical_height, physical_height,
convert_wenum(subpixel), convert_wenum(subpixel),
@ -1076,7 +1075,6 @@ impl OutputEvent {
height, height,
refresh, refresh,
} => { } => {
let state = state.deref_mut();
let (output, dimensions) = state let (output, dimensions) = state
.world .world
.query_one_mut::<(&WlOutput, &mut OutputDimensions)>(target) .query_one_mut::<(&WlOutput, &mut OutputDimensions)>(target)
@ -1093,7 +1091,6 @@ impl OutputEvent {
output.mode(convert_wenum(flags), width, height, refresh); output.mode(convert_wenum(flags), width, height, refresh);
} }
Event::Scale { factor } => { Event::Scale { factor } => {
let state = state.deref_mut();
debug!( debug!(
"{} scale: {factor}", "{} scale: {factor}",
state.world.get::<&WlOutput>(target).unwrap().id() state.world.get::<&WlOutput>(target).unwrap().id()
@ -1109,7 +1106,6 @@ impl OutputEvent {
} }
} }
Event::Name { name } => { Event::Name { name } => {
let state = state.deref_mut();
state state
.world .world
.get::<&WlOutput>(target) .get::<&WlOutput>(target)
@ -1137,7 +1133,6 @@ impl OutputEvent {
match event { match event {
Event::LogicalPosition { x, y } => { Event::LogicalPosition { x, y } => {
update_output_offset(target, OutputDimensionsSource::Xdg, x, y, state); update_output_offset(target, OutputDimensionsSource::Xdg, x, y, state);
let state = state.deref_mut();
state state
.world .world
.get::<&XdgOutputServer>(target) .get::<&XdgOutputServer>(target)
@ -1148,7 +1143,6 @@ impl OutputEvent {
); );
} }
Event::LogicalSize { .. } => { Event::LogicalSize { .. } => {
let state = state.deref_mut();
let (xdg, dimensions) = state let (xdg, dimensions) = state
.world .world
.query_one_mut::<(&XdgOutputServer, &OutputDimensions)>(target) .query_one_mut::<(&XdgOutputServer, &OutputDimensions)>(target)
@ -1249,7 +1243,6 @@ impl Event for zwp_confined_pointer_v1::Event {
impl Event for zwp_tablet_seat_v2::Event { impl Event for zwp_tablet_seat_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
let seat = state.world.get::<&TabletSeatServer>(target).unwrap(); let seat = state.world.get::<&TabletSeatServer>(target).unwrap();
match self { match self {
Self::TabletAdded { id } => { Self::TabletAdded { id } => {
@ -1292,7 +1285,6 @@ impl Event for zwp_tablet_v2::Event {
impl Event for zwp_tablet_pad_v2::Event { impl Event for zwp_tablet_pad_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
let pad = state.world.get::<&TabletPadServer>(target).unwrap(); let pad = state.world.get::<&TabletPadServer>(target).unwrap();
let s_surf; let s_surf;
match self { match self {
@ -1346,7 +1338,6 @@ impl Event for zwp_tablet_pad_v2::Event {
impl Event for zwp_tablet_tool_v2::Event { impl Event for zwp_tablet_tool_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
match self { match self {
Self::ProximityIn { Self::ProximityIn {
serial, serial,
@ -1447,7 +1438,6 @@ where
impl Event for zwp_tablet_pad_group_v2::Event { impl Event for zwp_tablet_pad_group_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
let group = state.world.get::<&TabletPadGroupServer>(target).unwrap(); let group = state.world.get::<&TabletPadGroupServer>(target).unwrap();
match self { match self {
Self::Buttons { buttons } => group.buttons(buttons), Self::Buttons { buttons } => group.buttons(buttons),
@ -1476,7 +1466,6 @@ impl Event for zwp_tablet_pad_group_v2::Event {
impl Event for zwp_tablet_pad_ring_v2::Event { impl Event for zwp_tablet_pad_ring_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
let ring = state.world.get::<&TabletPadRingServer>(target).unwrap(); let ring = state.world.get::<&TabletPadRingServer>(target).unwrap();
simple_event_shunt! { simple_event_shunt! {
ring, self => [ ring, self => [
@ -1491,7 +1480,6 @@ impl Event for zwp_tablet_pad_ring_v2::Event {
impl Event for zwp_tablet_pad_strip_v2::Event { impl Event for zwp_tablet_pad_strip_v2::Event {
fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) { fn handle<C: XConnection>(self, target: Entity, state: &mut ServerState<C>) {
let state = state.deref_mut();
let strip = state.world.get::<&TabletPadStripServer>(target).unwrap(); let strip = state.world.get::<&TabletPadStripServer>(target).unwrap();
simple_event_shunt! { simple_event_shunt! {
strip, self => [ strip, self => [

View file

@ -629,18 +629,17 @@ impl<C: XConnection> ServerState<C> {
} }
if !self.updated_outputs.is_empty() { if !self.updated_outputs.is_empty() {
let state = self.deref_mut(); for output in self.updated_outputs.iter() {
for output in state.updated_outputs.drain(..) { let output_scale = self.world.get::<&OutputScaleFactor>(*output).unwrap();
let output_scale = state.world.get::<&OutputScaleFactor>(output).unwrap();
if matches!(*output_scale, OutputScaleFactor::Output(..)) { if matches!(*output_scale, OutputScaleFactor::Output(..)) {
let mut surface_query = state let mut surface_query = self
.world .world
.query::<(&OnOutput, &mut SurfaceScaleFactor)>() .query::<(&OnOutput, &mut SurfaceScaleFactor)>()
.with::<(&WindowData, &WlSurface)>(); .with::<(&WindowData, &WlSurface)>();
let mut surfaces = vec![]; let mut surfaces = vec![];
for (surface, (OnOutput(s_output), surface_scale)) in surface_query.iter() { for (surface, (OnOutput(s_output), surface_scale)) in surface_query.iter() {
if *s_output == output { if s_output == output {
surface_scale.0 = output_scale.get(); surface_scale.0 = output_scale.get();
surfaces.push(surface); surfaces.push(surface);
} }
@ -648,10 +647,11 @@ impl<C: XConnection> ServerState<C> {
drop(surface_query); drop(surface_query);
for surface in surfaces { for surface in surfaces {
update_surface_viewport(state.world.query_one(surface).unwrap()); update_surface_viewport(self.world.query_one(surface).unwrap());
} }
} }
} }
self.updated_outputs.clear();
let mut mixed_scale = false; let mut mixed_scale = false;
let mut scale; let mut scale;
@ -1463,7 +1463,7 @@ impl ForeignSelection {
state: &ServerState<impl XConnection>, state: &ServerState<impl XConnection>,
) -> Vec<u8> { ) -> Vec<u8> {
let mut pipe = self.inner.receive(mime_type).unwrap(); let mut pipe = self.inner.receive(mime_type).unwrap();
state.inner.queue.flush().unwrap(); state.queue.flush().unwrap();
let mut data = Vec::new(); let mut data = Vec::new();
pipe.read_to_end(&mut data).unwrap(); pipe.read_to_end(&mut data).unwrap();
data data