Gdk.Surface¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
|||
r/w/co |
|||
r/w/co |
|||
r |
|||
r |
|||
r |
|||
r |
|||
r |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when surface starts being present on the monitor. |
|
Emitted when GDK receives an input event for surface. |
|
Emitted when the size of surface is changed, or when relayout should be performed. |
|
Emitted when surface stops being present on the monitor. |
|
Emitted when part of the surface needs to be redrawn. |
Fields¶
- Inherited:
Class Details¶
- class Gdk.Surface(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
A
GdkSurface
is 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 [iface`Gdk`.Toplevel] or [iface`Gdk`.Popup], 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.
- classmethod new_popup(parent, autohide)[source]¶
- Parameters:
parent (
Gdk.Surface
) – the parent surface to attach the surface toautohide (
bool
) – whether to hide the surface on outside clicks
- Returns:
a new
GdkSurface
- Return type:
Create a new popup surface.
The surface will be attached to parent and can be positioned relative to it using [method`Gdk`.Popup.present].
- classmethod new_toplevel(display)[source]¶
- Parameters:
display (
Gdk.Display
) – the display to create the surface on- Returns:
the new
GdkSurface
- Return type:
Creates a new toplevel surface.
- beep()[source]¶
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 [method`Gdk`.Display.beep].
- create_cairo_context()[source]¶
- Returns:
the newly created
GdkCairoContext
- Return type:
Creates a new
GdkCairoContext
for rendering on self.
- create_gl_context()[source]¶
- Raises:
- Returns:
the newly created
GdkGLContext
- Return type:
Creates a new
GdkGLContext
for theGdkSurface
.The context is disconnected from any particular surface or surface. If the creation of the
GdkGLContext
failed, error will be set. Before using the returnedGdkGLContext
, you will need to call [method`Gdk`.GLContext.make_current] or [method`Gdk`.GLContext.realize].
- create_similar_surface(content, width, height)[source]¶
- Parameters:
content (
cairo.Content
) – the content for the new surfacewidth (
int
) – width of the new surfaceheight (
int
) – height of the new surface
- Returns:
a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.
- Return type:
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.
Deprecated since version 4.12: Create a suitable cairo image surface yourself
- create_vulkan_context()[source]¶
- Raises:
- Returns:
- Return type:
Sets an error and returns
None
.Deprecated since version 4.14: GTK does not expose any Vulkan internals. This function is a leftover that was accidentally exposed.
- destroy()[source]¶
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.
- get_cursor()[source]¶
- Returns:
a
GdkCursor
- Return type:
Gdk.Cursor
orNone
Retrieves a
GdkCursor
pointer for the cursor currently set on theGdkSurface
.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 [method`Gdk`.Surface.set_cursor] to unset the cursor of the surface.
- get_device_cursor(device)[source]¶
- Parameters:
device (
Gdk.Device
) – a pointerGdkDevice
- Returns:
a
GdkCursor
- Return type:
Gdk.Cursor
orNone
Retrieves a
GdkCursor
pointer for the device currently set on the specifiedGdkSurface
.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 [method`Gdk`.Surface.set_cursor] to unset the cursor of the surface.
- get_device_position(device)[source]¶
- Parameters:
device (
Gdk.Device
) – pointerGdkDevice
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
- Return type:
(
bool
, x:float
, y:float
, mask:Gdk.ModifierType
)
Obtains the current device position and modifier state.
The position is given in coordinates relative to the upper left corner of self.
- get_display()[source]¶
- Returns:
the
GdkDisplay
associated with self- Return type:
Gets the
GdkDisplay
associated with aGdkSurface
.
- get_frame_clock()[source]¶
- Returns:
the frame clock
- Return type:
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.
- get_height()[source]¶
- Returns:
The height of self
- Return type:
Returns the height of the given self.
Surface size is reported in ”application pixels”, not ”device pixels” (see [method`Gdk`.Surface.get_scale_factor]).
- get_mapped()[source]¶
-
Checks whether the surface has been mapped.
A surface is mapped with [method`Gdk`.Toplevel.present] or [method`Gdk`.Popup.present].
- get_scale()[source]¶
- Returns:
the scale
- Return type:
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.
New in version 4.12.
- get_scale_factor()[source]¶
- Returns:
the scale factor
- Return type:
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.
- get_width()[source]¶
- Returns:
The width of self
- Return type:
Returns the width of the given self.
Surface size is reported in ”application pixels”, not ”device pixels” (see [method`Gdk`.Surface.get_scale_factor]).
- hide()[source]¶
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().
- queue_render()[source]¶
Forces a [signal`Gdk`.Surface::render] signal emission for self to be scheduled.
This function is useful for implementations that track invalid regions on their own.
- request_layout()[source]¶
Request a layout phase from the surface’s frame clock.
See [method`Gdk`.FrameClock.request_phase].
- set_cursor(cursor)[source]¶
- Parameters:
cursor (
Gdk.Cursor
orNone
) – aGdkCursor
Sets the default mouse pointer for a
GdkSurface
.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 [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.
- set_device_cursor(device, cursor)[source]¶
- Parameters:
device (
Gdk.Device
) – a pointerGdkDevice
cursor (
Gdk.Cursor
) – aGdkCursor
Sets a specific
GdkCursor
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 [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.
- set_input_region(region)[source]¶
- Parameters:
region (
cairo.Region
) – region of surface to be reactive
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 [method`Gdk`.Display.supports_input_shapes] to find out if a particular backend supports input regions.
- set_opaque_region(region)[source]¶
- Parameters:
region (
cairo.Region
orNone
) – a region, orNone
to make the entire surface opaque
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.
Deprecated since version 4.16: GDK can figure out the opaque parts of a window itself by inspecting the contents that are drawn.
- translate_coordinates(to, x, y)[source]¶
- Parameters:
to (
Gdk.Surface
) – the target surfacex (
float
) – coordinates to translatey (
float
) – coordinates to translate
- Returns:
True
if the coordinates were successfully translated- x:
coordinates to translate
- y:
coordinates to translate
- Return type:
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).
Signal Details¶
- Gdk.Surface.signals.enter_monitor(surface, monitor)¶
- Signal Name:
enter-monitor
- Flags:
- Parameters:
surface (
Gdk.Surface
) – The object which received the signalmonitor (
Gdk.Monitor
) – the monitor
Emitted when surface starts being present on the monitor.
- Gdk.Surface.signals.event(surface, event)¶
- Signal Name:
event
- Flags:
- Parameters:
surface (
Gdk.Surface
) – The object which received the signalevent (
Gdk.Event
) – an input event
- Returns:
True
to indicate that the event has been handled- Return type:
Emitted when GDK receives an input event for surface.
- Gdk.Surface.signals.layout(surface, width, height)¶
- Signal Name:
layout
- Flags:
- Parameters:
surface (
Gdk.Surface
) – The object which received the signalwidth (
int
) – the current widthheight (
int
) – the current 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
Gdk.Surface.get_scale_factor
()).
- Gdk.Surface.signals.leave_monitor(surface, monitor)¶
- Signal Name:
leave-monitor
- Flags:
- Parameters:
surface (
Gdk.Surface
) – The object which received the signalmonitor (
Gdk.Monitor
) – the monitor
Emitted when surface stops being present on the monitor.
- Gdk.Surface.signals.render(surface, region)¶
- Signal Name:
render
- Flags:
- Parameters:
surface (
Gdk.Surface
) – The object which received the signalregion (
cairo.Region
) – the region that needs to be redrawn
- Returns:
True
to indicate that the signal has been handled- Return type:
Emitted when part of the surface needs to be redrawn.
Property Details¶
- Gdk.Surface.props.cursor¶
- Name:
cursor
- Type:
- Default Value:
- Flags:
The mouse pointer for the
GdkSurface
.
- Gdk.Surface.props.display¶
- Name:
display
- Type:
- Default Value:
- Flags:
The
GdkDisplay
connection of the surface.
- Gdk.Surface.props.frame_clock¶
- Name:
frame-clock
- Type:
- Default Value:
- Flags:
The
GdkFrameClock
of the surface.
- Gdk.Surface.props.height¶
-
The height of the surface, in pixels.
- Gdk.Surface.props.mapped¶
-
Whether the surface is mapped.
- Gdk.Surface.props.scale¶
-
The scale of the surface.
New in version 4.12.
- Gdk.Surface.props.scale_factor¶
-
The scale factor of the surface.
The scale factor is the next larger integer, compared to [property`Gdk`.Surface:scale].