Trait gdk4::prelude::SurfaceExt [−][src]
pub trait SurfaceExt: 'static {
Show 32 methods
fn beep(&self);
fn create_cairo_context(&self) -> Option<CairoContext>;
fn create_gl_context(&self) -> Result<Option<GLContext>, Error>;
fn create_vulkan_context(&self) -> Result<VulkanContext, Error>;
fn destroy(&self);
fn cursor(&self) -> Option<Cursor>;
fn device_cursor<P: IsA<Device>>(&self, device: &P) -> Option<Cursor>;
fn device_position<P: IsA<Device>>(
&self,
device: &P
) -> Option<(f64, f64, ModifierType)>;
fn display(&self) -> Option<Display>;
fn frame_clock(&self) -> Option<FrameClock>;
fn height(&self) -> i32;
fn is_mapped(&self) -> bool;
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<P: IsA<Device>>(&self, device: &P, 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_factor_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_width_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required methods
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()
.
fn create_cairo_context(&self) -> Option<CairoContext>
fn create_cairo_context(&self) -> Option<CairoContext>
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
fn create_vulkan_context(&self) -> Result<VulkanContext, Error>
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
Destroys the window system resources associated with self
and
decrements self
’s reference count.
The window system resources for all children of self
are also
destroyed, but the children’s reference counts are not decremented.
Note that a surface will not be destroyed automatically when its reference count reaches zero. You must call this function yourself before that happens.
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
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
fn frame_clock(&self) -> Option<FrameClock>
fn frame_clock(&self) -> Option<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
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
Checks whether the surface has been mapped.
A surface is mapped with ToplevelExt::present()
or PopupExt::present()
.
Returns
true
if the surface is mapped
fn 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 of a surface may change during runtime.
Returns
the scale factor
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
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()``.
fn is_destroyed(&self) -> bool
fn is_destroyed(&self) -> bool
fn queue_render(&self)
fn queue_render(&self)
Forces a signal::Surface::render
signal emission for self
to be scheduled.
This function is useful for implementations that track invalid regions on their own.
fn request_layout(&self)
fn request_layout(&self)
Request a layout phase from the surface’s frame clock.
fn 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
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
fn 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
fn 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
vfunc::Gtk::Widget::css_changed
handler.
region
a region, or None
to make the entire
surface opaque
fn 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
fn 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
fn 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
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 scale_factor()
).
width
the current width
height
the current height