bare-gtk 0.3.1 → 0.3.2

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 CHANGED
@@ -251,6 +251,7 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
251
251
  V("surfaceDisplay", bare_gtk_surface_display)
252
252
 
253
253
  V("applicationGetDefault", bare_gtk_application_get_default)
254
+ V("applicationActiveWindow", bare_gtk_application_active_window)
254
255
  V("applicationHold", bare_gtk_application_hold)
255
256
  V("applicationRelease", bare_gtk_application_release)
256
257
 
@@ -335,6 +336,7 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
335
336
  V("GESTURE_DRAG_EVENT_CANCEL", bare_gtk_gesture_drag_event_cancel)
336
337
 
337
338
  V("FRAME_CLOCK_EVENT_AFTER_PAINT", bare_gtk_frame_clock_event_after_paint)
339
+ V("FRAME_CLOCK_EVENT_UPDATE", bare_gtk_frame_clock_event_update)
338
340
 
339
341
  V("SETTINGS_EVENT_PREFER_DARK_THEME", bare_gtk_settings_event_prefer_dark_theme)
340
342
  V("SETTINGS_EVENT_XFT_DPI", bare_gtk_settings_event_xft_dpi)
@@ -1,7 +1,14 @@
1
1
  import GObject = require('./object')
2
+ import GTKWindow = require('./window')
2
3
 
3
4
  /** The application, as a `GtkApplication`. It quits once it has no windows and nothing holds it. */
4
5
  interface GTKApplication extends GObject {
6
+ /**
7
+ * The window that was most recently active, or `null` if there are none. Until a window has been
8
+ * focused, this is the window added most recently.
9
+ */
10
+ readonly activeWindow: GTKWindow | null
11
+
5
12
  /** Keep the application running while it has no windows. */
6
13
  hold(): this
7
14
 
package/lib/application.h CHANGED
@@ -63,4 +63,26 @@ bare_gtk_application_release(js_env_t *env, js_callback_info_t *info) {
63
63
  return NULL;
64
64
  }
65
65
 
66
+ // The window that was most recently active, which is the most recently added
67
+ // one until any of them has been focused.
68
+ static js_value_t *
69
+ bare_gtk_application_active_window(js_env_t *env, js_callback_info_t *info) {
70
+ int err;
71
+
72
+ size_t argc = 1;
73
+ js_value_t *argv[1];
74
+
75
+ bare_gtk_state_t *state;
76
+ err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
77
+ assert(err == 0);
78
+
79
+ assert(argc == 1);
80
+
81
+ GtkApplication *application;
82
+ err = bare_gobject_read_tag(env, state->registry, argv[0], "application", (gpointer *) &application);
83
+ if (err < 0) return NULL;
84
+
85
+ return bare_gtk__create_tag(env, state, gtk_application_get_active_window(application));
86
+ }
87
+
66
88
  #endif // BARE_GTK_APPLICATION_H
@@ -1,12 +1,17 @@
1
1
  const binding = require('../binding')
2
2
  const wrap = require('./wrap')
3
3
  const GObject = require('./object')
4
+ const GTKWindow = require('./window')
4
5
 
5
6
  module.exports = exports = class GTKApplication extends GObject {
6
7
  static getDefault() {
7
8
  return wrap(GTKApplication, binding.applicationGetDefault())
8
9
  }
9
10
 
11
+ get activeWindow() {
12
+ return wrap(GTKWindow, binding.applicationActiveWindow(this._tag))
13
+ }
14
+
10
15
  hold() {
11
16
  binding.applicationHold(this._tag)
12
17
  return this
@@ -23,6 +23,9 @@ declare namespace GDKFrameClock {
23
23
  export interface Events {
24
24
  /** A frame has been laid out and drawn. */
25
25
  'after-paint': []
26
+
27
+ /** A frame is about to be laid out and drawn, so changes made now are part of it. */
28
+ update: []
26
29
  }
27
30
  }
28
31
 
package/lib/frame-clock.h CHANGED
@@ -10,8 +10,18 @@
10
10
 
11
11
  enum {
12
12
  bare_gtk_frame_clock_event_after_paint = 1 << 0,
13
+ bare_gtk_frame_clock_event_update = 1 << 1,
13
14
  };
14
15
 
16
+ static void
17
+ bare_gtk_frame_clock__on_update(GdkFrameClock *clock, gpointer data) {
18
+ bare_gtk_state_t *state = data;
19
+
20
+ if ((bare_gtk__observed(state, clock) & bare_gtk_frame_clock_event_update) == 0) return;
21
+
22
+ bare_gtk__emit(state, clock, "update", 0, NULL);
23
+ }
24
+
15
25
  static void
16
26
  bare_gtk_frame_clock__on_after_paint(GdkFrameClock *clock, gpointer data) {
17
27
  bare_gtk_state_t *state = data;
@@ -46,6 +56,7 @@ bare_gtk_frame_clock_event_mask(js_env_t *env, js_callback_info_t *info) {
46
56
 
47
57
  if (bare_gtk__observe(state, clock, events)) {
48
58
  g_signal_connect(clock, "after-paint", G_CALLBACK(bare_gtk_frame_clock__on_after_paint), state);
59
+ g_signal_connect(clock, "update", G_CALLBACK(bare_gtk_frame_clock__on_update), state);
49
60
  }
50
61
 
51
62
  return NULL;
@@ -3,7 +3,8 @@ const GObject = require('./object')
3
3
 
4
4
  module.exports = exports = class GDKFrameClock extends GObject {
5
5
  static _events = {
6
- 'after-paint': binding.FRAME_CLOCK_EVENT_AFTER_PAINT
6
+ 'after-paint': binding.FRAME_CLOCK_EVENT_AFTER_PAINT,
7
+ update: binding.FRAME_CLOCK_EVENT_UPDATE
7
8
  }
8
9
 
9
10
  _eventMask(mask) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-gtk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "GTK bindings and runtime for Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-arm64/bare
3
3
  size: 83698384 bytes
4
- sha256: 193c38e3c6f4b1e1ec4dc1c588094fa720886bec6890d87aad628c8ea1b53b79
4
+ sha256: c297481925682ce0ea4ad8e28b699f33171d7bc3f408037cc08bd50a3571435e
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/linux-x64/bare
3
3
  size: 82479072 bytes
4
- sha256: 7a2132dd5d107e026e4aa8d0e7f2cf946ccb9cb41fc079dca56acbeb3a6ffbfb
4
+ sha256: a0c3995c9de5d2f1f148d045746c31aa1e3af84a86cd7a9c7ceec362dde55a61
Binary file