package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Surface

type t = [ `surface | `object_ ] Gobject.obj
val new_popup : t -> bool -> t

Create a new Surface

val new_toplevel : [ `display | `object_ ] Gobject.obj -> t

Create a new Surface

val translate_coordinates : t -> t -> float -> float -> bool

Translates coordinates between two surfaces.

Note that this only works if @to and @from are popups or transient-for to the same toplevel (directly or indirectly).

val set_opaque_region : t -> Ocgtk_cairo.Cairo.Wrappers.Region.t option -> unit

Marks a region of the `GdkSurface` 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 @surface 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(../gtk4/vfunc.Widget.css_changed.html) handler.

val set_input_region : t -> Ocgtk_cairo.Cairo.Wrappers.Region.t -> unit

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 @surface.

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 method@Gdk.Display.supports_input_shapes to find out if a particular backend supports input regions.

val set_device_cursor : t -> [ `device | `object_ ] Gobject.obj -> [ `cursor | `object_ ] Gobject.obj -> unit

Sets a specific `GdkCursor` for a given device when it gets inside @surface.

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

Use ctor@Gdk.Cursor.new_from_name or ctor@Gdk.Cursor.new_from_texture to create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.

val set_cursor : t -> [ `cursor | `object_ ] Gobject.obj option -> unit

Sets the default mouse pointer for a `GdkSurface`.

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

Use ctor@Gdk.Cursor.new_from_name or ctor@Gdk.Cursor.new_from_texture to create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.

val request_layout : t -> unit

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

See method@Gdk.FrameClock.request_phase.

val queue_render : t -> unit

Forces a signal@Gdk.Surface::render signal emission for @surface to be scheduled.

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

val is_destroyed : t -> bool

Check to see if a surface is destroyed.

val hide : t -> unit

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()(../gtk4/method.Widget.hide.html).

val get_width : t -> int

Returns the width of the given @surface.

Surface size is reported in ”application pixels”, not ”device pixels” (see method@Gdk.Surface.get_scale_factor).

val get_scale_factor : t -> int

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.

val get_scale : t -> float

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 method@Gdk.Surface.get_scale_factor, which returns the next larger integer.

The scale may change during the lifetime of the surface.

val get_mapped : t -> bool

Checks whether the surface has been mapped.

A surface is mapped with method@Gdk.Toplevel.present or method@Gdk.Popup.present.

val get_height : t -> int

Returns the height of the given @surface.

Surface size is reported in ”application pixels”, not ”device pixels” (see method@Gdk.Surface.get_scale_factor).

val get_frame_clock : t -> [ `frame_clock | `object_ ] Gobject.obj

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.

val get_display : t -> [ `display | `object_ ] Gobject.obj

Gets the `GdkDisplay` associated with a `GdkSurface`.

val get_device_position : t -> [ `device | `object_ ] Gobject.obj -> bool * float * float * Gdk_enums.modifiertype

Obtains the current device position and modifier state.

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

val get_device_cursor : t -> [ `device | `object_ ] Gobject.obj -> [ `cursor | `object_ ] Gobject.obj option

Retrieves a `GdkCursor` pointer for the @device currently set on the specified `GdkSurface`.

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

Use method@Gdk.Surface.set_cursor to unset the cursor of the surface.

val get_cursor : t -> [ `cursor | `object_ ] Gobject.obj option

Retrieves a `GdkCursor` pointer for the cursor currently set on the `GdkSurface`.

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

Use method@Gdk.Surface.set_cursor to unset the cursor of the surface.

val destroy : t -> unit

Destroys the window system resources associated with @surface and decrements @surface's reference count.

The window system resources for all children of @surface 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.

val create_vulkan_context : t -> ([ `vulkan_context | `draw_context | `object_ ] Gobject.obj, GError.t) result

Sets an error and returns %NULL.

val create_similar_surface : t -> Ocgtk_cairo.Cairo.content -> int -> int -> Ocgtk_cairo.Cairo.Wrappers.Surface.t

Create a new Cairo surface that is as compatible as possible with the given @surface.

For example the new surface will have the same fallback resolution and font options as @surface. Generally, the new surface will also use the same backend as @surface, unless that is not possible for some reason. The type of the returned surface may be examined with cairo_surface_get_type().

Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)

This function always returns a valid pointer, but it will return a pointer to a “nil” surface if @other is already in an error state or any other error occurs.

val create_gl_context : t -> ([ `gl_context | `draw_context | `object_ ] Gobject.obj, GError.t) result

Creates a new `GdkGLContext` for the `GdkSurface`.

The context is disconnected from any particular surface or surface. If the creation of the `GdkGLContext` failed, @error will be set. Before using the returned `GdkGLContext`, you will need to call method@Gdk.GLContext.make_current or method@Gdk.GLContext.realize.

val create_cairo_context : t -> [ `cairo_context | `draw_context | `object_ ] Gobject.obj

Creates a new `GdkCairoContext` for rendering on @surface.

val beep : t -> unit

Emits a short beep associated to @surface.

If the display of @surface does not support per-surface beeps, emits a short beep on the display just as method@Gdk.Display.beep.

val on_enter_monitor : ?after:bool -> t -> callback:(monitor:[ `monitor | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id
val on_event : ?after:bool -> t -> callback:(event:[ `event ] Gobject.obj -> bool) -> Gobject.Signal.handler_id
val on_layout : ?after:bool -> t -> callback:(width:int -> height:int -> unit) -> Gobject.Signal.handler_id
val on_leave_monitor : ?after:bool -> t -> callback:(monitor:[ `monitor | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id