autocommit 2022-03-23 16:23:28 CET
This commit is contained in:
parent
d7f298ab5f
commit
a9a4fc04b7
13 changed files with 91 additions and 70 deletions
48
Cargo.lock
generated
48
Cargo.lock
generated
|
|
@ -39,9 +39,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.53"
|
||||
version = "1.0.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
|
||||
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
|
|
@ -105,9 +105,7 @@ version = "0.2.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -118,9 +116,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
|
@ -208,9 +206,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
||||
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
|
|
@ -290,9 +288,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.117"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
|
|
@ -306,9 +304,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
|
@ -370,9 +368,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
|
|
@ -423,9 +421,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
|
@ -462,21 +460,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
version = "1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
|
|
@ -518,9 +510,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.86"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
|
||||
checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -529,9 +521,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ num-traits = "0.2.14"
|
|||
num-derive = "0.3.3"
|
||||
bitflags = "1.3.2"
|
||||
libloading = "0.7.2"
|
||||
bstr = "0.2.17"
|
||||
bstr = { version = "0.2.17", default-features = false, features = ["std"] }
|
||||
isnt = "0.1.0"
|
||||
once_cell = "1.9.0"
|
||||
rand = "0.8.4"
|
||||
|
|
@ -40,7 +40,7 @@ pin-project = "1.0.10"
|
|||
[build-dependencies]
|
||||
repc = "0.1.1"
|
||||
anyhow = "1.0.52"
|
||||
bstr = "0.2.17"
|
||||
bstr = { version = "0.2.17", default-features = false, features = ["std"] }
|
||||
|
||||
#[profile.dev.build-override]
|
||||
#opt-level = 3
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::drm::drm::{
|
|||
};
|
||||
use crate::utils::bitflags::BitflagsExt;
|
||||
use crate::utils::oserror::OsError;
|
||||
use crate::utils::trim::AsciiTrim;
|
||||
use ahash::AHashMap;
|
||||
use bstr::ByteSlice;
|
||||
use std::ffi::CString;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use crate::libinput::sys::{
|
|||
use crate::udev::UdevError;
|
||||
use crate::utils::oserror::OsError;
|
||||
use crate::utils::ptr_ext::PtrExt;
|
||||
use crate::utils::trim::AsciiTrim;
|
||||
use crate::utils::vasprintf::vasprintf_;
|
||||
use crate::ErrorFmt;
|
||||
use bstr::ByteSlice;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ mod ifs;
|
|||
mod libinput;
|
||||
mod logind;
|
||||
mod object;
|
||||
mod pango;
|
||||
mod pixman;
|
||||
mod rect;
|
||||
mod render;
|
||||
|
|
@ -99,7 +100,6 @@ mod wire_xcon;
|
|||
mod xcon;
|
||||
mod xkbcommon;
|
||||
mod xwayland;
|
||||
mod pango;
|
||||
|
||||
fn main() {
|
||||
env_logger::builder()
|
||||
|
|
|
|||
45
src/pango.rs
45
src/pango.rs
|
|
@ -1,17 +1,17 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
|
||||
use crate::pango::consts::{CairoFormat, CairoOperator, PangoEllipsizeMode};
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, IntoUstr};
|
||||
use crate::pango::consts::{CairoFormat, CairoOperator, PangoEllipsizeMode};
|
||||
|
||||
pub mod consts;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/pango_tys.rs"));
|
||||
|
||||
#[link(name = "cairo")]
|
||||
extern {
|
||||
extern "C" {
|
||||
type cairo_surface_t;
|
||||
type cairo_t;
|
||||
|
||||
|
|
@ -33,18 +33,12 @@ extern {
|
|||
fn cairo_destroy(cairo: *mut cairo_t);
|
||||
|
||||
fn cairo_set_operator(cr: *mut cairo_t, op: cairo_operator_t);
|
||||
fn cairo_set_source_rgba(
|
||||
cr: *mut cairo_t,
|
||||
red: f64,
|
||||
green: f64,
|
||||
blue: f64,
|
||||
alpha: f64,
|
||||
);
|
||||
fn cairo_set_source_rgba(cr: *mut cairo_t, red: f64, green: f64, blue: f64, alpha: f64);
|
||||
fn cairo_move_to(cr: *mut cairo_t, x: f64, y: f64);
|
||||
}
|
||||
|
||||
#[link(name = "pangocairo-1.0")]
|
||||
extern {
|
||||
extern "C" {
|
||||
type PangoContext_;
|
||||
|
||||
fn pango_cairo_create_context(cr: *mut cairo_t) -> *mut PangoContext_;
|
||||
|
|
@ -52,14 +46,14 @@ extern {
|
|||
}
|
||||
|
||||
#[link(name = "gobject-2.0")]
|
||||
extern {
|
||||
extern "C" {
|
||||
type GObject;
|
||||
|
||||
fn g_object_unref(object: *mut GObject);
|
||||
}
|
||||
|
||||
#[link(name = "pango-1.0")]
|
||||
extern {
|
||||
extern "C" {
|
||||
type PangoFontDescription_;
|
||||
type PangoLayout_;
|
||||
|
||||
|
|
@ -100,16 +94,18 @@ pub struct CairoImageSurface {
|
|||
}
|
||||
|
||||
impl CairoImageSurface {
|
||||
pub fn new_image_surface(format: CairoFormat, width: i32, height: i32) -> Result<Rc<Self>, PangoError> {
|
||||
pub fn new_image_surface(
|
||||
format: CairoFormat,
|
||||
width: i32,
|
||||
height: i32,
|
||||
) -> Result<Rc<Self>, PangoError> {
|
||||
unsafe {
|
||||
let s = cairo_image_surface_create(format.raw() as _, width as _, height as _);
|
||||
let status = cairo_surface_status(s);
|
||||
if status != 0 {
|
||||
return Err(PangoError::CreateSurface(status as _));
|
||||
}
|
||||
Ok(Rc::new(Self {
|
||||
s,
|
||||
}))
|
||||
Ok(Rc::new(Self { s }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,15 +130,11 @@ impl CairoImageSurface {
|
|||
}
|
||||
|
||||
pub fn height(&self) -> i32 {
|
||||
unsafe {
|
||||
cairo_image_surface_get_height(self.s) as _
|
||||
}
|
||||
unsafe { cairo_image_surface_get_height(self.s) as _ }
|
||||
}
|
||||
|
||||
pub fn stride(&self) -> i32 {
|
||||
unsafe {
|
||||
cairo_image_surface_get_stride(self.s) as _
|
||||
}
|
||||
unsafe { cairo_image_surface_get_stride(self.s) as _ }
|
||||
}
|
||||
|
||||
pub fn data(&self) -> Result<&[Cell<u8>], PangoError> {
|
||||
|
|
@ -177,10 +169,7 @@ impl CairoContext {
|
|||
if p.is_null() {
|
||||
return Err(PangoError::CreatePangoCairo);
|
||||
}
|
||||
Ok(Rc::new(PangoCairoContext {
|
||||
c: self.clone(),
|
||||
p,
|
||||
}))
|
||||
Ok(Rc::new(PangoCairoContext { c: self.clone(), p }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +236,7 @@ impl PangoFontDescription {
|
|||
pub fn from_string<'a>(s: impl IntoUstr<'a>) -> Self {
|
||||
let s = s.into_ustr();
|
||||
Self {
|
||||
s: unsafe {
|
||||
pango_font_description_from_string(s.as_ptr())
|
||||
},
|
||||
s: unsafe { pango_font_description_from_string(s.as_ptr()) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::render::egl::sys::{eglQueryString, EGLDeviceEXT, EGLDisplay, EGL_EXTENSIONS};
|
||||
use crate::render::egl::PROCS;
|
||||
use crate::render::gl::sys::{glGetString, GL_EXTENSIONS};
|
||||
use crate::utils::trim::AsciiTrim;
|
||||
use ahash::AHashSet;
|
||||
use bstr::ByteSlice;
|
||||
use std::ffi::CStr;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
use crate::format::ARGB8888;
|
||||
use crate::pango::consts::{
|
||||
CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE,
|
||||
};
|
||||
use crate::pango::{CairoImageSurface, PangoError, PangoFontDescription};
|
||||
use crate::render::{RenderContext, Texture};
|
||||
use crate::theme::Color;
|
||||
use crate::RenderError;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::pango::{CairoImageSurface, PangoError, PangoFontDescription};
|
||||
use crate::pango::consts::{CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum TextError {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub mod smallmap;
|
|||
pub mod stack;
|
||||
pub mod syncqueue;
|
||||
pub mod tri;
|
||||
pub mod trim;
|
||||
pub mod vasprintf;
|
||||
pub mod vec_ext;
|
||||
pub mod vecstorage;
|
||||
|
|
|
|||
33
src/utils/trim.rs
Normal file
33
src/utils/trim.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
pub trait AsciiTrim {
|
||||
fn trim(&self) -> &[u8];
|
||||
fn trim_start(&self) -> &[u8];
|
||||
fn trim_end(&self) -> &[u8];
|
||||
}
|
||||
|
||||
impl AsciiTrim for [u8] {
|
||||
fn trim(&self) -> &[u8] {
|
||||
self.trim_start().trim_end()
|
||||
}
|
||||
|
||||
fn trim_start(&self) -> &[u8] {
|
||||
let mut s = self;
|
||||
while let Some((b, r)) = s.split_first() {
|
||||
if !matches!(*b, b' ' | b'\t' | b'\n') {
|
||||
break;
|
||||
}
|
||||
s = r;
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
fn trim_end(&self) -> &[u8] {
|
||||
let mut s = self;
|
||||
while let Some((b, r)) = s.split_last() {
|
||||
if !matches!(*b, b' ' | b'\t' | b'\n') {
|
||||
break;
|
||||
}
|
||||
s = r;
|
||||
}
|
||||
s
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ use std::ptr;
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::utils::ptr_ext::PtrExt;
|
||||
use crate::utils::trim::AsciiTrim;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use crate::client::ClientError;
|
|||
use crate::forker::ForkerProxy;
|
||||
use crate::ifs::wl_surface::xwindow::Xwindow;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::utils::oserror::OsError;
|
||||
use crate::utils::tri::Try;
|
||||
use crate::wire::WlSurfaceId;
|
||||
use crate::xcon::XconError;
|
||||
|
|
@ -16,7 +17,6 @@ use std::num::ParseIntError;
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, pipe2, Errno, OwnedFd};
|
||||
use crate::utils::oserror::OsError;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum XWaylandError {
|
||||
|
|
@ -128,7 +128,11 @@ async fn run(
|
|||
Ok(p) => p,
|
||||
Err(e) => return Err(XWaylandError::Pipe(e.into())),
|
||||
};
|
||||
let wm = uapi::socketpair(c::AF_UNIX, c::SOCK_STREAM | c::SOCK_CLOEXEC | c::SOCK_NONBLOCK, 0);
|
||||
let wm = uapi::socketpair(
|
||||
c::AF_UNIX,
|
||||
c::SOCK_STREAM | c::SOCK_CLOEXEC | c::SOCK_NONBLOCK,
|
||||
0,
|
||||
);
|
||||
let (wm1, wm2) = match wm {
|
||||
Ok(w) => w,
|
||||
Err(e) => return Err(XWaylandError::Socketpair(e.into())),
|
||||
|
|
|
|||
|
|
@ -6,20 +6,18 @@ use crate::wire::WlSurfaceId;
|
|||
use crate::wire_xcon::{
|
||||
ChangeWindowAttributes, ClientMessage, CompositeRedirectSubwindows, ConfigureNotify,
|
||||
ConfigureRequest, ConfigureWindow, ConfigureWindowValues, CreateGC, CreateNotify, CreatePixmap,
|
||||
CreateWindow, CreateWindowValues, DestroyNotify, FreeGC, FreePixmap, InternAtom,
|
||||
MapRequest, MapWindow, PutImage, RenderCreateCursor, RenderCreatePicture,
|
||||
SetSelectionOwner,
|
||||
CreateWindow, CreateWindowValues, DestroyNotify, FreeGC, FreePixmap, InternAtom, MapRequest,
|
||||
MapWindow, PutImage, RenderCreateCursor, RenderCreatePicture, SetSelectionOwner,
|
||||
};
|
||||
use crate::xcon::consts::{
|
||||
COMPOSITE_REDIRECT_MANUAL, EVENT_MASK_PROPERTY_CHANGE, EVENT_MASK_SUBSTRUCTURE_NOTIFY,
|
||||
EVENT_MASK_SUBSTRUCTURE_REDIRECT, IMAGE_FORMAT_Z_PIXMAP,
|
||||
WINDOW_CLASS_INPUT_OUTPUT,
|
||||
EVENT_MASK_SUBSTRUCTURE_REDIRECT, IMAGE_FORMAT_Z_PIXMAP, WINDOW_CLASS_INPUT_OUTPUT,
|
||||
};
|
||||
use crate::xcon::{Event, XEvent, Xcon};
|
||||
use crate::xwayland::{XWaylandError, XWaylandEvent};
|
||||
use crate::{AsyncQueue, ErrorFmt, State};
|
||||
use ahash::AHashMap;
|
||||
use futures_util::{FutureExt, select};
|
||||
use futures_util::{select, FutureExt};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use uapi::OwnedFd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue