From 8e7b1bc0cd357670feabe8ede50675ed5c4d119f Mon Sep 17 00:00:00 2001 From: sminez Date: Fri, 14 Jun 2024 06:43:49 +0000 Subject: [PATCH] deploy: 36f7a1a4240d3a3010b58108ebbc5d4037c4939c --- rustdoc/penrose_ui/core/index.html | 2 +- rustdoc/penrose_ui/core/struct.Context.html | 8 ++-- rustdoc/src/penrose_ui/core/fontset.rs.html | 10 ++++- rustdoc/src/penrose_ui/core/mod.rs.html | 42 ++++++++++++++++++++- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/rustdoc/penrose_ui/core/index.html b/rustdoc/penrose_ui/core/index.html index dfe907bb..9a652c4a 100644 --- a/rustdoc/penrose_ui/core/index.html +++ b/rustdoc/penrose_ui/core/index.html @@ -1,5 +1,5 @@ penrose_ui::core - Rust -

Module penrose_ui::core

source ·
Expand description

The core Draw and Context structs for rendering UI elements.

+

Module penrose_ui::core

source ·
Expand description

The core Draw and Context structs for rendering UI elements.

If you are only interested in adding functionality to the penrose StatusBar then you do not need to worry about the use and implementation of Draw and Context: the abstractions provided by the Widget trait should be sufficient for your needs. If however you wish diff --git a/rustdoc/penrose_ui/core/struct.Context.html b/rustdoc/penrose_ui/core/struct.Context.html index 722acc5e..112d9853 100644 --- a/rustdoc/penrose_ui/core/struct.Context.html +++ b/rustdoc/penrose_ui/core/struct.Context.html @@ -9,7 +9,7 @@ handles rendering child widgets for a real example of how to make use of the offseting functionality of this struct.

-

Implementations§

source§

impl<'a> Context<'a>

source

pub fn clear(&mut self) -> Result<()>

Clear the underlying surface, restoring it to the background color.

+

Implementations§

source§

impl<'a> Context<'a>

source

pub fn clear(&mut self) -> Result<()>

Clear the underlying surface, restoring it to the background color.

source

pub fn translate(&mut self, dx: i32, dy: i32)

Offset future drawing operations by an additional (dx, dy)

source

pub fn reset_offset(&mut self)

Set future drawing operations to apply from the origin.

source

pub fn set_x_offset(&mut self, x: i32)

Set an absolute x offset for future drawing operations.

@@ -18,15 +18,15 @@
source

pub fn fill_rect(&mut self, _: Rect, color: Color) -> Result<()>

Render a filled rectangle using the supplied color.

source

pub fn fill_polygon(&mut self, points: &[Point], color: Color) -> Result<()>

Render a filled rectangle using the supplied color.

source

pub fn fill_bg(&mut self, r: Rect) -> Result<()>

Fill the specified area with this Context’s background color

-
source

pub fn draw_text( +

source

pub fn draw_text( &mut self, txt: &str, h_offset: u32, padding: (u32, u32), c: Color ) -> Result<(u32, u32)>

Render the provided text at the current context offset using the supplied color.

-
source

pub fn text_extent(&mut self, txt: &str) -> Result<(u32, u32)>

Determine the width and height taken up by a given string in pixels.

-
source

pub fn flush(&self)

Flush pending requests to the X server.

+
source

pub fn text_extent(&mut self, txt: &str) -> Result<(u32, u32)>

Determine the width and height taken up by a given string in pixels.

+
source

pub fn flush(&self)

Flush pending requests to the X server.

This method does not need to be called explicitly if the flush method for the parent Draw is being called as well.

Trait Implementations§

source§

impl<'a> Debug for Context<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> !Send for Context<'a>

§

impl<'a> !Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> !UnwindSafe for Context<'a>

Blanket Implementations§

source§

impl<T> Any for T
where diff --git a/rustdoc/src/penrose_ui/core/fontset.rs.html b/rustdoc/src/penrose_ui/core/fontset.rs.html index c62d90d9..7cdb98bf 100644 --- a/rustdoc/src/penrose_ui/core/fontset.rs.html +++ b/rustdoc/src/penrose_ui/core/fontset.rs.html @@ -267,6 +267,9 @@

Files

265 266 267 +268 +269 +270

use crate::{core::SCREEN, Error, Result};
 use fontconfig_sys::{
     constants::{FC_CHARSET, FC_SCALABLE},
@@ -385,7 +388,7 @@ 

Files

// SAFETY: the Display we have a pointer to is freed by the parent draw unsafe { XftFontClose(self.dpy, self.primary.xfont); - for f in self.fallback.drain(0..) { + for f in self.fallback.drain(..) { XftFontClose(self.dpy, f.xfont); } } @@ -483,7 +486,10 @@

Files

ext, ); - Ok(((*ext).xOff as u32, self.h)) + let x_off = (*ext).xOff as u32; + std::alloc::dealloc(ext as *mut u8, layout); + + Ok((x_off, self.h)) } } diff --git a/rustdoc/src/penrose_ui/core/mod.rs.html b/rustdoc/src/penrose_ui/core/mod.rs.html index 06a2a845..7ab145d9 100644 --- a/rustdoc/src/penrose_ui/core/mod.rs.html +++ b/rustdoc/src/penrose_ui/core/mod.rs.html @@ -541,6 +541,25 @@

Files

539 540 541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560
//! The core [`Draw`] and [`Context`] structs for rendering UI elements.
 //!
 //! If you are only interested in adding functionality to the penrose [StatusBar][0] then you
@@ -569,7 +588,7 @@ 

Files

}; use tracing::{debug, info}; use x11::{ - xft::{XftColor, XftColorAllocName, XftDrawCreate, XftDrawStringUtf8}, + xft::{XftColor, XftColorAllocName, XftDraw, XftDrawCreate, XftDrawDestroy, XftDrawStringUtf8}, xlib::{ CapButt, Complex, CoordModeOrigin, Display, Drawable, False, JoinMiter, LineSolid, Window, XCopyArea, XCreateGC, XCreatePixmap, XDefaultColormap, XDefaultDepth, XDefaultVisual, @@ -962,6 +981,8 @@

Files

) -> Result<(u32, u32)> { // SAFETY: // - the pointers for self.dpy and s.drawable are known to be non-null + // - we wrap the returned pointer in DropXftDraw to ensure that we correctly destroy + // the XftDraw we create here (see below) let d = unsafe { XftDrawCreate( self.dpy, @@ -971,6 +992,8 @@

Files

) }; + let _drop_draw = DropXftDraw { ptr: d }; + let (lpad, rpad) = (padding.0 as i32, padding.1); let (mut x, y) = (lpad + self.dx, self.dy); let (mut total_w, mut total_h) = (x as u32, 0); @@ -1004,7 +1027,22 @@

Files

total_h = max(total_h, chunk_h); } - Ok((total_w + rpad, total_h)) + return Ok((total_w + rpad, total_h)); + + // There are multiple error paths here where we need to make sure that we correctly destroy + // the XftDraw we created. Rather than complicate the error handling we use a Drop wrapper + // to ensure that we run XftDrawDestroy when the function returns. + + struct DropXftDraw { + ptr: *mut XftDraw, + } + + impl Drop for DropXftDraw { + fn drop(&mut self) { + // SAFETY: the pointer we have must be non-null + unsafe { XftDrawDestroy(self.ptr) }; + } + } } /// Determine the width and height taken up by a given string in pixels.