Package ch.bailu.gtk.gdk
Class Surface
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gdk.Surface
- All Implemented Interfaces:
PointerInterface
A `GdkSurface` is a rectangular region on the screen.
It’s a low-level object, used to implement high-level objects
such as [class@Gtk.Window] or [class@Gtk.Dialog] in GTK.
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.
It’s a low-level object, used to implement high-level objects
such as [class@Gtk.Window] or [class@Gtk.Dialog] in GTK.
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
beep()
Emits a short beep associated to @surface.Creates a new `GdkCairoContext` for rendering on @surface.Creates a new `GdkGLContext` for the `GdkSurface`.createSimilarSurface
(int content, int width, int height) Create a new Cairo surface that is as compatible as possible with the
given @surface.Creates a new `GdkVulkanContext` for rendering on @surface.void
destroy()
Destroys the window system resources associated with @surface and
decrements @surface's reference count.static ClassHandler
Retrieves a `GdkCursor` pointer for the cursor currently set on the
`GdkSurface`.getDeviceCursor
(Device device) Retrieves a `GdkCursor` pointer for the @device currently set on the
specified `GdkSurface`.Gets the `GdkDisplay` associated with a `GdkSurface`.Gets the frame clock for the surface.int
Returns the height of the given @surface.static int
boolean
Checks whether the surface has been mapped.static long
static TypeSystem.TypeSize
int
Returns the internal scale factor that maps from surface coordinates
to the actual device pixels.static long
static TypeSystem.TypeSize
int
getWidth()
Returns the width of the given @surface.void
hide()
Hide the surface.boolean
Check to see if a surface is destroyed.static Surface
newPopupSurface
(Surface parent, boolean autohide) Create a new popup surface.static Surface
newToplevelSurface
(Display display) Creates a new toplevel surface.onEnterMonitor
(Surface.OnEnterMonitor signal) Connect to signal "enter-monitor".onEvent
(Surface.OnEvent signal) Connect to signal "event".onLayout
(Surface.OnLayout signal) Connect to signal "layout".onLeaveMonitor
(Surface.OnLeaveMonitor signal) Connect to signal "leave-monitor".onRender
(Surface.OnRender signal) Connect to signal "render".void
Forces a [signal@Gdk.Surface::render] signal emission for @surface
to be scheduled.void
Request a layout phase from the surface's frame clock.void
Sets the default mouse pointer for a `GdkSurface`.void
setDeviceCursor
(Device device, Cursor cursor) Sets a specific `GdkCursor` for a given device when it gets inside @surface.void
setInputRegion
(Region region) Apply the region to the surface for the purpose of event
handling.void
setOpaqueRegion
(Region region) Marks a region of the `GdkSurface` as opaque.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_ENTER_MONITOR
- See Also:
-
SIGNAL_ON_EVENT
- See Also:
-
SIGNAL_ON_LAYOUT
- See Also:
-
SIGNAL_ON_LEAVE_MONITOR
- See Also:
-
SIGNAL_ON_RENDER
- See Also:
-
-
Constructor Details
-
Surface
-
-
Method Details
-
getClassHandler
-
newPopupSurface
Create a new popup surface.
The surface will be attached to @parent and can be positioned
relative to it using [method@Gdk.Popup.present].- Parameters:
parent
- the parent surface to attach the surface toautohide
- whether to hide the surface on outside clicks- Returns:
- a new `GdkSurface`
-
newToplevelSurface
Creates a new toplevel surface.- Parameters:
display
- the display to create the surface on- Returns:
- the new `GdkSurface`
-
beep
public void beep()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]. -
createCairoContext
Creates a new `GdkCairoContext` for rendering on @surface.- Returns:
- the newly created `GdkCairoContext`
-
createGlContext
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].- Returns:
- the newly created `GdkGLContext`
- Throws:
AllocationError
-
createSimilarSurface
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
- the content for the new surfacewidth
- width of the new surfaceheight
- 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.
-
createVulkanContext
Creates a new `GdkVulkanContext` for rendering on @surface.
If the creation of the `GdkVulkanContext` failed, @error will be set.- Returns:
- the newly created `GdkVulkanContext`, or %NULL on error
- Throws:
AllocationError
-
destroy
public void destroy()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. -
getCursor
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.- Returns:
- a `GdkCursor`
-
getDeviceCursor
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.- Parameters:
device
- a pointer `GdkDevice`- Returns:
- a `GdkCursor`
-
getDisplay
Gets the `GdkDisplay` associated with a `GdkSurface`.- Returns:
- the `GdkDisplay` associated with @surface
-
getFrameClock
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.- Returns:
- the frame clock
-
getHeight
public int getHeight()Returns the height of the given @surface.
Surface size is reported in ”application pixels”, not
”device pixels” (see [method@Gdk.Surface.get_scale_factor]).- Returns:
- The height of @surface
-
getMapped
public boolean getMapped()Checks whether the surface has been mapped.
A surface is mapped with [method@Gdk.Toplevel.present]
or [method@Gdk.Popup.present].- Returns:
- %TRUE if the surface is mapped
-
getScaleFactor
public int getScaleFactor()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 of a surface may change during runtime.- Returns:
- the scale factor
-
getWidth
public int getWidth()Returns the width of the given @surface.
Surface size is reported in ”application pixels”, not
”device pixels” (see [method@Gdk.Surface.get_scale_factor]).- Returns:
- The width of @surface
-
hide
public void hide()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 [method@Gtk.Widget.hide]. -
isDestroyed
public boolean isDestroyed()Check to see if a surface is destroyed.- Returns:
- %TRUE if the surface is destroyed
-
queueRender
public void queueRender()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. -
requestLayout
public void requestLayout()Request a layout phase from the surface's frame clock.
See [method@Gdk.FrameClock.request_phase]. -
setCursor
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.- Parameters:
cursor
- a `GdkCursor`
-
setDeviceCursor
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.- Parameters:
device
- a pointer `GdkDevice`cursor
- a `GdkCursor`
-
setInputRegion
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.- Parameters:
region
- region of surface to be reactive
-
setOpaqueRegion
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
[vfunc@Gtk.Widget.css_changed] handler.- Parameters:
region
- a region, or %NULL to make the entire surface opaque
-
onEnterMonitor
Connect to signal "enter-monitor".
SeeSurface.OnEnterMonitor.onEnterMonitor(ch.bailu.gtk.gdk.Monitor)
for signal description.
FieldSIGNAL_ON_ENTER_MONITOR
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onEvent
Connect to signal "event".
SeeSurface.OnEvent.onEvent(ch.bailu.gtk.type.Pointer)
for signal description.
FieldSIGNAL_ON_EVENT
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onLayout
Connect to signal "layout".
SeeSurface.OnLayout.onLayout(int, int)
for signal description.
FieldSIGNAL_ON_LAYOUT
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onLeaveMonitor
Connect to signal "leave-monitor".
SeeSurface.OnLeaveMonitor.onLeaveMonitor(ch.bailu.gtk.gdk.Monitor)
for signal description.
FieldSIGNAL_ON_LEAVE_MONITOR
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onRender
Connect to signal "render".
SeeSurface.OnRender.onRender(ch.bailu.gtk.cairo.Region)
for signal description.
FieldSIGNAL_ON_RENDER
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-