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
|
|
@ -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