1.39 <GdkSurface>

Class: <GdkSurface>

It derives from <GObject>.

Represents a rectangular region on the screen.

It’s a low-level object, used to implement high-level objects such as GtkWindow.

The surfaces you see in practice are either <GdkToplevel> or <GdkPopup>, and those interfaces provide much of the required API to interact with these surfaces. Other, more specialized surface types exist, but you will rarely interact with them directly.

Properties

Property: surface:cursor self

The mouse pointer for the <GdkSurface>.

Its value is a <GdkCursor>, or #f.

Set it with (set! (surface:cursor self) value).

Property: surface:display self

The <GdkDisplay> connection of the surface.

Its value is a <GdkDisplay>, or #f.

It can only be set when the object is made, with #:display.

Property: surface:frame-clock self

The <GdkFrameClock> of the surface.

Its value is a <GdkFrameClock>, or #f.

It can only be set when the object is made, with #:frame-clock.

Property: surface:height self

The height of the surface, in pixels.

Its value is a 32-bit integer.

It is read only.

Property: surface:mapped self

Whether the surface is mapped.

Its value is a boolean.

It is read only.

Property: surface:scale self

The scale of the surface.

Its value is a real number.

It is read only.

Property: surface:scale-factor self

The scale factor of the surface.

The scale factor is the next larger integer, compared to surface:scale.

Its value is a 32-bit integer.

It is read only.

Property: surface:width self

The width of the surface in pixels.

Its value is a 32-bit integer.

It is read only.

Procedures

Method: surface:beep self
Method: 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 display:beep.

self

Passed: a <GdkSurface>.

a toplevel <GdkSurface>

Method: surface:create-cairo-context self ⇒ %return
Method: create-cairo-context self ⇒ %return

Creates a new <GdkCairoContext> for rendering on self.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkCairoContext>.

the newly created <GdkCairoContext>

Method: surface:create-gl-context self ⇒ %return
Method: create-gl-context self ⇒ %return

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 glcontext:make-current or glcontext:realize?.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkGLContext>.

the newly created <GdkGLContext>

Method: surface:create-similar-surface self content width height ⇒ %return
Method: create-similar-surface self content width height ⇒ %return

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

For example the new surface will have the same fallback resolution and font options as self. Generally, the new surface will also use the same backend as self, 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.

self

Passed: a <GdkSurface>.

surface to make new surface similar to

content

Passed: a <cairo_content_t>, or one of its symbols.

the content for the new surface

width

Passed: a 32-bit integer.

width of the new surface

height

Passed: a 32-bit integer.

height of the new surface

%return

Returned: a <CairoSurface>.

a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.

Method: surface:create-vulkan-context self ⇒ %return
Method: create-vulkan-context self ⇒ %return

Sets an error and returns #f.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkVulkanContext>.

#f

Method: surface:destroy self
Method: destroy self

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.

self

Passed: a <GdkSurface>.

a <GdkSurface>

Method: surface:get-cursor self ⇒ %return
Method: get-cursor self ⇒ %return

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

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

Use surface:set-cursor to unset the cursor of the surface.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkCursor>, or #f.

a <GdkCursor>

Method: surface:get-device-cursor self device ⇒ %return
Method: get-device-cursor self device ⇒ %return

Retrieves a <GdkCursor> pointer for the device currently set on the specified <GdkSurface>.

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

Use surface:set-cursor to unset the cursor of the surface.

self

Passed: a <GdkSurface>.

a <GdkSurface>

device

Passed: a <GdkDevice>.

a pointer <GdkDevice>

%return

Returned: a <GdkCursor>, or #f.

a <GdkCursor>

Method: surface:get-device-position self device ⇒ %return x y mask
Method: get-device-position self device ⇒ %return x y mask

Obtains the current device position and modifier state.

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

self

Passed: a <GdkSurface>.

a <GdkSurface>

device

Passed: a <GdkDevice>.

pointer <GdkDevice> to query to

%return

Returned: a boolean.

#t if the device is over the surface

x

Returned: a real number.

return location for the X coordinate of device

y

Returned: a real number.

return location for the Y coordinate of device

mask

Returned: a <GdkModifierType>.

return location for the modifier mask

Method: surface:get-display self ⇒ %return
Method: get-display self ⇒ %return

Gets the <GdkDisplay> associated with a <GdkSurface>.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkDisplay>.

the <GdkDisplay> associated with self

Method: surface:get-frame-clock self ⇒ %return
Method: get-frame-clock self ⇒ %return

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.

self

Passed: a <GdkSurface>.

surface to get frame clock for

%return

Returned: a <GdkFrameClock>.

the frame clock

Method: surface:get-height self ⇒ %return
Method: get-height self ⇒ %return

Returns the height of the given self.

Surface size is reported in ”application pixels”, not ”device pixels” (see surface:get-scale-factor).

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a 32-bit integer.

The height of self

Method: surface:get-mapped? self ⇒ %return
Method: get-mapped? self ⇒ %return

Checks whether the surface has been mapped.

A surface is mapped with toplevel:present or popup:present?.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a boolean.

#t if the surface is mapped

Method: surface:get-scale self ⇒ %return
Method: get-scale self ⇒ %return

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 surface:get-scale-factor, which returns the next larger integer.

