webview_ruby2 0.2.4 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cefbf9ba714c336ab0e375c9a3ed17e128a85159dbd54606266d097d40fe296
4
- data.tar.gz: fa6e1132f23ec33d90d89c4a86aa13b1bf44ba5595e8c50e0d78e6d4bdc73673
3
+ metadata.gz: 877b4375e719e91491c5fff9cb8f6a700d602e932ff720d7d194f0b1e033ced5
4
+ data.tar.gz: accdb93f959e780245d3bca2582c050efa91cbd39fce4e11a2bbc761c4c7341e
5
5
  SHA512:
6
- metadata.gz: 69b5a735bce1fdc189e91e7cdc66182a8a3f07fea9c549e782e9a56a94a63369ef98217eb5b14c84fbaea44db11a91c8dfc1e0787c1545f8e22cada0cd5d1ded
7
- data.tar.gz: 670c47c11bfb4a267233eb1e16a08d197ac04fc0c6e121e6b14b5f0632d8227969b26ce9565469310d905736996cee07265fcb7d1b5e6deaba03d031974d16a0
6
+ metadata.gz: 5fb30bec7976d17bd17373bc80c765899c55d137e6bdf4e48b80c578c5fbe149975aedb073ff93036ade1793d3fb5824686659ca15523fdc35d837bacc5452a3
7
+ data.tar.gz: d2c802736667fa4e36f4a32ee5d0f391c82162fbb325ef0189aa101f32f7f9a5294ffaf62cd95a534cdeb0bef603ea3d5324dea6ebfe6e5e92d2ae45e48cf6ac
@@ -66,6 +66,12 @@ WEBVIEW_API void *webview_get_window(webview_t w);
66
66
  // Updates the title of the native window. Must be called from the UI thread.
67
67
  WEBVIEW_API void webview_set_title(webview_t w, const char *title);
68
68
 
69
+ // Hide from dock
70
+ WEBVIEW_API void webview_hide_from_dock(webview_t w, int hide);
71
+
72
+ // Show/hide webview window
73
+ WEBVIEW_API void webview_show(webview_t w, int show);
74
+
69
75
  // Update the background color of the native window
70
76
  WEBVIEW_API void webview_set_bg(webview_t w, double r, double g, double b, double a);
71
77
 
@@ -628,7 +634,7 @@ public:
628
634
  objc_allocateClassPair((Class) "NSResponder"_cls, "AppDelegate", 0);
629
635
  class_addProtocol(cls, objc_getProtocol("NSTouchBarProvider"));
630
636
  class_addMethod(cls, "applicationShouldTerminateAfterLastWindowClosed:"_sel,
631
- (IMP)(+[](id, SEL, id) -> BOOL { return 1; }), "c@:@");
637
+ (IMP)(+[](id, SEL, id) -> BOOL { return 0; }), "c@:@");
632
638
  class_addMethod(cls, "userContentController:didReceiveScriptMessage:"_sel,
633
639
  (IMP)(+[](id self, SEL, id, id msg) {
634
640
  auto w =
@@ -734,6 +740,15 @@ public:
734
740
  void run() {
735
741
  id app = ((id(*)(id, SEL))objc_msgSend)("NSApplication"_cls,
736
742
  "sharedApplication"_sel);
743
+
744
+ #define NSApplicationActivationPolicyAccessory 1
745
+ if (this->dock_hide) {
746
+ dispatch([&]() {
747
+ ((void (*)(id, SEL, BOOL))objc_msgSend)(
748
+ app, "setActivationPolicy:"_sel, NSApplicationActivationPolicyAccessory);
749
+ });
750
+ }
751
+
737
752
  dispatch([&]() {
738
753
  ((void (*)(id, SEL, BOOL))objc_msgSend)(
739
754
  app, "activateIgnoringOtherApps:"_sel, 1);
@@ -768,6 +783,22 @@ public:
768
783
  "NSColor"_cls, "colorWithRed:green:blue:alpha:"_sel, r, g, b, a));
769
784
  }
770
785
 
786
+ void hide_from_dock(int hide) {
787
+ this->dock_hide = hide;
788
+ }
789
+
790
+ void show(int yes) {
791
+ if(yes == 0) {
792
+ ((void (*)(id, SEL, id))objc_msgSend)(
793
+ m_window, "orderOut:"_sel,
794
+ nullptr);
795
+ } else {
796
+ ((void (*)(id, SEL, id))objc_msgSend)(
797
+ m_window, "makeKeyAndOrderFront:"_sel,
798
+ nullptr);
799
+ }
800
+ }
801
+
771
802
  void set_title(const std::string title) {
772
803
  ((void (*)(id, SEL, id))objc_msgSend)(
773
804
  m_window, "setTitle:"_sel,
@@ -852,6 +883,7 @@ private:
852
883
  id m_window;
853
884
  id m_webview;
854
885
  id m_manager;
886
+ int dock_hide = 0;
855
887
  };
856
888
 
857
889
  using browser_engine = cocoa_wkwebview_engine;
@@ -1386,6 +1418,14 @@ WEBVIEW_API void webview_set_title(webview_t w, const char *title) {
1386
1418
  static_cast<webview::webview *>(w)->set_title(title);
1387
1419
  }
1388
1420
 
1421
+ WEBVIEW_API void webview_hide_from_dock(webview_t w, int hide) {
1422
+ static_cast<webview::webview *>(w)->hide_from_dock(hide);
1423
+ }
1424
+
1425
+ WEBVIEW_API void webview_show(webview_t w, int show) {
1426
+ static_cast<webview::webview *>(w)->show(show);
1427
+ }
1428
+
1389
1429
  WEBVIEW_API void webview_set_bg(webview_t w, double r, double g, double b, double a) {
1390
1430
  static_cast<webview::webview *>(w)->set_bg(r, g, b, a);
1391
1431
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebviewRuby
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.6"
5
5
  end
data/lib/webview_ruby.rb CHANGED
@@ -12,6 +12,8 @@ module WebviewRuby
12
12
  attach_function :webview_run, [:pointer], :void
13
13
  attach_function :webview_terminate, [:pointer], :void
14
14
  attach_function :webview_set_title, [:pointer, :string], :void
15
+ attach_function :webview_show, [:pointer, :int], :void
16
+ attach_function :webview_hide_from_dock, [:pointer, :int], :void
15
17
  attach_function :webview_set_pos, [:pointer, :int, :int], :void
16
18
  attach_function :webview_set_bg, [:pointer, :double, :double, :double, :double], :void
17
19
  attach_function :webview_set_size, [:pointer, :int, :int, :int, :int], :void
@@ -31,6 +33,18 @@ module WebviewRuby
31
33
  @window = WebviewRuby.webview_create(debug ? 1 : 0, nil)
32
34
  end
33
35
 
36
+ def show(yes)
37
+ if yes
38
+ WebviewRuby.webview_show(@window, 1)
39
+ else
40
+ WebviewRuby.webview_show(@window, 0)
41
+ end
42
+ end
43
+
44
+ def hide_from_dock(hide)
45
+ WebviewRuby.webview_hide_from_dock(@window, hide)
46
+ end
47
+
34
48
  def get_x()
35
49
  WebviewRuby.webview_get_x(@window)
36
50
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webview_ruby2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Concetto Rudilosso
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-23 00:00:00.000000000 Z
10
+ date: 2025-06-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ffi