bare-gtk 0.4.5 → 0.4.6
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/lib/runtime.c
CHANGED
|
@@ -19,9 +19,12 @@ static uv_loop_t *bare__loop;
|
|
|
19
19
|
static uv_async_t bare__shutdown;
|
|
20
20
|
static bare_t *bare;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
typedef struct {
|
|
23
|
+
GSource source;
|
|
24
|
+
gpointer poll;
|
|
25
|
+
} bare__source_t;
|
|
26
|
+
|
|
27
|
+
static GSource *bare__source;
|
|
25
28
|
|
|
26
29
|
static bool bare__exited;
|
|
27
30
|
|
|
@@ -63,49 +66,53 @@ bare__on_platform_thread(void *data) {
|
|
|
63
66
|
assert(err == 0);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
// GLib asks a source for its timeout before every poll, so a timer is waited
|
|
70
|
+
// for wherever it was set, including from GTK callbacks that run outside the
|
|
71
|
+
// loop of the runtime.
|
|
69
72
|
static gboolean
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
bare__on_prepare(GSource *source, gint *timeout) {
|
|
74
|
+
if (bare__exited) {
|
|
75
|
+
*timeout = -1;
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
return FALSE;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
uv_update_time(bare__loop);
|
|
81
|
+
|
|
82
|
+
*timeout = uv_backend_timeout(bare__loop);
|
|
83
|
+
|
|
84
|
+
return *timeout == 0;
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
static gboolean
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
bare__on_check(GSource *source) {
|
|
89
|
+
if (bare__exited) return FALSE;
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
bare__source_t *self = (bare__source_t *) source;
|
|
81
92
|
|
|
82
|
-
return
|
|
83
|
-
}
|
|
93
|
+
if (g_source_query_unix_fd(source, self->poll) & G_IO_IN) return TRUE;
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
bare__run(void) {
|
|
87
|
-
int err;
|
|
95
|
+
uv_update_time(bare__loop);
|
|
88
96
|
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
return uv_backend_timeout(bare__loop) == 0;
|
|
98
|
+
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
static gboolean
|
|
101
|
+
bare__on_dispatch(GSource *source, GSourceFunc callback, gpointer data) {
|
|
102
|
+
int err;
|
|
94
103
|
|
|
95
104
|
err = bare_run(bare, UV_RUN_NOWAIT);
|
|
96
105
|
assert(err >= 0);
|
|
97
106
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
int timeout = uv_backend_timeout(bare__loop);
|
|
101
|
-
|
|
102
|
-
if (timeout == 0) {
|
|
103
|
-
bare__timer = g_idle_add(bare__on_timeout, NULL);
|
|
104
|
-
} else if (timeout > 0) {
|
|
105
|
-
bare__timer = g_timeout_add(timeout, bare__on_timeout, NULL);
|
|
106
|
-
}
|
|
107
|
+
return G_SOURCE_CONTINUE;
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
static GSourceFuncs bare__source_funcs = {
|
|
111
|
+
.prepare = bare__on_prepare,
|
|
112
|
+
.check = bare__on_check,
|
|
113
|
+
.dispatch = bare__on_dispatch,
|
|
114
|
+
};
|
|
115
|
+
|
|
109
116
|
static void
|
|
110
117
|
bare__on_exit(bare_t *bare, void *data) {
|
|
111
118
|
bare__exited = true;
|
|
@@ -146,13 +153,13 @@ bare__on_startup(GtkApplication *app, gpointer data) {
|
|
|
146
153
|
err = bare_load(bare, entry, NULL, NULL);
|
|
147
154
|
(void) err;
|
|
148
155
|
|
|
149
|
-
|
|
156
|
+
bare__source = g_source_new(&bare__source_funcs, sizeof(bare__source_t));
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
bare__source_t *self = (bare__source_t *) bare__source;
|
|
152
159
|
|
|
153
|
-
|
|
160
|
+
self->poll = g_source_add_unix_fd(bare__source, uv_backend_fd(bare__loop), G_IO_IN);
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
g_source_attach(bare__source, NULL);
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
int
|
|
@@ -242,11 +249,9 @@ main(int argc, char *argv[]) {
|
|
|
242
249
|
|
|
243
250
|
g_application_run(G_APPLICATION(app), argc, argv);
|
|
244
251
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (bare__timer) g_source_remove(bare__timer);
|
|
252
|
+
g_source_destroy(bare__source);
|
|
248
253
|
|
|
249
|
-
|
|
254
|
+
g_source_unref(bare__source);
|
|
250
255
|
|
|
251
256
|
err = uv_async_send(&bare__shutdown);
|
|
252
257
|
assert(err == 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-gtk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "GTK bindings and runtime for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/holepunchto/bare-gtk#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"bare-events": "^2.8.2",
|
|
44
45
|
"bare-gobject-registry": "^0.1.0",
|
|
45
46
|
"require-asset": "^1.1.0"
|
|
46
47
|
},
|
|
Binary file
|
package/prebuilds/linux-x64/bare
CHANGED
|
Binary file
|