如何通过JRuby在SWT/Shoes中获得macOS透明标题栏效果

How to obtain a macOS transparent titlebar effect in SWT/Shoes via JRuby

我试图在使用 Shoes 时获得这种效果(透明的标题栏和全尺寸内容)。但是,我认为 SWT 甚至不提供此选项。

我怎样才能做到这一点?

我是这样实现的:

我把这段代码放在 Shoes.app 声明之前

class Shoes
  module Swt
    class App
      def initialize_shell
        @image = ::Swt::Graphics::Image.new(::Swt.display, ICON)
        @shell = ::Swt::Widgets::Shell.new(::Swt.display, main_window_style)
        @shell.image = @image
        @shell.text = @dsl.app_title
        @shell.background_mode = ::Swt::SWT::INHERIT_DEFAULT
        @shell.background = @background.real
        full_size_byte_mask = 32768

        hack_cocoa_main_window('setTitleVisibility:', 1)
        hack_cocoa_main_window('setStyleMask:', @shell.view.window.styleMask | full_size_byte_mask)
        hack_cocoa_main_window('setTitlebarAppearsTransparent:', 1)
      end

      private

      def hack_cocoa_main_window(key, value, type=nil)
        key = org.eclipse.swt.internal.cocoa::OS.sel_registerName(key)
        id  = @shell.view.window.id
        msg_method = ['objc_msgSend', type].compact.join('_')
        org.eclipse.swt.internal.cocoa::OS.send(msg_method, id, key, value)
      end
    end
  end
end