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
Provided Methods§
Sourcefn beep(&self)
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()
.
Sourcefn create_cairo_context(&self) -> CairoContext
fn create_cairo_context(&self) -> CairoContext
Sourcefn create_gl_context(&self) -> Result<GLContext, Error>
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
Sourcefn create_vulkan_context(&self) -> Result<VulkanContext, Error>
👎Deprecated: Since 4.14
fn create_vulkan_context(&self) -> Result<VulkanContext, Error>
fn destroy(&self)
Sourcefn device_cursor(&self, device: &impl IsA<Device>) -> Option<Cursor>
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
Sourcefn device_position(
&self,
device: &impl IsA<Device>,
) -> Option<(f64, f64, ModifierType)>
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
Sourcefn frame_clock(&self) -> FrameClock
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
Sourcefn height(&self) -> i32
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
Sourcefn is_mapped(&self) -> bool
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
Sourcefn scale(&self) -> f64
Available on crate feature v4_12
only.
fn scale(&self) -> f64
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
Sourcefn scale_factor(&self) -> i32
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
Sourcefn width(&self) -> i32
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
Sourcefn hide(&self)
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().
Sourcefn is_destroyed(&self) -> bool
fn is_destroyed(&self) -> bool
Sourcefn queue_render(&self)
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.
Sourcefn request_layout(&self)
fn request_layout(&self)
Request a layout phase from the surface’s frame clock.
Sourcefn set_cursor(&self, cursor: Option<&Cursor>)
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
Sourcefn set_device_cursor(&self, device: &impl IsA<Device>, cursor: &Cursor)
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
Sourcefn set_input_region(&self, region: &Region)
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
Sourcefn set_opaque_region(&self, region: Option<&Region>)
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 GtkWidgetClass.css_changed handler.
§region
a region, or None
to make the entire
surface opaque
Sourcefn connect_enter_monitor<F: Fn(&Self, &Monitor) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_enter_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F, ) -> SignalHandlerId
Sourcefn connect_event<F: Fn(&Self, &Event) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_event<F: Fn(&Self, &Event) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Sourcefn connect_layout<F: Fn(&Self, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_layout<F: Fn(&Self, i32, i32) + 'static>( &self, f: F, ) -> SignalHandlerId
Sourcefn connect_leave_monitor<F: Fn(&Self, &Monitor) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_leave_monitor<F: Fn(&Self, &Monitor) + 'static>( &self, f: F, ) -> SignalHandlerId
Sourcefn connect_render<F: Fn(&Self, &Region) -> bool + '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
v4_12
only.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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.