bare-gtk 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.c +3 -0
- package/lib/native.h +41 -0
- package/lib/surface.d.ts +3 -0
- package/lib/surface.h +38 -0
- package/lib/surface.js +4 -0
- package/lib/widget.d.ts +3 -0
- package/lib/widget.h +58 -0
- package/lib/widget.js +4 -0
- package/lib/window.d.ts +6 -0
- package/lib/window.js +4 -0
- package/package.json +2 -1
- package/prebuilds/linux-arm64/bare +1 -1
- package/prebuilds/linux-arm64/bare-gtk.bare +0 -0
- package/prebuilds/linux-x64/bare +1 -1
- package/prebuilds/linux-x64/bare-gtk.bare +0 -0
package/binding.c
CHANGED
|
@@ -125,6 +125,7 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
|
|
|
125
125
|
V("widgetScaleFactor", bare_gtk_widget_scale_factor)
|
|
126
126
|
V("widgetNative", bare_gtk_widget_native)
|
|
127
127
|
V("widgetComputeBounds", bare_gtk_widget_compute_bounds)
|
|
128
|
+
V("widgetComputePoint", bare_gtk_widget_compute_point)
|
|
128
129
|
V("widgetMeasure", bare_gtk_widget_measure)
|
|
129
130
|
V("widgetAddCssClass", bare_gtk_widget_add_css_class)
|
|
130
131
|
V("widgetRemoveCssClass", bare_gtk_widget_remove_css_class)
|
|
@@ -244,11 +245,13 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
|
|
|
244
245
|
V("monitorValid", bare_gtk_monitor_valid)
|
|
245
246
|
|
|
246
247
|
V("nativeSurface", bare_gtk_native_surface)
|
|
248
|
+
V("nativeSurfaceTransform", bare_gtk_native_surface_transform)
|
|
247
249
|
|
|
248
250
|
V("surfaceWidth", bare_gtk_surface_width)
|
|
249
251
|
V("surfaceHeight", bare_gtk_surface_height)
|
|
250
252
|
V("surfaceScaleFactor", bare_gtk_surface_scale_factor)
|
|
251
253
|
V("surfaceDisplay", bare_gtk_surface_display)
|
|
254
|
+
V("surfaceXid", bare_gtk_surface_xid)
|
|
252
255
|
|
|
253
256
|
V("applicationGetDefault", bare_gtk_application_get_default)
|
|
254
257
|
V("applicationActiveWindow", bare_gtk_application_active_window)
|
package/lib/native.h
CHANGED
|
@@ -28,4 +28,45 @@ bare_gtk_native_surface(js_env_t *env, js_callback_info_t *info) {
|
|
|
28
28
|
return bare_gtk__create_tag(env, state, gtk_native_get_surface(native));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
static js_value_t *
|
|
32
|
+
bare_gtk_native_surface_transform(js_env_t *env, js_callback_info_t *info) {
|
|
33
|
+
int err;
|
|
34
|
+
|
|
35
|
+
size_t argc = 1;
|
|
36
|
+
js_value_t *argv[1];
|
|
37
|
+
|
|
38
|
+
bare_gtk_state_t *state;
|
|
39
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
40
|
+
assert(err == 0);
|
|
41
|
+
|
|
42
|
+
assert(argc == 1);
|
|
43
|
+
|
|
44
|
+
GtkNative *native;
|
|
45
|
+
err = bare_gobject_read_tag(env, state->registry, argv[0], "native", (gpointer *) &native);
|
|
46
|
+
if (err < 0) return NULL;
|
|
47
|
+
|
|
48
|
+
double x, y;
|
|
49
|
+
gtk_native_get_surface_transform(native, &x, &y);
|
|
50
|
+
|
|
51
|
+
js_value_t *result;
|
|
52
|
+
err = js_create_array_with_length(env, 2, &result);
|
|
53
|
+
assert(err == 0);
|
|
54
|
+
|
|
55
|
+
js_value_t *val;
|
|
56
|
+
|
|
57
|
+
err = js_create_double(env, x, &val);
|
|
58
|
+
assert(err == 0);
|
|
59
|
+
|
|
60
|
+
err = js_set_element(env, result, 0, val);
|
|
61
|
+
assert(err == 0);
|
|
62
|
+
|
|
63
|
+
err = js_create_double(env, y, &val);
|
|
64
|
+
assert(err == 0);
|
|
65
|
+
|
|
66
|
+
err = js_set_element(env, result, 1, val);
|
|
67
|
+
assert(err == 0);
|
|
68
|
+
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
31
72
|
#endif // BARE_GTK_NATIVE_H
|
package/lib/surface.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ interface GDKSurface extends GObject {
|
|
|
10
10
|
readonly scaleFactor: number
|
|
11
11
|
|
|
12
12
|
readonly display: GDKDisplay | null
|
|
13
|
+
|
|
14
|
+
/** The X11 window of the surface, as `gdk_x11_surface_get_xid()`, or `null` if GDK is not on X11. */
|
|
15
|
+
readonly xid: number | null
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
declare class GDKSurface {
|
package/lib/surface.h
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
#include <gtk/gtk.h>
|
|
8
8
|
|
|
9
|
+
#ifdef GDK_WINDOWING_X11
|
|
10
|
+
#include <gdk/x11/gdkx.h>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
9
13
|
#include "bridging.h"
|
|
10
14
|
|
|
11
15
|
#define V(name, fn) \
|
|
@@ -58,4 +62,38 @@ bare_gtk_surface_display(js_env_t *env, js_callback_info_t *info) {
|
|
|
58
62
|
return bare_gtk__create_tag(env, state, gdk_surface_get_display(surface));
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
static js_value_t *
|
|
66
|
+
bare_gtk_surface_xid(js_env_t *env, js_callback_info_t *info) {
|
|
67
|
+
int err;
|
|
68
|
+
|
|
69
|
+
size_t argc = 1;
|
|
70
|
+
js_value_t *argv[1];
|
|
71
|
+
|
|
72
|
+
bare_gtk_state_t *state;
|
|
73
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
74
|
+
assert(err == 0);
|
|
75
|
+
|
|
76
|
+
assert(argc == 1);
|
|
77
|
+
|
|
78
|
+
GdkSurface *surface;
|
|
79
|
+
err = bare_gobject_read_tag(env, state->registry, argv[0], "surface", (gpointer *) &surface);
|
|
80
|
+
if (err < 0) return NULL;
|
|
81
|
+
|
|
82
|
+
js_value_t *result;
|
|
83
|
+
|
|
84
|
+
#ifdef GDK_WINDOWING_X11
|
|
85
|
+
if (GDK_IS_X11_SURFACE(surface)) {
|
|
86
|
+
err = js_create_uint32(env, (uint32_t) gdk_x11_surface_get_xid(surface), &result);
|
|
87
|
+
assert(err == 0);
|
|
88
|
+
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
#endif
|
|
92
|
+
|
|
93
|
+
err = js_get_null(env, &result);
|
|
94
|
+
assert(err == 0);
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
61
99
|
#endif // BARE_GTK_SURFACE_H
|
package/lib/surface.js
CHANGED
|
@@ -16,6 +16,10 @@ module.exports = exports = class GDKSurface extends GObject {
|
|
|
16
16
|
return binding.surfaceScaleFactor(this._tag)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
get xid() {
|
|
20
|
+
return binding.surfaceXid(this._tag)
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
get display() {
|
|
20
24
|
return wrap(GDKDisplay, binding.surfaceDisplay(this._tag))
|
|
21
25
|
}
|
package/lib/widget.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ interface GTKWidget<M extends Record<keyof M, unknown[]> = {}> extends GObject<M
|
|
|
83
83
|
/** The bounds of the widget in the coordinates of `target`, or `null` if they are unrelated. */
|
|
84
84
|
computeBounds(target: GTKWidget): [x: number, y: number, width: number, height: number] | null
|
|
85
85
|
|
|
86
|
+
/** The point `x`, `y` of the widget in the coordinates of `target`, or `null` if they are unrelated. */
|
|
87
|
+
computePoint(target: GTKWidget, x: number, y: number): [x: number, y: number] | null
|
|
88
|
+
|
|
86
89
|
/** Add the widget to `parent`, after `previousSibling`, or first when that is `null`. */
|
|
87
90
|
insertAfter(parent: GTKWidget, previousSibling?: GTKWidget | null): this
|
|
88
91
|
|
package/lib/widget.h
CHANGED
|
@@ -567,6 +567,64 @@ bare_gtk_widget_compute_bounds(js_env_t *env, js_callback_info_t *info) {
|
|
|
567
567
|
return result;
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
+
static js_value_t *
|
|
571
|
+
bare_gtk_widget_compute_point(js_env_t *env, js_callback_info_t *info) {
|
|
572
|
+
int err;
|
|
573
|
+
|
|
574
|
+
size_t argc = 4;
|
|
575
|
+
js_value_t *argv[4];
|
|
576
|
+
|
|
577
|
+
bare_gtk_state_t *state;
|
|
578
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
579
|
+
assert(err == 0);
|
|
580
|
+
|
|
581
|
+
assert(argc == 4);
|
|
582
|
+
|
|
583
|
+
GtkWidget *widget;
|
|
584
|
+
err = bare_gobject_read_tag(env, state->registry, argv[0], "widget", (gpointer *) &widget);
|
|
585
|
+
if (err < 0) return NULL;
|
|
586
|
+
|
|
587
|
+
GtkWidget *target;
|
|
588
|
+
err = bare_gobject_read_tag(env, state->registry, argv[1], "target", (gpointer *) &target);
|
|
589
|
+
if (err < 0) return NULL;
|
|
590
|
+
|
|
591
|
+
double x;
|
|
592
|
+
err = js_get_value_double(env, argv[2], &x);
|
|
593
|
+
assert(err == 0);
|
|
594
|
+
|
|
595
|
+
double y;
|
|
596
|
+
err = js_get_value_double(env, argv[3], &y);
|
|
597
|
+
assert(err == 0);
|
|
598
|
+
|
|
599
|
+
graphene_point_t point;
|
|
600
|
+
|
|
601
|
+
js_value_t *result;
|
|
602
|
+
|
|
603
|
+
if (!gtk_widget_compute_point(widget, target, &GRAPHENE_POINT_INIT(x, y), &point)) {
|
|
604
|
+
err = js_get_null(env, &result);
|
|
605
|
+
assert(err == 0);
|
|
606
|
+
|
|
607
|
+
return result;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
err = js_create_array_with_length(env, 2, &result);
|
|
611
|
+
assert(err == 0);
|
|
612
|
+
|
|
613
|
+
#define V(i, d) \
|
|
614
|
+
{ \
|
|
615
|
+
js_value_t *val; \
|
|
616
|
+
err = js_create_double(env, d, &val); \
|
|
617
|
+
assert(err == 0); \
|
|
618
|
+
err = js_set_element(env, result, i, val); \
|
|
619
|
+
assert(err == 0); \
|
|
620
|
+
}
|
|
621
|
+
V(0, point.x)
|
|
622
|
+
V(1, point.y)
|
|
623
|
+
#undef V
|
|
624
|
+
|
|
625
|
+
return result;
|
|
626
|
+
}
|
|
627
|
+
|
|
570
628
|
static js_value_t *
|
|
571
629
|
bare_gtk_widget_measure(js_env_t *env, js_callback_info_t *info) {
|
|
572
630
|
int err;
|
package/lib/widget.js
CHANGED
|
@@ -154,6 +154,10 @@ module.exports = exports = class GTKWidget extends GObject {
|
|
|
154
154
|
return binding.widgetComputeBounds(this._tag, target._tag)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
computePoint(target, x, y) {
|
|
158
|
+
return binding.widgetComputePoint(this._tag, target._tag, x, y)
|
|
159
|
+
}
|
|
160
|
+
|
|
157
161
|
insertAfter(parent, previousSibling = null) {
|
|
158
162
|
binding.widgetInsertAfter(
|
|
159
163
|
this._tag,
|
package/lib/window.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ interface GTKWindow extends GTKWidget<GTKWindow.Events> {
|
|
|
6
6
|
/** The surface the window draws on, or `null` before it is shown. */
|
|
7
7
|
readonly surface: GDKSurface | null
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Where the window is drawn within its surface, as `gtk_native_get_surface_transform()`. Client
|
|
11
|
+
* side decorations, such as a shadow, take up the rest.
|
|
12
|
+
*/
|
|
13
|
+
readonly surfaceTransform: [x: number, y: number]
|
|
14
|
+
|
|
9
15
|
title: string | null
|
|
10
16
|
|
|
11
17
|
/** The size the window opens at, as `[width, height]`. */
|
package/lib/window.js
CHANGED
|
@@ -22,6 +22,10 @@ module.exports = exports = class GTKWindow extends GTKWidget {
|
|
|
22
22
|
return wrap(GDKSurface, binding.nativeSurface(this._tag))
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
get surfaceTransform() {
|
|
26
|
+
return binding.nativeSurfaceTransform(this._tag)
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
get title() {
|
|
26
30
|
return binding.windowTitle(this._tag)
|
|
27
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-gtk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "GTK bindings and runtime for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"bare-gtk": "file:.",
|
|
53
53
|
"bare-native-test": "^0.1.0",
|
|
54
54
|
"bare-tap": "^1.1.0",
|
|
55
|
+
"bare-x11": "^0.1.0",
|
|
55
56
|
"cmake-bare": "^1.6.5",
|
|
56
57
|
"cmake-fetch": "^1.4.0",
|
|
57
58
|
"lunte": "^1.8.0",
|
|
Binary file
|
package/prebuilds/linux-x64/bare
CHANGED
|
Binary file
|