The scale may change during the lifetime of the surface.

self

Passed: a <GdkSurface>.

surface to get scale for

%return

Returned: a real number.

the scale

Method: surface:get-scale-factor self ⇒ %return
Method: get-scale-factor self ⇒ %return

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.

self

Passed: a <GdkSurface>.

surface to get scale factor for

%return

Returned: a 32-bit integer.

the scale factor

Method: surface:get-width self ⇒ %return
Method: get-width self ⇒ %return

Returns the width of the given self.

Surface size is reported in ”application pixels”, not ”device pixels” (see surface:get-scale-factor).

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a 32-bit integer.

The width of self

Method: surface:hide self
Method: 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().

self

Passed: a <GdkSurface>.

a <GdkSurface>

Method: surface:is-destroyed? self ⇒ %return
Method: is-destroyed? self ⇒ %return

Check to see if a surface is destroyed.

self

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a boolean.

#t if the surface is destroyed

Procedure: surface:new-popup parent autohide ⇒ %return

Create a new popup surface.

The surface will be attached to parent and can be positioned relative to it using popup:present?.

parent

Passed: a <GdkSurface>.

the parent surface to attach the surface to

autohide

Passed: a boolean.

whether to hide the surface on outside clicks

%return

Returned: a <GdkSurface>.

a new <GdkSurface>

Procedure: surface:new-toplevel display ⇒ %return

Creates a new toplevel surface.

display

Passed: a <GdkDisplay>.

the display to create the surface on

%return

Returned: a <GdkSurface>.

the new <GdkSurface>

Method: surface:queue-render self
Method: queue-render self

Forces a surface:render signal emission for self to be scheduled.

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

self

Passed: a <GdkSurface>.

a <GdkSurface>

Method: surface:request-layout self
Method: request-layout self

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

See frame-clock:request-phase.

self

Passed: a <GdkSurface>.

a <GdkSurface>

Method: surface:set-cursor self [cursor]
Method: set-cursor self [cursor]

Sets the default mouse pointer for a <GdkSurface>.

Passing #f 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:new-from-name or cursor:new-from-texture to create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR.

self

Passed: a <GdkSurface>.

a <GdkSurface>

cursor

Passed, or left out: a <GdkCursor>, or #f.

a <GdkCursor>

Method: surface:set-device-cursor self device cursor
Method: set-device-cursor self device cursor

Sets a specific <GdkCursor> for a given device when it gets inside self.

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

Use cursor:new-from-name or cursor:new-from-texture to create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR.

self

Passed: a <GdkSurface>.

a <GdkSurface>

device

Passed: a <GdkDevice>.

a pointer <GdkDevice>

cursor

Passed: a <GdkCursor>.

a <GdkCursor>

Method: surface:set-input-region self [region]
Method: set-input-region self [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 display:supports-input-shapes? to find out if a particular backend supports input regions.

self

Passed: a <GdkSurface>.

a <GdkSurface>

region

Passed, or left out: a <CairoRegion>, or #f.

region of surface to be reactive, or #f to make the entire surface reactive

Method: surface:set-opaque-region self [region]
Method: set-opaque-region self [region]

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

self

Passed: a <GdkSurface>.

a top-level <GdkSurface>

region

Passed, or left out: a <CairoRegion>, or #f.

a region, or #f to make the entire surface opaque

Method: surface:translate-coordinates self to x y ⇒ %return x y
Method: translate-coordinates self to x y ⇒ %return x y

Translates coordinates between two surfaces.

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

self

Passed: a <GdkSurface>.

the origin surface

to

Passed: a <GdkSurface>.

the target surface

x

Passed, and returned: a real number.

coordinates to translate

y

Passed, and returned: a real number.

coordinates to translate

%return

Returned: a boolean.

#t if the coordinates were successfully translated

Signals

Signal: surface:enter-monitor

Connect a handler with (connect object surface:enter-monitor handler). It is called as (handler self monitor).

Emitted when surface starts being present on the monitor.

self

Passed: a <GdkSurface>.

monitor

Passed: a <GdkMonitor>.

the monitor

Signal: surface:event

Connect a handler with (connect object surface:event handler). It is called as (handler self event) ⇒ %return.

Emitted when GDK receives an input event for surface.

self

Passed: a <GdkSurface>.

event

Passed: a <GdkEvent>.

an input event

%return

Returned: a boolean.

#t to indicate that the event has been handled

Signal: surface:layout

Connect a handler with (connect object surface:layout handler). It is called as (handler self width height).

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 surface:get-scale-factor).

self

Passed: a <GdkSurface>.

width

Passed: a 32-bit integer.

the current width

height

Passed: a 32-bit integer.

the current height

Signal: surface:leave-monitor

Connect a handler with (connect object surface:leave-monitor handler). It is called as (handler self monitor).

Emitted when surface stops being present on the monitor.

self

Passed: a <GdkSurface>.

monitor

Passed: a <GdkMonitor>.

the monitor

Signal: surface:render

Connect a handler with (connect object surface:render handler). It is called as (handler self region) ⇒ %return.

Emitted when part of the surface needs to be redrawn.

self

Passed: a <GdkSurface>.

region

Passed: a <CairoRegion>.

the region that needs to be redrawn

%return

Returned: a boolean.

#t to indicate that the signal has been handled