Trait gdk4::prelude::SurfaceExt

source ·
pub trait SurfaceExt: IsA<Surface> + Sealed + 'static {
Show 34 methods // Provided methods fn beep(&self) { ... } fn create_cairo_context(&self) -> CairoContext { ... } fn create_gl_context(&self) -> Result<GLContext, Error> { ... } fn create_vulkan_context(&self) -> Result<VulkanContext, Error> { ... } fn destroy(&self) { ... } fn cursor(&self) -> Option<Cursor> { ... } fn device_cursor(&self, device: &impl IsA<Device>) -> Option<Cursor> { ... } fn device_position( &self, device: &impl IsA<Device> ) -> Option<(f64, f64, ModifierType)> { ... } fn display(&self) -> Display { ... } fn frame_clock(&self) -> FrameClock { ... } fn height(&self) -> i32 { ... } fn is_mapped(&self) -> bool { ... } fn scale(&self) -> f64 { ... } fn scale_factor(&self) -> i32 { ... } fn width(&self) -> i32 { ... } fn hide(&self) { ... } fn is_destroyed(&self) -> bool { ... } fn queue_render(&self) { ... } fn request_layout(&self) { ... } fn set_cursor(&self, cursor: Option<&Cursor>) { ... } fn set_device_cursor(&self, device: &impl IsA<Device>, cursor: &Cursor) { ... } fn set_input_region(&self, region: &Region) { ... } fn set_opaque_region(&self, region: Option<&Region>) { ... } fn connect_enter_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_event<F: Fn(&Self, &Event) -> bool + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_layout<F: Fn(&Self, i32, i32) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_leave_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_render<F: Fn(&Self, &Region) -> bool + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_cursor_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_height_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_mapped_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_scale_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_scale_factor_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_width_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Surface methods.

Implementors

DragSurface, Popup, Surface, Toplevel

Provided Methods§

source

fn beep(&self)

Emits a short beep associated to @self.

If the display of @self does not support per-surface beeps, emits a short beep on the display just as DisplayExt::beep().

source

fn create_cairo_context(&self) -> CairoContext

Creates a new CairoContext for rendering on @self.

Returns

the newly created CairoContext

source

fn create_gl_context(&self) -> Result<GLContext, Error>

Creates a new GLContext for the Surface.

The context is disconnected from any particular surface or surface. If the creation of the GLContext failed, @error will be set. Before using the returned GLContext, you will need to call GLContextExt::make_current() or GLContextExt::realize().

Returns

the newly created GLContext

source

fn create_vulkan_context(&self) -> Result<VulkanContext, Error>

Creates a new VulkanContext for rendering on @self.

If the creation of the VulkanContext failed, @error will be set.

Returns

the newly created VulkanContext, or None on error

source

fn destroy(&self)

source

fn cursor(&self) -> Option<Cursor>

Retrieves a Cursor pointer for the cursor currently set on the Surface.

If the return value is None then there is no custom cursor set on the surface, and it is using the cursor for its parent surface.

Use set_cursor() to unset the cursor of the surface.

Returns

a Cursor

source

fn device_cursor(&self, device: &impl IsA<Device>) -> Option<Cursor>

Retrieves a Cursor pointer for the @device currently set on the specified Surface.

If the return value is None then there is no custom cursor set on the specified surface, and it is using the cursor for its parent surface.

Use set_cursor() to unset the cursor of the surface.

device

a pointer Device

Returns

a Cursor

source

fn device_position( &self, device: &impl IsA<Device> ) -> Option<(f64, f64, ModifierType)>

Obtains the current device position and modifier state.

The position is given in coordinates relative to the upper left corner of @self.

device

pointer Device to query to

Returns

true if the device is over the surface

x

return location for the X coordinate of @device

y

return location for the Y coordinate of @device

mask

return location for the modifier mask

source

fn display(&self) -> Display

Gets the Display associated with a Surface.

Returns

the Display associated with @self

source

fn frame_clock(&self) -> FrameClock

Gets the frame clock for the surface.

The frame clock for a surface never changes unless the surface is reparented to a new toplevel surface.

Returns

the frame clock

source

fn height(&self) -> i32

Returns the height of the given @self.

Surface size is reported in ”application pixels”, not ”device pixels” (see scale_factor()).

Returns

The height of @self

source

fn is_mapped(&self) -> bool

Checks whether the surface has been mapped.

A surface is mapped with ToplevelExt::present() or PopupExt::present().

