Skip to content

Commit

Permalink
add Gui, Option Unnamed Style and Unnamed ExStyle
Browse files Browse the repository at this point in the history
but only `+0x80000000` and `+E0x8000000` for now, as they are needed for phil294/vimium-everywhere#3. Other styles are probably very low priority or just don't apply on Linux at all.
  • Loading branch information
phil294 committed Jul 2, 2023
1 parent 65bb667 commit e95e11c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6025,8 +6025,8 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<p class="calibre8 tbd"><strong class="calibre14">SysMenu</strong>: Provides an icon with a drop-down menu in the upper left corner of the title bar. [Default]</p>
<p class="calibre8 rm"><strong class="calibre14">Theme</strong>: By specifying -Theme, all subsequently created controls in the window will have Classic Theme appearance on Windows XP and beyond. To later create additional controls in the window that obey the current theme, turn it back on via +Theme. Note: This option has no effect on operating systems older than Windows XP, nor does it have any effect on XP itself if the Classic Theme is in effect.</p>
<p class="calibre8"><strong class="calibre14">ToolWindow</strong>: Provides <span class="rm">a narrower title bar</span> but the window will have no taskbar button.</p>
<p class="calibre8 tbd"><strong class="calibre14">(Unnamed Style)</strong>: Specify a plus or minus sign followed immediately by a decimal or hexadecimal <a href="#Styles.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">style number</a>.</p>
<p class="calibre8 tbd"><strong class="calibre14">(Unnamed ExStyle)</strong>: Specify a plus or minus sign followed immediately by the letter E and a decimal or hexadecimal extended style number. For example, +E0x40000 would add the WS_EX_APPWINDOW style, which provides a taskbar button for a window that would otherwise lack one. Although the other extended style numbers are not yet documented here (since they are rarely used), they can be discovered on the Internet.</p>
<p class="calibre8"><strong class="calibre14">(Unnamed Style)</strong>: Specify a plus or minus sign followed immediately by a decimal or hexadecimal <a href="#Styles.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">style number</a>. You can find a list of Styles with their respective numbers <a href="https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles">here</a>. <span class="x11">Currently, only one code is supported: WS_POPUP (Gui, +0x80000000). This prevents the window from ever grabbing focus. This option only works when you specify it before any other Gui command as the type can only be set at internal window creation time.</span></p>
<p class="calibre8"><strong class="calibre14">(Unnamed ExStyle)</strong>: Specify a plus or minus sign followed immediately by the letter E and a decimal or hexadecimal extended style number. <span class="tbd">For example, +E0x40000 would add the WS_EX_APPWINDOW style, which provides a taskbar button for a window that would otherwise lack one. Although the other extended style numbers are not yet documented here (since they are rarely used), they can be discovered on the Internet.</span>You can find a list of ExStyles with their respective numbers <a href="https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles">here</a>. <span class="x11">Currently, only one code is supported: WS_EX_NOACTIVATE (Gui, +E0x8000000). It doesn't seem to work really, try WS_POPUP instead (see "Unnamed Style" above).</span></p>
<div class="tbd">
<p class="calibre8"> </p>
<p class="calibre8"><span class="calibre17"><a id="Gui.htm__Flash" href="#Gui.htm__Flash" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> Flash [, Off]</span> (v1.0.21+) </p>
Expand Down
26 changes: 25 additions & 1 deletion src/cmd/gtk/gui/gui-option.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ class Cmd::Gtk::Gui::GuiOption < Cmd::Base
def self.max_args; 2 end
def run(thread, args)
gui_id = args[0]
opt = thread.parse_word_options(args[1])
if opt[""]?.try &.[:n] == 0x80000000 # WS_POPUP
# This special option is only available at window creation time, so it needs to be configured
# *before* the `gtk.gui()` call is made where the window will be created and this setting
# should be respected. Consequently, this option can have no effect once any other gui command ran.
thread.runner.display.gtk.guis_creation_info[gui_id] ||= Run::Gtk::GuiCreationInfo.new(type: ::Gtk::WindowType::Popup)
end
thread.runner.display.gtk.gui(thread, gui_id) do |gui|
thread.parse_word_options(args[1]).each do |w, i|
opt.each do |w, i|
case w
when "caption" then gui.window.decorated = ! i[:minus]
when "resize" then gui.window.resizable = ! i[:minus]
Expand All @@ -13,6 +20,23 @@ class Cmd::Gtk::Gui::GuiOption < Cmd::Base
::Gdk::WindowTypeHint::Menu :
::Gdk::WindowTypeHint::Normal
when "toolwindow" then gui.window.skip_taskbar_hint = ! i[:minus]
# https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
# (with current parser, only one ext window style can be passed in the same invocation)
when "e"
case i[:n]
when 0x8000000 # WS_EX_NOACTIVATE
# These actually don't seem to do anything on X11 but perhaps necessary on Wayland?
gui.window.accept_focus = i[:minus]
gui.window.can_focus = i[:minus]
# Not sure about this one and it probably doesn't even belong into this style:
# gui.window.type_hint = i[:minus] ? ::Gdk::WindowTypeHint::Normal : ::Gdk::WindowTypeHint::Tooltip
end
# https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles
# (with current parser, only one window style can be passed in the same invocation)
when ""
# case i[:n]
# when 0x80000000 # WS_POPUP
# (moved above)
end
end
end
Expand Down
15 changes: 14 additions & 1 deletion src/run/display/gtk.cr
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,26 @@ module Run
end
end
getter guis = {} of String => GuiInfo
# This is necessary to be able to pass flags to the Gui Gtk Window *at creation time*, because
# the respective flags can't be set again at a later time.
# This is a rare occurrence and currently only necessary to set the type to Popup.
# Note that this is different from properties that can only be set before a window is *shown*.
# For that, the only thing that matters is the ordering of ahk commands.
class GuiCreationInfo
property type : ::Gtk::WindowType
def initialize(*, @type)
end
end
# :ditto:
getter guis_creation_info = {} of String => GuiCreationInfo
# Yields (and if not yet exists, creates) the gui info referring to *gui_id*,
# including the `window`, and passes the block on to the GTK idle thread so
# you can run GTK code with it.
def gui(thread, gui_id, &block : GuiInfo -> _)
if ! @guis[gui_id]?
act do
window = ::Gtk::Window.new title: @default_title, window_position: ::Gtk::WindowPosition::Center, icon: @icon_pixbuf, resizable: false
type = @guis_creation_info[gui_id]?.try &.type || ::Gtk::WindowType::Toplevel
window = ::Gtk::Window.new title: @default_title, window_position: ::Gtk::WindowPosition::Center, icon: @icon_pixbuf, resizable: false, type: type
# , border_width: 20
fixed = ::Gtk::Fixed.new
window.add fixed
Expand Down

0 comments on commit e95e11c

Please sign in to comment.