bare-gtk 0.4.5 → 0.4.7

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/CMakeLists.txt CHANGED
@@ -8,7 +8,7 @@ find_package(PkgConfig REQUIRED)
8
8
 
9
9
  project(bare_gtk C)
10
10
 
11
- fetch_package("github:holepunchto/bare@1.38.0")
11
+ fetch_package("github:holepunchto/bare@1.40.0")
12
12
  fetch_package("github:holepunchto/libpath#a68d099")
13
13
 
14
14
  pkg_check_modules(GTK REQUIRED IMPORTED_TARGET GLOBAL gtk4>=4.6)
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
- static GIOChannel *bare__channel;
23
- static guint bare__poll;
24
- static guint bare__timer;
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,50 @@ bare__on_platform_thread(void *data) {
63
66
  assert(err == 0);
64
67
  }
65
68
 
66
- static void
67
- bare__run(void);
68
-
69
69
  static gboolean
70
- bare__on_poll(GIOChannel *source, GIOCondition condition, gpointer data) {
71
- bare__run();
70
+ bare__on_prepare(GSource *source, gint *timeout) {
71
+ if (bare__exited) {
72
+ *timeout = -1;
72
73
 
73
- return G_SOURCE_CONTINUE;
74
+ return FALSE;
75
+ }
76
+
77
+ uv_update_time(bare__loop);
78
+
79
+ *timeout = uv_backend_timeout(bare__loop);
80
+
81
+ return *timeout == 0;
74
82
  }
75
83
 
76
84
  static gboolean
77
- bare__on_timeout(gpointer data) {
78
- bare__timer = 0;
85
+ bare__on_check(GSource *source) {
86
+ if (bare__exited) return FALSE;
79
87
 
80
- bare__run();
88
+ bare__source_t *self = (bare__source_t *) source;
81
89
 
82
- return G_SOURCE_REMOVE;
83
- }
90
+ if (g_source_query_unix_fd(source, self->poll) & G_IO_IN) return TRUE;
84
91
 
85
- static void
86
- bare__run(void) {
87
- int err;
92
+ uv_update_time(bare__loop);
88
93
 
89
- if (bare__timer) {
90
- g_source_remove(bare__timer);
94
+ return uv_backend_timeout(bare__loop) == 0;
95
+ }
91
96
 
92
- bare__timer = 0;
93
- }
97
+ static gboolean
98
+ bare__on_dispatch(GSource *source, GSourceFunc callback, gpointer data) {
99
+ int err;
94
100
 
95
101
  err = bare_run(bare, UV_RUN_NOWAIT);
96
102
  assert(err >= 0);
97
103
 
98
- if (bare__exited) return;
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
- }
104
+ return G_SOURCE_CONTINUE;
107
105
  }
108
106
 
107
+ static GSourceFuncs bare__source_funcs = {
108
+ .prepare = bare__on_prepare,
109
+ .check = bare__on_check,
110
+ .dispatch = bare__on_dispatch,
111
+ };
112
+
109
113
  static void
110
114
  bare__on_exit(bare_t *bare, void *data) {
111
115
  bare__exited = true;
@@ -146,13 +150,13 @@ bare__on_startup(GtkApplication *app, gpointer data) {
146
150
  err = bare_load(bare, entry, NULL, NULL);
147
151
  (void) err;
148
152
 
149
- bare__channel = g_io_channel_unix_new(bare__loop->backend_fd);
153
+ bare__source = g_source_new(&bare__source_funcs, sizeof(bare__source_t));
150
154
 
151
- bare__poll = g_io_add_watch(bare__channel, G_IO_IN, bare__on_poll, NULL);
155
+ bare__source_t *self = (bare__source_t *) bare__source;
152
156
 
153
- bare__timer = 0;
157
+ self->poll = g_source_add_unix_fd(bare__source, uv_backend_fd(bare__loop), G_IO_IN);
154
158
 
155
- bare__run();
159
+ g_source_attach(bare__source, NULL);
156
160
  }
157
161
 
158
162
  int
@@ -242,11 +246,9 @@ main(int argc, char *argv[]) {
242
246
 
243
247
  g_application_run(G_APPLICATION(app), argc, argv);
244
248
 
245
- g_source_remove(bare__poll);
246
-
247
- if (bare__timer) g_source_remove(bare__timer);
249
+ g_source_destroy(bare__source);
248
250
 
249
- g_io_channel_unref(bare__channel);
251
+ g_source_unref(bare__source);
250
252
 
251
253
  err = uv_async_send(&bare__shutdown);
252
254
  assert(err == 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-gtk",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
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
  },
@@ -55,7 +56,7 @@
55
56
  "bare-tap": "^1.1.0",
56
57
  "bare-x11": "^0.1.0",
57
58
  "cmake-bare": "^1.18.0",
58
- "cmake-fetch": "^1.5.5",
59
+ "cmake-fetch": "^1.6.0",
59
60
  "cmake-prelude": "^0.1.11",
60
61
  "lunte": "^1.8.0",
61
62
  "prettier": "^3.4.1",
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-arm64/bare
3
- size: 47015048 bytes
4
- sha256: 8d9d77a4bcd86204a09ea0c23155588d2cf7560038d24a380819871d68599a48
3
+ size: 46358352 bytes
4
+ sha256: 8b92d3150a20651e5ac8a3440be6aa2d8a41602c7c2522d31e5f63d0712f07b6
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-x64/bare
3
- size: 48145624 bytes
4
- sha256: 7703482d232cbde2ac3556775d808d24bfb75db0806c189126a35fcd3cabf78b
3
+ size: 47529984 bytes
4
+ sha256: 944d7ebb2a343b059e241b609f6f7c09fc5ba8ed5fcd5751ee0212a797d3e9bf
Binary file