bare-gtk 0.4.4 → 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/CMakeLists.txt CHANGED
@@ -2,17 +2,17 @@ cmake_minimum_required(VERSION 4.0)
2
2
 
3
3
  find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
4
4
  find_package(cmake-fetch REQUIRED PATHS node_modules/cmake-fetch)
5
+ find_package(cmake-prelude REQUIRED PATHS node_modules/cmake-prelude)
5
6
 
6
7
  find_package(PkgConfig REQUIRED)
7
8
 
8
9
  project(bare_gtk C)
9
10
 
10
- fetch_package("github:holepunchto/bare@1.35.1")
11
- fetch_package("github:holepunchto/libpath")
11
+ fetch_package("github:holepunchto/bare@1.38.0")
12
+ fetch_package("github:holepunchto/libpath#a68d099")
12
13
 
13
14
  pkg_check_modules(GTK REQUIRED IMPORTED_TARGET GLOBAL gtk4>=4.6)
14
15
 
15
- # The version the prebuilds are built against.
16
16
  target_compile_definitions(
17
17
  PkgConfig::GTK
18
18
  INTERFACE
@@ -20,12 +20,12 @@ target_compile_definitions(
20
20
  GDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_6
21
21
  )
22
22
 
23
- add_bare_module(bare_gtk)
24
-
25
- target_sources(
26
- ${bare_gtk}
27
- PRIVATE
23
+ add_bare_module(
24
+ bare_gtk
25
+ SOURCES
28
26
  binding.c
27
+ LINK
28
+ PkgConfig::GTK
29
29
  )
30
30
 
31
31
  target_include_directories(
@@ -34,49 +34,28 @@ target_include_directories(
34
34
  node_modules/bare-gobject-registry/lib
35
35
  )
36
36
 
37
- target_link_libraries(
38
- ${bare_gtk}
39
- PUBLIC
40
- PkgConfig::GTK
41
- )
42
-
43
- add_executable(bare_runtime)
37
+ bare_target(target)
44
38
 
45
- target_sources(
39
+ add_executable_target(
46
40
  bare_runtime
47
- PRIVATE
41
+ SOURCES
48
42
  lib/runtime.c
43
+ LINK
44
+ $<LINK_LIBRARY:WHOLE_ARCHIVE,bare::static>
45
+ bare::exports
46
+ rlimit::static
47
+ path::static
48
+ PkgConfig::GTK
49
+ EXPORTS
50
+ bare_gtk_app
51
+ RPATH ../lib
52
+ DESTINATION ${target}
53
+ OUTPUT_DIRECTORY bin
54
+ EXPORT OFF
49
55
  )
50
56
 
51
- set(bare_runtime_rpath "$ORIGIN/../lib")
52
-
53
57
  set_target_properties(
54
- bare_runtime
58
+ bare_runtime_executable
55
59
  PROPERTIES
56
- C_STANDARD 99
57
- POSITION_INDEPENDENT_CODE ON
58
60
  OUTPUT_NAME bare
59
- INSTALL_RPATH "${bare_runtime_rpath}"
60
- BUILD_WITH_INSTALL_RPATH ON
61
- ENABLE_EXPORTS ON
62
61
  )
63
-
64
- # Store the rpath as `RPATH` rather than the newer `RUNPATH`, so that
65
- # `$ORIGIN/../lib` is searched by every `dlopen()` in the process, not only by
66
- # those the runtime makes itself.
67
- target_link_options(bare_runtime PRIVATE -Wl,--disable-new-dtags)
68
-
69
- target_link_libraries(
70
- bare_runtime
71
- PUBLIC
72
- $<LINK_LIBRARY:WHOLE_ARCHIVE,bare_static>
73
- PRIVATE
74
- rlimit_static
75
- path_static
76
- PRIVATE
77
- PkgConfig::GTK
78
- )
79
-
80
- bare_target(target)
81
-
82
- install(TARGETS bare_runtime RUNTIME DESTINATION ${target})
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,53 @@ bare__on_platform_thread(void *data) {
63
66
  assert(err == 0);
64
67
  }
65
68
 
66
- static void
67
- bare__run(void);
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
- bare__on_poll(GIOChannel *source, GIOCondition condition, gpointer data) {
71
- bare__run();
73
+ bare__on_prepare(GSource *source, gint *timeout) {
74
+ if (bare__exited) {
75
+ *timeout = -1;
72
76
 
73
- return G_SOURCE_CONTINUE;
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
- bare__on_timeout(gpointer data) {
78
- bare__timer = 0;
88
+ bare__on_check(GSource *source) {
89
+ if (bare__exited) return FALSE;
79
90
 
80
- bare__run();
91
+ bare__source_t *self = (bare__source_t *) source;
81
92
 
82
- return G_SOURCE_REMOVE;
83
- }
93
+ if (g_source_query_unix_fd(source, self->poll) & G_IO_IN) return TRUE;
84
94
 
85
- static void
86
- bare__run(void) {
87
- int err;
95
+ uv_update_time(bare__loop);
88
96
 
89
- if (bare__timer) {
90
- g_source_remove(bare__timer);
97
+ return uv_backend_timeout(bare__loop) == 0;
98
+ }
91
99
 
92
- bare__timer = 0;
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
- 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
- }
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
- bare__channel = g_io_channel_unix_new(bare__loop->backend_fd);
156
+ bare__source = g_source_new(&bare__source_funcs, sizeof(bare__source_t));
150
157
 
151
- bare__poll = g_io_add_watch(bare__channel, G_IO_IN, bare__on_poll, NULL);
158
+ bare__source_t *self = (bare__source_t *) bare__source;
152
159
 
153
- bare__timer = 0;
160
+ self->poll = g_source_add_unix_fd(bare__source, uv_backend_fd(bare__loop), G_IO_IN);
154
161
 
155
- bare__run();
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
- g_source_remove(bare__poll);
246
-
247
- if (bare__timer) g_source_remove(bare__timer);
252
+ g_source_destroy(bare__source);
248
253
 
249
- g_io_channel_unref(bare__channel);
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.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
  },
@@ -54,8 +55,9 @@
54
55
  "bare-pointer": "^0.1.1",
55
56
  "bare-tap": "^1.1.0",
56
57
  "bare-x11": "^0.1.0",
57
- "cmake-bare": "^1.6.5",
58
- "cmake-fetch": "^1.4.0",
58
+ "cmake-bare": "^1.18.0",
59
+ "cmake-fetch": "^1.5.5",
60
+ "cmake-prelude": "^0.1.11",
59
61
  "lunte": "^1.8.0",
60
62
  "prettier": "^3.4.1",
61
63
  "prettier-config-holepunch": "^2.0.0"
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-arm64/bare
3
- size: 83773504 bytes
4
- sha256: de51bad5f03171530d762ebfb95bc7cc084588c78f1f4c18e55ae97e78a1856b
3
+ size: 47015048 bytes
4
+ sha256: 26ec8929ce298b277b4c5ecc691a9349013e4a8d278b0df3444a18d367d99083
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-x64/bare
3
- size: 82548240 bytes
4
- sha256: 7450ca3470c4b4b924d17fe6dc2adaf551628edd07960d491f5a42aeb658ba83
3
+ size: 48145624 bytes
4
+ sha256: f3754d54d60bcb4bc6250954652fe1c75ad6be1c3590023632150dc197c35947
Binary file