mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-12 05:31:31 +11:00
Remove unused code in X11 backend. (#1416)
Signed-off-by: Freya Gentz <zegentzy@protonmail.com>
This commit is contained in:
parent
0ae78db6cb
commit
8856b6ecb7
|
@ -489,21 +489,9 @@ impl<'a> Deref for DeviceInfo<'a> {
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct WindowId(ffi::Window);
|
pub struct WindowId(ffi::Window);
|
||||||
|
|
||||||
impl WindowId {
|
|
||||||
pub unsafe fn dummy() -> Self {
|
|
||||||
WindowId(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DeviceId(c_int);
|
pub struct DeviceId(c_int);
|
||||||
|
|
||||||
impl DeviceId {
|
|
||||||
pub unsafe fn dummy() -> Self {
|
|
||||||
DeviceId(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Window(Arc<UnownedWindow>);
|
pub struct Window(Arc<UnownedWindow>);
|
||||||
|
|
||||||
impl Deref for Window {
|
impl Deref for Window {
|
||||||
|
|
|
@ -43,62 +43,4 @@ impl XConnection {
|
||||||
};
|
};
|
||||||
self.send_event(target_window, event_mask, event)
|
self.send_event(target_window, event_mask, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare yourself for the ultimate in unsafety!
|
|
||||||
// You should favor `send_client_msg` whenever possible, but some protocols (i.e. startup notification) require you
|
|
||||||
// to send more than one message worth of data.
|
|
||||||
pub fn send_client_msg_multi<T: Formattable>(
|
|
||||||
&self,
|
|
||||||
window: c_ulong, // The window this is "about"; not necessarily this window
|
|
||||||
target_window: c_ulong, // The window we're sending to
|
|
||||||
message_type: ffi::Atom,
|
|
||||||
event_mask: Option<c_long>,
|
|
||||||
data: &[T],
|
|
||||||
) -> Flusher<'_> {
|
|
||||||
let format = T::FORMAT;
|
|
||||||
let size_of_t = mem::size_of::<T>();
|
|
||||||
debug_assert_eq!(size_of_t, format.get_actual_size());
|
|
||||||
let mut event = ffi::XClientMessageEvent {
|
|
||||||
type_: ffi::ClientMessage,
|
|
||||||
display: self.display,
|
|
||||||
window,
|
|
||||||
message_type,
|
|
||||||
format: format as c_int,
|
|
||||||
data: ffi::ClientMessageData::new(),
|
|
||||||
// These fields are ignored by `XSendEvent`
|
|
||||||
serial: 0,
|
|
||||||
send_event: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
let t_per_payload = format.get_payload_size() / size_of_t;
|
|
||||||
assert!(t_per_payload > 0);
|
|
||||||
let payload_count = data.len() / t_per_payload;
|
|
||||||
let payload_remainder = data.len() % t_per_payload;
|
|
||||||
let payload_ptr = data.as_ptr() as *const ClientMsgPayload;
|
|
||||||
|
|
||||||
let mut payload_index = 0;
|
|
||||||
while payload_index < payload_count {
|
|
||||||
let payload = unsafe { payload_ptr.offset(payload_index as isize) };
|
|
||||||
payload_index += 1;
|
|
||||||
event.data = unsafe { mem::transmute(*payload) };
|
|
||||||
self.send_event(target_window, event_mask, &event).queue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if payload_remainder > 0 {
|
|
||||||
let mut payload: ClientMsgPayload = [0; 5];
|
|
||||||
let t_payload = payload.as_mut_ptr() as *mut T;
|
|
||||||
let invalid_payload = unsafe { payload_ptr.offset(payload_index as isize) };
|
|
||||||
let invalid_t_payload = invalid_payload as *const T;
|
|
||||||
let mut t_index = 0;
|
|
||||||
while t_index < payload_remainder {
|
|
||||||
let valid_t = unsafe { invalid_t_payload.offset(t_index as isize) };
|
|
||||||
unsafe { (*t_payload.offset(t_index as isize)) = (*valid_t).clone() };
|
|
||||||
t_index += 1;
|
|
||||||
}
|
|
||||||
event.data = unsafe { mem::transmute(payload) };
|
|
||||||
self.send_event(target_window, event_mask, &event).queue();
|
|
||||||
}
|
|
||||||
|
|
||||||
Flusher::new(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,6 @@ impl Format {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_same_size_as<T>(&self) -> bool {
|
|
||||||
mem::size_of::<T>() == self.get_actual_size()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_actual_size(&self) -> usize {
|
pub fn get_actual_size(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
&Format::Char => mem::size_of::<c_char>(),
|
&Format::Char => mem::size_of::<c_char>(),
|
||||||
|
@ -32,15 +28,6 @@ impl Format {
|
||||||
&Format::Long => mem::size_of::<c_long>(),
|
&Format::Long => mem::size_of::<c_long>(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_payload_size(&self) -> usize {
|
|
||||||
match self {
|
|
||||||
// Due to the wonders of X11, half the space goes unused if you're not using longs (on 64-bit).
|
|
||||||
&Format::Char => mem::size_of::<c_char>() * 20,
|
|
||||||
&Format::Short => mem::size_of::<c_short>() * 10,
|
|
||||||
&Format::Long => mem::size_of::<c_long>() * 5,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Formattable: Debug + Clone + Copy + PartialEq + PartialOrd {
|
pub trait Formattable: Debug + Clone + Copy + PartialEq + PartialOrd {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::dpi::{LogicalPosition, LogicalSize};
|
|
||||||
|
|
||||||
// Friendly neighborhood axis-aligned rectangle
|
// Friendly neighborhood axis-aligned rectangle
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -89,16 +88,6 @@ impl FrameExtents {
|
||||||
pub fn from_border(border: c_ulong) -> Self {
|
pub fn from_border(border: c_ulong) -> Self {
|
||||||
Self::new(border, border, border, border)
|
Self::new(border, border, border, border)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_logical(&self, factor: f64) -> LogicalFrameExtents {
|
|
||||||
let logicalize = |value: c_ulong| value as f64 / factor;
|
|
||||||
LogicalFrameExtents {
|
|
||||||
left: logicalize(self.left),
|
|
||||||
right: logicalize(self.right),
|
|
||||||
top: logicalize(self.top),
|
|
||||||
bottom: logicalize(self.bottom),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -135,20 +124,6 @@ impl FrameExtentsHeuristic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_pos_to_outer_logical(
|
|
||||||
&self,
|
|
||||||
mut logical: LogicalPosition<f64>,
|
|
||||||
factor: f64,
|
|
||||||
) -> LogicalPosition<f64> {
|
|
||||||
use self::FrameExtentsHeuristicPath::*;
|
|
||||||
if self.heuristic_path != UnsupportedBordered {
|
|
||||||
let frame_extents = self.frame_extents.as_logical(factor);
|
|
||||||
logical.x -= frame_extents.left;
|
|
||||||
logical.y -= frame_extents.top;
|
|
||||||
}
|
|
||||||
logical
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inner_size_to_outer(&self, width: u32, height: u32) -> (u32, u32) {
|
pub fn inner_size_to_outer(&self, width: u32, height: u32) -> (u32, u32) {
|
||||||
(
|
(
|
||||||
width.saturating_add(
|
width.saturating_add(
|
||||||
|
@ -163,17 +138,6 @@ impl FrameExtentsHeuristic {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_size_to_outer_logical(
|
|
||||||
&self,
|
|
||||||
mut logical: LogicalSize<f64>,
|
|
||||||
factor: f64,
|
|
||||||
) -> LogicalSize<f64> {
|
|
||||||
let frame_extents = self.frame_extents.as_logical(factor);
|
|
||||||
logical.width += frame_extents.left + frame_extents.right;
|
|
||||||
logical.height += frame_extents.top + frame_extents.bottom;
|
|
||||||
logical
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XConnection {
|
impl XConnection {
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::sync::Arc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum StateOperation {
|
pub enum StateOperation {
|
||||||
Remove = 0, // _NET_WM_STATE_REMOVE
|
Remove = 0, // _NET_WM_STATE_REMOVE
|
||||||
Add = 1, // _NET_WM_STATE_ADD
|
Add = 1, // _NET_WM_STATE_ADD
|
||||||
|
@ -189,22 +190,6 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_flag(&self, flag: c_long) -> bool {
|
|
||||||
has_flag(self.size_hints.flags, flag)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn getter(&self, flag: c_long, field1: &c_int, field2: &c_int) -> Option<(u32, u32)> {
|
|
||||||
if self.has_flag(flag) {
|
|
||||||
Some((*field1 as _, *field2 as _))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_size(&self) -> Option<(u32, u32)> {
|
|
||||||
self.getter(ffi::PSize, &self.size_hints.width, &self.size_hints.height)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WARNING: This hint is obsolete
|
// WARNING: This hint is obsolete
|
||||||
pub fn set_size(&mut self, size: Option<(u32, u32)>) {
|
pub fn set_size(&mut self, size: Option<(u32, u32)>) {
|
||||||
if let Some((width, height)) = size {
|
if let Some((width, height)) = size {
|
||||||
|
@ -216,14 +201,6 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_max_size(&self) -> Option<(u32, u32)> {
|
|
||||||
self.getter(
|
|
||||||
ffi::PMaxSize,
|
|
||||||
&self.size_hints.max_width,
|
|
||||||
&self.size_hints.max_height,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_max_size(&mut self, max_size: Option<(u32, u32)>) {
|
pub fn set_max_size(&mut self, max_size: Option<(u32, u32)>) {
|
||||||
if let Some((max_width, max_height)) = max_size {
|
if let Some((max_width, max_height)) = max_size {
|
||||||
self.size_hints.flags |= ffi::PMaxSize;
|
self.size_hints.flags |= ffi::PMaxSize;
|
||||||
|
@ -234,14 +211,6 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_min_size(&self) -> Option<(u32, u32)> {
|
|
||||||
self.getter(
|
|
||||||
ffi::PMinSize,
|
|
||||||
&self.size_hints.min_width,
|
|
||||||
&self.size_hints.min_height,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_min_size(&mut self, min_size: Option<(u32, u32)>) {
|
pub fn set_min_size(&mut self, min_size: Option<(u32, u32)>) {
|
||||||
if let Some((min_width, min_height)) = min_size {
|
if let Some((min_width, min_height)) = min_size {
|
||||||
self.size_hints.flags |= ffi::PMinSize;
|
self.size_hints.flags |= ffi::PMinSize;
|
||||||
|
@ -252,14 +221,6 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_resize_increments(&self) -> Option<(u32, u32)> {
|
|
||||||
self.getter(
|
|
||||||
ffi::PResizeInc,
|
|
||||||
&self.size_hints.width_inc,
|
|
||||||
&self.size_hints.height_inc,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_resize_increments(&mut self, resize_increments: Option<(u32, u32)>) {
|
pub fn set_resize_increments(&mut self, resize_increments: Option<(u32, u32)>) {
|
||||||
if let Some((width_inc, height_inc)) = resize_increments {
|
if let Some((width_inc, height_inc)) = resize_increments {
|
||||||
self.size_hints.flags |= ffi::PResizeInc;
|
self.size_hints.flags |= ffi::PResizeInc;
|
||||||
|
@ -270,14 +231,6 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_base_size(&self) -> Option<(u32, u32)> {
|
|
||||||
self.getter(
|
|
||||||
ffi::PBaseSize,
|
|
||||||
&self.size_hints.base_width,
|
|
||||||
&self.size_hints.base_height,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_base_size(&mut self, base_size: Option<(u32, u32)>) {
|
pub fn set_base_size(&mut self, base_size: Option<(u32, u32)>) {
|
||||||
if let Some((base_width, base_height)) = base_size {
|
if let Some((base_width, base_height)) = base_size {
|
||||||
self.size_hints.flags |= ffi::PBaseSize;
|
self.size_hints.flags |= ffi::PBaseSize;
|
||||||
|
|
|
@ -23,18 +23,12 @@ pub use self::{
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
mem::{self, MaybeUninit},
|
mem::{self, MaybeUninit},
|
||||||
ops::BitAnd,
|
|
||||||
os::raw::*,
|
os::raw::*,
|
||||||
ptr,
|
ptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{ffi, XConnection, XError};
|
use super::{ffi, XConnection, XError};
|
||||||
|
|
||||||
pub fn reinterpret<'a, A, B>(a: &'a A) -> &'a B {
|
|
||||||
let b_ptr = a as *const _ as *const B;
|
|
||||||
unsafe { &*b_ptr }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn maybe_change<T: PartialEq>(field: &mut Option<T>, value: T) -> bool {
|
pub fn maybe_change<T: PartialEq>(field: &mut Option<T>, value: T) -> bool {
|
||||||
let wrapped = Some(value);
|
let wrapped = Some(value);
|
||||||
if *field != wrapped {
|
if *field != wrapped {
|
||||||
|
@ -45,13 +39,6 @@ pub fn maybe_change<T: PartialEq>(field: &mut Option<T>, value: T) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_flag<T>(bitset: T, flag: T) -> bool
|
|
||||||
where
|
|
||||||
T: Copy + PartialEq + BitAnd<T, Output = T>,
|
|
||||||
{
|
|
||||||
bitset & flag == flag
|
|
||||||
}
|
|
||||||
|
|
||||||
#[must_use = "This request was made asynchronously, and is still in the output buffer. You must explicitly choose to either `.flush()` (empty the output buffer, sending the request now) or `.queue()` (wait to send the request, allowing you to continue to add more requests without additional round-trips). For more information, see the documentation for `util::flush_requests`."]
|
#[must_use = "This request was made asynchronously, and is still in the output buffer. You must explicitly choose to either `.flush()` (empty the output buffer, sending the request now) or `.queue()` (wait to send the request, allowing you to continue to add more requests without additional round-trips). For more information, see the documentation for `util::flush_requests`."]
|
||||||
pub struct Flusher<'a> {
|
pub struct Flusher<'a> {
|
||||||
xconn: &'a XConnection,
|
xconn: &'a XConnection,
|
||||||
|
|
|
@ -26,6 +26,7 @@ impl GetPropertyError {
|
||||||
const PROPERTY_BUFFER_SIZE: c_long = 1024; // 4k of RAM ought to be enough for anyone!
|
const PROPERTY_BUFFER_SIZE: c_long = 1024; // 4k of RAM ought to be enough for anyone!
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum PropMode {
|
pub enum PropMode {
|
||||||
Replace = ffi::PropModeReplace as isize,
|
Replace = ffi::PropModeReplace as isize,
|
||||||
Prepend = ffi::PropModePrepend as isize,
|
Prepend = ffi::PropModePrepend as isize,
|
||||||
|
|
Loading…
Reference in a new issue