Top | ![]() |
![]() |
![]() |
![]() |
GdkCursor * | cursor | Read / Write |
GdkDisplay * | display | Read / Write / Construct Only |
GdkFrameClock * | frame-clock | Read / Write / Construct Only |
gboolean | mapped | Read |
gboolean | event | Run Last |
void | popup-layout-changed | Run First |
gboolean | render | Run Last |
void | size-changed | Run First |
GdkSurface | |
enum | GdkSurfaceHints |
GdkGeometry | |
enum | GdkGravity |
enum | GdkSurfaceEdge |
enum | GdkSurfaceTypeHint |
enum | GdkSurfaceState |
enum | GdkModifierType |
enum | GdkModifierIntent |
A GdkSurface is a (usually) rectangular region on the screen. It’s a low-level object, used to implement high-level objects such as GtkWindow on the GTK level.
GdkSurface * gdk_surface_new_toplevel (GdkDisplay *display
,int width
,int height
);
Creates a new toplevel surface.
[constructor]
GdkSurface * gdk_surface_new_popup (GdkSurface *parent
,gboolean autohide
);
Create a new popup surface.
The surface will be attached to parent
and can be positioned relative to it
using gdk_surface_show_popup()
or later using gdk_surface_layout_popup()
.
[constructor]
void
gdk_surface_destroy (GdkSurface *surface
);
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.
gboolean
gdk_surface_is_destroyed (GdkSurface *surface
);
Check to see if a surface is destroyed..
GdkDisplay *
gdk_surface_get_display (GdkSurface *surface
);
Gets the GdkDisplay associated with a GdkSurface.
void
gdk_surface_hide (GdkSurface *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()
.
gboolean
gdk_surface_is_viewable (GdkSurface *surface
);
Check if the surface and all ancestors of the surface are mapped. (This is not necessarily "viewable" in the X sense, since we only check as far as we have GDK surface parents, not to the root surface.)
gboolean
gdk_surface_get_mapped (GdkSurface *surface
);
Checks whether the surface has been mapped (with gdk_surface_show()
or
gdk_surface_show_unraised()
).
int
gdk_surface_get_width (GdkSurface *surface
);
Returns the width of the given surface
.
On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
int
gdk_surface_get_height (GdkSurface *surface
);
Returns the height of the given surface
.
On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
gboolean gdk_surface_translate_coordinates (GdkSurface *from
,GdkSurface *to
,double *x
,double *y
);
Translates the given coordinates from being
relative to the from
surface to being relative
to the to
surface.
Note that this only works if to
and from
are
popups or transient-for to the same toplevel
(directly or indirectly).
void gdk_surface_begin_resize_drag (GdkSurface *surface
,GdkSurfaceEdge edge
,GdkDevice *device
,gint button
,gint x
,gint y
,guint32 timestamp
);
Begins a surface resize operation (for a toplevel surface). You might use this function to implement a “window resize grip,”
surface |
a toplevel GdkSurface |
|
edge |
the edge or corner from which the drag is started |
|
device |
the device used for the operation |
|
button |
the button being used to drag, or 0 for a keyboard-initiated drag |
|
x |
surface X coordinate of mouse click that began the drag |
|
y |
surface Y coordinate of mouse click that began the drag |
|
timestamp |
timestamp of mouse click that began the drag (use |
void gdk_surface_begin_move_drag (GdkSurface *surface
,GdkDevice *device
,gint button
,gint x
,gint y
,guint32 timestamp
);
Begins a surface move operation (for a toplevel surface).
surface |
a toplevel GdkSurface |
|
device |
the device used for the operation |
|
button |
the button being used to drag, or 0 for a keyboard-initiated drag |
|
x |
surface X coordinate of mouse click that began the drag |
|
y |
surface Y coordinate of mouse click that began the drag |
|
timestamp |
timestamp of mouse click that began the drag |
void gdk_surface_constrain_size (GdkGeometry *geometry
,GdkSurfaceHints flags
,gint width
,gint height
,gint *new_width
,gint *new_height
);
Constrains a desired width and height according to a set of geometry hints (such as minimum and maximum size).
void
gdk_surface_beep (GdkSurface *surface
);
Emits a short beep associated to surface
in the appropriate
display, if supported. Otherwise, emits a short beep on
the display just as gdk_display_beep()
.
gint
gdk_surface_get_scale_factor (GdkSurface *surface
);
Returns the internal scale factor that maps from surface coordiantes 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, if this happens a configure event will be sent to the toplevel surface.
void gdk_surface_set_opaque_region (GdkSurface *surface
,cairo_region_t *region
);
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 “css-changed” handler.
GdkGLContext * gdk_surface_create_gl_context (GdkSurface *surface
,GError **error
);
Creates a new GdkGLContext matching the framebuffer format to the visual of 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 gdk_gl_context_make_current()
or gdk_gl_context_realize()
.
GdkVulkanContext * gdk_surface_create_vulkan_context (GdkSurface *surface
,GError **error
);
Creates a new GdkVulkanContext for rendering on surface
.
If the creation of the GdkVulkanContext failed, error
will be set.
GdkCairoContext *
gdk_surface_create_cairo_context (GdkSurface *surface
);
Creates a new GdkCairoContext for rendering on surface
.
void
gdk_surface_queue_expose (GdkSurface *surface
);
Forces an expose event for surface
to be scheduled.
If the invalid area of surface
is empty, an expose event will
still be emitted. Its invalid region will be empty.
This function is useful for implementations that track invalid regions on their own.
void
gdk_surface_freeze_updates (GdkSurface *surface
);
Temporarily freezes a surface such that it won’t receive expose
events. The surface will begin receiving expose events again when
gdk_surface_thaw_updates()
is called. If gdk_surface_freeze_updates()
has been called more than once, gdk_surface_thaw_updates()
must be called
an equal number of times to begin processing exposes.
void
gdk_surface_thaw_updates (GdkSurface *surface
);
Thaws a surface frozen with gdk_surface_freeze_updates()
. Note that this
will not necessarily schedule updates if the surface freeze count reaches
zero.
GdkFrameClock *
gdk_surface_get_frame_clock (GdkSurface *surface
);
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.
void gdk_surface_set_cursor (GdkSurface *surface
,GdkCursor *cursor
);
Sets the default mouse pointer for a GdkSurface.
Note that cursor
must be for the same display as surface
.
Use gdk_cursor_new_from_name()
or gdk_cursor_new_from_texture()
to
create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR
.
Passing NULL
for the cursor
argument to gdk_surface_set_cursor()
means
that surface
will use the cursor of its parent surface. Most surfaces
should use this default.
GdkCursor *
gdk_surface_get_cursor (GdkSurface *surface
);
Retrieves a GdkCursor pointer for the cursor currently set on the
specified GdkSurface, or NULL
. 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.
a GdkCursor, or NULL
. The
returned object is owned by the GdkSurface and should not be
unreferenced directly. Use gdk_surface_set_cursor()
to unset the
cursor of the surface.
[nullable][transfer none]
void gdk_surface_set_device_cursor (GdkSurface *surface
,GdkDevice *device
,GdkCursor *cursor
);
Sets a specific GdkCursor for a given device when it gets inside surface
.
Use gdk_cursor_new_fromm_name()
or gdk_cursor_new_from_texture()
to create
the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR
. Passing
NULL
for the cursor
argument to gdk_surface_set_cursor()
means that
surface
will use the cursor of its parent surface. Most surfaces should
use this default.
GdkCursor * gdk_surface_get_device_cursor (GdkSurface *surface
,GdkDevice *device
);
Retrieves a GdkCursor pointer for the device
currently set on the
specified GdkSurface, or NULL
. 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.
a GdkCursor, or NULL
. The
returned object is owned by the GdkSurface and should not be
unreferenced directly. Use gdk_surface_set_cursor()
to unset the
cursor of the surface.
[nullable][transfer none]
void gdk_surface_set_input_region (GdkSurface *surface
,cairo_region_t *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 surface
.
An input shape 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 shape controls where the surface is “clickable”.
On the X11 platform, this requires version 1.1 of the shape extension.
On the Win32 platform, this functionality is not present and the function does nothing.
void gdk_surface_set_shadow_width (GdkSurface *surface
,gint left
,gint right
,gint top
,gint bottom
);
Newer GTK windows using client-side decorations use extra geometry around their frames for effects like shadows and invisible borders. Window managers that want to maximize windows or snap to edges need to know where the extents of the actual frame lie, so that users don’t feel like windows are snapping against random invisible edges.
Note that this property is automatically updated by GTK, so this function should only be used by applications which do not use GTK to create toplevel surfaces.
void gdk_surface_get_device_position (GdkSurface *surface
,GdkDevice *device
,double *x
,double *y
,GdkModifierType *mask
);
Obtains the current device position in doubles and modifier state.
The position is given in coordinates relative to the upper left
corner of surface
.
surface |
a GdkSurface. |
|
device |
pointer GdkDevice to query to. |
|
x |
return location for the X coordinate of |
[out][allow-none] |
y |
return location for the Y coordinate of |
[out][allow-none] |
mask |
return location for the modifier mask, or |
[out][allow-none] |
gboolean
gdk_surface_get_support_multidevice (GdkSurface *surface
);
Returns TRUE
if the surface is aware of the existence of multiple
devices.
void gdk_surface_set_support_multidevice (GdkSurface *surface
,gboolean support_multidevice
);
This function will enable multidevice features in surface
.
Multidevice aware surfaces will need to handle properly multiple, per device enter/leave events, device grabs and grab ownerships.
surface |
a GdkSurface. |
|
support_multidevice |
|
“cursor”
property“cursor” GdkCursor *
The mouse pointer for a GdkSurface. See gdk_surface_set_cursor()
and
gdk_surface_get_cursor()
for details.
Owner: GdkSurface
Flags: Read / Write
“display”
property“display” GdkDisplay *
The GdkDisplay connection of the surface. See gdk_surface_get_display()
for details.
Owner: GdkSurface
Flags: Read / Write / Construct Only
“frame-clock”
property“frame-clock” GdkFrameClock *
Frame Clock.
Owner: GdkSurface
Flags: Read / Write / Construct Only
“event”
signalgboolean user_function (GdkSurface *surface, GdkEvent *event, gpointer user_data)
Emitted when GDK receives an input event for surface
.
surface |
the GdkSurface |
|
event |
an input event |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“popup-layout-changed”
signalvoid user_function (GdkSurface *surface, gpointer user_data)
Emitted when the layout of a popup surface
has changed, e.g. if the popup
layout was reactive and after the parent moved causing the popover to end
up partially off-screen.
surface |
the GdkSurface that was laid out |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“render”
signalgboolean user_function (GdkSurface *surface, CairoRegion *region, gpointer user_data)
Emitted when part of the surface needs to be redrawn.
surface |
the GdkSurface |
|
region |
the region that needs to be redrawn |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“size-changed”
signalvoid user_function (GdkSurface *surface, gint width, gint height, gpointer user_data)
Emitted when the size of surface
is changed.
surface |
the GdkSurface |
|
width |
the new width |
|
height |
the new height |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First