Returns

true if the surface is mapped

source

fn scale(&self) -> f64

Available on crate feature v4_12 only.

Returns the internal scale that maps from surface coordinates to the actual device pixels.

When the scale is bigger than 1, the windowing system prefers to get buffers with a resolution that is bigger than the surface size (e.g. to show the surface on a high-resolution display, or in a magnifier).

Compare with scale_factor(), which returns the next larger integer.

The scale may change during the lifetime of the surface.

Returns

the scale

source

fn scale_factor(&self) -> i32

Returns the internal scale factor that maps from surface coordinates to the actual device pixels.

On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2). A higher value means that drawing is automatically scaled up to a higher resolution, so any code doing drawing will automatically look nicer. However, if you are supplying pixel-based data the scale value can be used to determine whether to use a pixel resource with higher resolution data.

The scale factor may change during the lifetime of the surface.

Returns

the scale factor

source

fn width(&self) -> i32

Returns the width of the given @self.

Surface size is reported in ”application pixels”, not ”device pixels” (see scale_factor()).

Returns

The width of @self

source

fn hide(&self)

Hide the surface.

For toplevel surfaces, withdraws them, so they will no longer be known to the window manager; for all surfaces, unmaps them, so they won’t be displayed. Normally done automatically as part of Gtk::Widget::hide().

source

fn is_destroyed(&self) -> bool

Check to see if a surface is destroyed.

Returns

true if the surface is destroyed

source

fn queue_render(&self)

Forces a render signal emission for @self to be scheduled.

This function is useful for implementations that track invalid regions on their own.

source

fn request_layout(&self)

Request a layout phase from the surface’s frame clock.

See FrameClock::request_phase().

source

fn set_cursor(&self, cursor: Option<&Cursor>)

Sets the default mouse pointer for a Surface.

Passing None for the @cursor argument means that @self will use the cursor of its parent surface. Most surfaces should use this default. Note that @cursor must be for the same display as @self.

Use Cursor::from_name() or Cursor::from_texture() to create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR.

cursor

a Cursor

source

fn set_device_cursor(&self, device: &impl IsA<Device>, cursor: &Cursor)

Sets a specific Cursor for a given device when it gets inside @self.

Passing None for the @cursor argument means that @self will use the cursor of its parent surface. Most surfaces should use this default.

Use Cursor::from_name() or Cursor::from_texture() to create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR.

device

a pointer Device

cursor

a Cursor

source

fn set_input_region(&self, region: &Region)

Apply the region to the surface for the purpose of event handling.

Mouse events which happen while the pointer position corresponds to an unset bit in the mask will be passed on the surface below @self.

An input region is typically used with RGBA surfaces. The alpha channel of the surface defines which pixels are invisible and allows for nicely antialiased borders, and the input region controls where the surface is “clickable”.

Use DisplayExt::supports_input_shapes() to find out if a particular backend supports input regions.

region

region of surface to be reactive

source

fn set_opaque_region(&self, region: Option<&Region>)

Marks a region of the Surface as opaque.

For optimisation purposes, compositing window managers may like to not draw obscured regions of surfaces, or turn off blending during for these regions. With RGB windows with no transparency, this is just the shape of the window, but with ARGB32 windows, the compositor does not know what regions of the window are transparent or not.

This function only works for toplevel surfaces.

GTK will update this property automatically if the @self background is opaque, as we know where the opaque regions are. If your surface background is not opaque, please update this property in your vfunc::Gtk::Widget::css_changed handler.

region

a region, or None to make the entire surface opaque

source

fn connect_enter_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when @surface starts being present on the monitor.

monitor

the monitor

source

fn connect_event<F: Fn(&Self, &Event) -> bool + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when GDK receives an input event for @surface.

event

an input event

Returns

true to indicate that the event has been handled

source

fn connect_layout<F: Fn(&Self, i32, i32) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when the size of @surface is changed, or when relayout should be performed.

Surface size is reported in ”application pixels”, not ”device pixels” (see gdk_surface_get_scale_factor()).

width

the current width

height

the current height

source

fn connect_leave_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when @surface stops being present on the monitor.

monitor

the monitor

source

fn connect_render<F: Fn(&Self, &Region) -> bool + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when part of the surface needs to be redrawn.

region

the region that needs to be redrawn

Returns

true to indicate that the signal has been handled

source

fn connect_cursor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_mapped_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Available on crate feature v4_12 only.
source

fn connect_scale_factor_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Implementors§