Class: Gdk::Surface

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(display) ⇒ Gdk::Surface

Creates a new toplevel surface.

Parameters:

  • display (Gdk::Display)

    the display to create the surface on

Instance Method Details

#beepnil

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 [methodGdk.Display.beep].

Returns:

  • (nil)

#create_cairo_contextGdk::CairoContext

Creates a new GdkCairoContext for rendering on surface.

Returns:

#create_gl_contextGdk::GLContext

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 [methodGdk.GLContext.make_current] or [methodGdk.GLContext.realize].

Returns:

#create_similar_surface(content, width, height) ⇒ cairo::Surface

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.

Parameters:

  • content (cairo::Content)

    the content for the new surface

  • width (Integer)

    width of the new surface

  • height (Integer)

    height of the new surface

Returns:

  • (cairo::Surface)

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

#create_vulkan_contextGdk::VulkanContext

Sets an error and returns nil.

Returns:

#cursorGdk::Cursor

The mouse pointer for the GdkSurface.

Returns:

#cursor=(cursor) ⇒ Gdk::Cursor

The mouse pointer for the GdkSurface.

Parameters:

Returns:

#destroynil

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.

Returns:

  • (nil)

#displayGdk::Display

The GdkDisplay connection of the surface.

Returns:

#display=(display) ⇒ Gdk::Display

The GdkDisplay connection of the surface.

Parameters:

Returns:

#frame_clockGdk::FrameClock

The GdkFrameClock of the surface.

Returns:

#frame_clock=(frame_clock) ⇒ Gdk::FrameClock

The GdkFrameClock of the surface.

Parameters:

Returns:

#get_device_cursor(device) ⇒ Gdk::Cursor

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

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

Use [methodGdk.Surface.set_cursor] to unset the cursor of the surface.

Parameters:

Returns:

#get_device_position(device, x, y, mask) ⇒ Boolean

Obtains the current device position and modifier state.

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

Parameters:

  • device (Gdk::Device)

    pointer GdkDevice to query to

  • x (Float)

    return location for the X coordinate of device

  • y (Float)

    return location for the Y coordinate of device

  • mask (Gdk::ModifierType)

    return location for the modifier mask

Returns:

  • (Boolean)

    true if the device is over the surface

#heightInteger

The height of the surface, in pixels.

Returns:

  • (Integer)

    height

#height=(height) ⇒ Integer

The height of the surface, in pixels.

Parameters:

  • height (Integer)

Returns:

  • (Integer)

    height

  • (Integer)

    height

#hidenil

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

Returns:

  • (nil)

#input_region=(region) ⇒ nil

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 [methodGdk.Display.supports_input_shapes] to find out if a particular backend supports input regions.

Parameters:

  • region (cairo::Region)

    region of surface to be reactive

Returns:

  • (nil)

#is_destroyedBoolean

Check to see if a surface is destroyed.

Returns:

  • (Boolean)

    true if the surface is destroyed

#mappedBoolean

Checks whether the surface has been mapped.

A surface is mapped with [methodGdk.Toplevel.present] or [methodGdk.Popup.present].

Returns:

  • (Boolean)

    true if the surface is mapped

#mapped=(mapped) ⇒ Boolean

Whether the surface is mapped.

Parameters:

  • mapped (Boolean)

Returns:

  • (Boolean)

    mapped

  • (Boolean)

    mapped

#mapped?Boolean

Whether the surface is mapped.

Returns:

  • (Boolean)

    mapped

#opaque_region=(region) ⇒ nil

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

Parameters:

  • region (cairo::Region)

    a region, or nil to make the entire surface opaque

Returns:

  • (nil)

#queue_rendernil

Forces a [signalGdk.Surface::render] signal emission for surface to be scheduled.

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

Returns:

  • (nil)

#request_layoutnil

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

See [methodGdk.FrameClock.request_phase].

Returns:

  • (nil)

#scaleFloat

The scale of the surface.

Returns:

  • (Float)

    scale

#scale=(scale) ⇒ Float

The scale of the surface.

Parameters:

  • scale (Float)

Returns:

  • (Float)

    scale

  • (Float)

    scale

#scale_factorInteger

The scale factor of the surface.

The scale factor is the next larger integer, compared to [propertyGdk.Surface:scale].

Returns:

  • (Integer)

    scale-factor

#scale_factor=(scale_factor) ⇒ Integer

The scale factor of the surface.

The scale factor is the next larger integer, compared to [propertyGdk.Surface:scale].

Parameters:

  • scale_factor (Integer)

Returns:

  • (Integer)

    scale-factor

  • (Integer)

    scale-factor

#set_device_cursor(device, cursor) ⇒ nil

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

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

Use [ctorGdk.Cursor.new_from_name] or [ctorGdk.Cursor.new_from_texture] to create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.

Parameters:

Returns:

  • (nil)

#translate_coordinates(to, x, y) ⇒ Boolean

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

Parameters:

  • to (Gdk::Surface)

    the target surface

  • x (Float)

    coordinates to translate

  • y (Float)

    coordinates to translate

Returns:

  • (Boolean)

    true if the coordinates were successfully translated

#widthInteger

The width of the surface in pixels.

Returns:

  • (Integer)

    width

#width=(width) ⇒ Integer

The width of the surface in pixels.

Parameters:

  • width (Integer)

Returns:

  • (Integer)

    width

  • (Integer)

    width