Trait gdk4::prelude::SurfaceExt

source ·
pub trait SurfaceExt: 'static {
Show 32 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_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_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

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().

Creates a new CairoContext for rendering on @self.

Returns

the newly created 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

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

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

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

Gets the Display associated with a Surface.

Returns

the Display associated with @self

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

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().

Check to see if a surface is destroyed.

Returns

true if the surface is destroyed

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.

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

See FrameClock::request_phase().

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

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

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

Emitted when @surface starts being present on the monitor.

monitor

the monitor

Emitted when GDK receives an input event for @surface.

event

an input event

Returns

true to indicate that the event has been handled

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

Emitted when @surface stops being present on the monitor.

monitor

the monitor

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

Implementors§