Compare commits

..

104 Commits
x11 ... v0.42.1

Author SHA1 Message Date
Kovid Goyal
d56721e64d version 0.42.1 2025-05-17 08:40:20 +05:30
Kovid Goyal
96d961dcd0 ... 2025-05-17 07:15:49 +05:30
Kovid Goyal
35067a60ff Also build launcher with -std=c11
Fixes #8642
2025-05-16 19:33:30 +05:30
Kovid Goyal
e015ebefab Implement focus tracking in kitten infrastructure 2025-05-16 12:48:21 +05:30
Kovid Goyal
ce59ef8c6e Export function to encode clipboard protocol chunk 2025-05-16 12:23:14 +05:30
Kovid Goyal
59c32d19cc Simplify code 2025-05-16 12:17:00 +05:30
Kovid Goyal
4713cc29ad make gofmt happy 2025-05-16 09:40:34 +05:30
Kovid Goyal
c861259e3b Rename go module from kitty -> github.com/kovidgoyal/kitty
Makes the code more easily re-useable in other projects
2025-05-16 08:43:39 +05:30
Kovid Goyal
66b13aa6d4 ... 2025-05-15 22:20:51 +05:30
Kovid Goyal
14ab28af51 Cleanup previous PR 2025-05-15 22:09:54 +05:30
Kovid Goyal
4f22951a29 Merge branch 'feature/panel-kwin-id' of https://github.com/jinliu/kitty 2025-05-15 22:08:02 +05:30
Jin Liu
ac5c8b8ebb doc/kitten/panel: add suggestion to set --app-id=dock for kwin 2025-05-16 00:30:14 +08:00
Kovid Goyal
27a9db95af Cleanup previous PR 2025-05-15 21:44:05 +05:30
Kovid Goyal
e1f5c3ff5c Merge branch 'feature/appid-as-namespace' of https://github.com/jinliu/kitty 2025-05-15 21:43:06 +05:30
Kovid Goyal
429cff0a52 Convenience method to access any member of a set 2025-05-15 21:40:06 +05:30
Jin Liu
4c6c38929b panel kitten: on Wayland, use app-id for the LayerShellV1 namespace parameter
The Wayland LayerShellV1 protocol doesn't allow setting window class/name/role/type/appId.
Instead, it has a `namespace` parameter that we currently hardcode to `kitty`. It
seems suitable to use app-id for this parameter.

Example use case:
kwin use the `namespace` parameter and an undocumented mapping to set window type for
Layer Shell windows. E.g., "dock" maps to NET:Dock. So if we set `app_id dock` in
quick_access_terminal.conf, the panel would be considered a dock, and won't have the
normal scale in/out animation on shown/hidden.
2025-05-15 23:55:48 +08:00
Kovid Goyal
9a543c2370 Modify docs since --class and --name dont apply to panels on Wayland 2025-05-15 19:55:20 +05:30
Kovid Goyal
a3634e4903 ... 2025-05-15 09:39:30 +05:30
Kovid Goyal
8017945551 Wayland: Add support for the xdg-toplevel-tag protocol
Now you can use --name or its alias --os-window-tag to set the tag.
2025-05-15 09:35:42 +05:30
Kovid Goyal
1157777c11 Bump bundled Wayland version 2025-05-15 09:09:16 +05:30
Kovid Goyal
7ec0085a0b Also report panic via debugprintln 2025-05-14 12:06:01 +05:30
Kovid Goyal
51adca08f2 Only chdir to / if the cwd is not executable or does not exist. Fixes #8636 2025-05-14 08:58:57 +05:30
Kovid Goyal
123a115836 Make kitten main re-useable 2025-05-13 18:51:49 +05:30
Kovid Goyal
6282a46ff1 A new centered panel type that is sized 2025-05-13 16:38:57 +05:30
Kovid Goyal
6afe3cbc5a typo 2025-05-13 15:44:43 +05:30
Kovid Goyal
7ec486c7a6 ... 2025-05-13 15:38:11 +05:30
Kovid Goyal
d9f61803ae Make a note that launching OS panels does not support --config or --override as these are per process settings not per OS Window.
Fixes #8635.
2025-05-13 15:35:22 +05:30
Kovid Goyal
88f4c829eb Improve handling of output names
Now can use panel --output-name list to list available outputs.
Also, --output-name works on macOS
2025-05-13 15:29:37 +05:30
Kovid Goyal
67c1ce7280 ... 2025-05-13 11:54:01 +05:30
Kovid Goyal
a39b7eb7dd Quick access terminal: Allow configuring the monitor to display the panel on in Wayland/X11
Fixes #8630
2025-05-13 11:52:52 +05:30
Kovid Goyal
74291d0425 Fix #8633 2025-05-13 08:11:33 +05:30
Kovid Goyal
8e12cccf26 ... 2025-05-13 08:00:35 +05:30
Kovid Goyal
20d6a8e4c5 Fix building on older Cocoa 2025-05-13 07:45:11 +05:30
Kovid Goyal
a47babc87d Delay import on demand 2025-05-12 22:22:32 +05:30
Kovid Goyal
4c8f9f9e26 Cleanup previous PR
Fixes #8601
2025-05-12 22:18:41 +05:30
Shane Ciardelli
5c49e2aab4 remembers window position after quit
added position flag

added window geometry caching

Restores window given --position command

moved position flag to last listed flag

fixed formatting - working version

fixed git problems and formatting issues

fixing some caching mistakes

trailing whitespace

remove .dmypy.json for git
2025-05-12 22:18:41 +05:30
Kovid Goyal
9ed6be9272 Quick access terminal: Allow toggling the window to full screen and map using the standard kitty toggle_fullscreen shortcut
Fixes #8626
2025-05-12 15:20:48 +05:30
Kovid Goyal
cf69385823 Wayland: Fix an abort if the terminal program sets a window title longer than 2KB that contains CSI escape sequences and multibyte UTF-8
Fixes #8619
2025-05-12 13:53:12 +05:30
Kovid Goyal
015ee41d0f ... 2025-05-12 13:17:46 +05:30
Kovid Goyal
064bc963a8 macOS: Quick access terminal: Restore focus to previously active window when hiding the quick access terminal window
Fixes #8627
2025-05-12 13:15:42 +05:30
Kovid Goyal
eab298683d Box drawing: Use the old algorithm when drawing curves on low res screens or with very thin lines 2025-05-12 11:40:43 +05:30
Kovid Goyal
2bb92291fc Merge branch 'dependabot/go_modules/all-go-deps-5162d8c94b' of https://github.com/kovidgoyal/kitty 2025-05-12 09:10:09 +05:30
dependabot[bot]
9ed22337b6 Bump the all-go-deps group with 2 updates
Bumps the all-go-deps group with 2 updates: [golang.org/x/image](https://github.com/golang/image) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `golang.org/x/image` from 0.26.0 to 0.27.0
- [Commits](https://github.com/golang/image/compare/v0.26.0...v0.27.0)

Updates `golang.org/x/sys` from 0.32.0 to 0.33.0
- [Commits](https://github.com/golang/sys/compare/v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-version: 0.27.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-go-deps
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-go-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 03:39:24 +00:00
Kovid Goyal
68b4c3dd6d Fix ambiguous width and private use characters not being rendered when used with variable width text-sizing protocol escape codes 2025-05-12 05:21:51 +05:30
Kovid Goyal
7791a9129c Fix replay of multicell_command 2025-05-12 04:44:30 +05:30
Kovid Goyal
f2412cc9c8 version 0.42.0 2025-05-11 10:42:15 +05:30
Kovid Goyal
5dbd198fb9 Update changelog 2025-05-11 10:36:23 +05:30
Kovid Goyal
9b4643e8bc ... 2025-05-11 07:46:06 +05:30
Kovid Goyal
f2f914ed05 More natural limits for step size when sampling paramterized curve 2025-05-10 22:58:56 +05:30
Kovid Goyal
ec5062ceb4 Merge branch 'master' of https://github.com/nomisreual/kitty 2025-05-10 21:23:35 +05:30
Simon Antonius Lauer
eb70f81218 fix: add missing pkgs and manually add font for nix shell 2025-05-10 14:42:46 +02:00
Kovid Goyal
04a4d62859 Replace all remaining uses of old parametrized drawing code 2025-05-10 11:07:26 +05:30
Kovid Goyal
2aaa440519 Move calc of line width out of draw_parametrized_curve 2025-05-10 10:12:57 +05:30
Kovid Goyal
782e7cb2fb ... 2025-05-10 10:03:29 +05:30
Kovid Goyal
41b44fdafa Prepare for moving circle rendering to new code as well 2025-05-10 09:28:20 +05:30
Kovid Goyal
0f3603c0eb Use new parametrized curve rendering for rounded separators 2025-05-10 09:23:12 +05:30
Kovid Goyal
8ba9bfd460 Prepare for using new parametrized drawing code for beziers as well 2025-05-10 09:06:44 +05:30
Kovid Goyal
22fd548903 Also adjust in y direction for odd height 2025-05-10 09:00:57 +05:30
Kovid Goyal
7856046382 Proper odd width x-offset adjustment 2025-05-10 08:56:33 +05:30
Kovid Goyal
f93d57d919 Mark curve data as const 2025-05-10 08:50:29 +05:30
Kovid Goyal
e8d50d0734 Finish up implementation of drawing curve with derivative
Fixes #8299
2025-05-10 08:38:32 +05:30
Kovid Goyal
20e5c7b004 Simplify rectircle equations by using trigonometric super-ellipse parametrization 2025-05-10 07:31:33 +05:30
Kovid Goyal
a597764245 Refactor drawing of parametrized curve
Work towards a proper rendering of thick curves using a derivative to
control sampling frequency.
2025-05-09 21:55:51 +05:30
Kovid Goyal
d6225153ee Slightly improve rsync script 2025-05-09 15:33:22 +05:30
Kovid Goyal
cca838b952 ... 2025-05-09 07:48:56 +05:30
Kovid Goyal
6a53897c17 change_font_size: allow multiplying/dividing the current font size in addition to incrementing it
Fixes #8616
2025-05-09 07:39:06 +05:30
Kovid Goyal
e0e4e53e3b Allow using env vars that resolve to a full cmdline as program in launch mappings
Fixes #8613
2025-05-08 19:22:39 +05:30
Kovid Goyal
8a14a5638a ... 2025-05-08 15:30:09 +05:30
Kovid Goyal
2fed0ec562 Linux: Handle desktop settings portals that are so old they don't implement ReadOne
Sigh, outdated Linux software, just creating busy work for everyone.
2025-05-08 15:22:42 +05:30
Kovid Goyal
97f9d16046 ... 2025-05-08 07:27:16 +05:30
Kovid Goyal
ddd79f0733 Fix #8610 2025-05-07 16:23:17 +05:30
Kovid Goyal
53fd9892eb Allow custom kitten names with hyphens in them
Apparently there is no way to have config filenames on
nixOS/home-manager without hyphens in them.

Fixes #8608
2025-05-06 22:16:28 +05:30
Kovid Goyal
91eb0ec735 ... 2025-05-06 20:30:14 +05:30
Kovid Goyal
3c3ba4a9fb @ launch: Add a --wait-for-child-exit flag to get the child processes exit code even when it is running in a window. 2025-05-06 19:17:17 +05:30
Kovid Goyal
a4963a58e3 CLI parser: Suggest a correction for likely flag typo 2025-05-06 14:48:00 +05:30
Kovid Goyal
80bb9404d5 Have auto color scheme switching also control background image
Fixes #8603
2025-05-06 09:10:05 +05:30
Kovid Goyal
7045632d2e Fix #8606 2025-05-06 08:09:05 +05:30
Kovid Goyal
7b89477470 Allow changing some more background_image options in the API 2025-05-05 20:50:15 +05:30
Kovid Goyal
53bb4f0609 Remove useless code
default_background_changed is meant for individual windows not OS windows
2025-05-05 20:25:08 +05:30
Kovid Goyal
05e6ed685b Merge branch 'dependabot/go_modules/all-go-deps-0987ac49fb' of https://github.com/kovidgoyal/kitty 2025-05-05 08:45:25 +05:30
dependabot[bot]
e6e3e01795 Bump github.com/alecthomas/chroma/v2 in the all-go-deps group
Bumps the all-go-deps group with 1 update: [github.com/alecthomas/chroma/v2](https://github.com/alecthomas/chroma).


Updates `github.com/alecthomas/chroma/v2` from 2.17.0 to 2.17.2
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v2.17.0...v2.17.2)

---
updated-dependencies:
- dependency-name: github.com/alecthomas/chroma/v2
  dependency-version: 2.17.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-05 03:08:19 +00:00
Kovid Goyal
eb7ca8902b Add xmonad to the X11 compatibility table 2025-05-04 08:07:04 +05:30
Kovid Goyal
b5cbb501a4 Use the base name of the named pipe for the created temp file 2025-05-03 16:03:06 +05:30
Kovid Goyal
7ef2fe53e0 Avoid extra stat() 2025-05-03 15:55:36 +05:30
Kovid Goyal
a59a347903 diff kitten: Allow diffing named pipes
Fixes #8597
2025-05-03 15:53:29 +05:30
Kovid Goyal
d22381491d Restore top/bottom panel functionality on i3 2025-05-03 11:12:32 +05:30
Kovid Goyal
e961020330 Fix typo in docs 2025-05-03 10:58:39 +05:30
Kovid Goyal
1237f7667c ... 2025-05-03 10:47:03 +05:30
Kovid Goyal
7dc673e485 Add XFCE to the X11 compatibility matrix 2025-05-03 10:39:41 +05:30
Kovid Goyal
07cda6ac45 Add GNOME to the X11 compatibility matrix 2025-05-03 08:57:55 +05:30
Kovid Goyal
f30ec25c57 Start work on X11 compatibility matrix 2025-05-02 13:25:40 +05:30
Kovid Goyal
43be32a3d7 More atoms 2025-05-02 12:20:54 +05:30
Kovid Goyal
958489f97d X11: Workaround for floating window position on KDE 2025-05-02 10:11:15 +05:30
Kovid Goyal
afe7dc47c2 Update size in addition to position when updating layer properties 2025-05-02 09:35:25 +05:30
Kovid Goyal
11cb3adb8f Reduce roundtrips to X server to fetch atom values 2025-05-02 09:28:24 +05:30
Kovid Goyal
a9bc9962f4 X11: add support for --output-name 2025-05-02 08:37:49 +05:30
Kovid Goyal
a2631448e5 X11: fix window type for non background layers 2025-05-02 08:20:51 +05:30
Kovid Goyal
be9624bbdd Fix px suffix for lines/columns not working 2025-05-02 08:11:49 +05:30
Kovid Goyal
6c0e5f09d3 Fix layer size calculation on high DPI displays under X11 2025-05-02 08:01:35 +05:30
Kovid Goyal
233cd3e2b9 doc edits 2025-05-01 22:01:02 +05:30
Kovid Goyal
49ea2bf636 ... 2025-05-01 21:58:44 +05:30
Kovid Goyal
e87256793c ... 2025-05-01 21:49:48 +05:30
Kovid Goyal
f461039017 Modify docs in light of X11 support 2025-05-01 21:48:27 +05:30
Kovid Goyal
ca688be41c Use focus policy for controlling input on X11 2025-05-01 21:42:00 +05:30
230 changed files with 1821 additions and 957 deletions

View File

@@ -302,9 +302,9 @@
"name": "wayland",
"os": "linux",
"unix": {
"filename": "wayland-1.23.0.tar.xz",
"hash": "sha256:05b3e1574d3e67626b5974f862f36b5b427c7ceeb965cb36a4e6c2d342e45ab2",
"urls": ["https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.23.0/downloads/{filename}"]
"filename": "wayland-1.23.1.tar.xz",
"hash": "sha256:864fb2a8399e2d0ec39d56e9d9b753c093775beadc6022ce81f441929a81e5ed",
"urls": ["https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.23.1/downloads/{filename}"]
}
},
@@ -312,9 +312,9 @@
"name": "wayland-protocols",
"os": "linux",
"unix": {
"filename": "wayland-protocols-1.41.tar.xz",
"hash": "sha256:2786b6b1b79965e313f2c289c12075b9ed700d41844810c51afda10ee329576b",
"urls": ["https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.41/downloads/{filename}"]
"filename": "wayland-protocols-1.44.tar.xz",
"hash": "sha256:3df1107ecf8bfd6ee878aeca5d3b7afd81248a48031e14caf6ae01f14eebb50e",
"urls": ["https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.44/downloads/{filename}"]
}
}

View File

@@ -106,29 +106,58 @@ consumption to do the same tasks.
Detailed list of changes
-------------------------------------
0.42.0 [future]
0.42.1 [2025-05-17]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fix ambiguous width and private use characters not being rendered when used with variable width text-sizing protocol escape codes
- Quick access terminal: Restore focus to previously active window when hiding the quick access terminal window on macOS (:iss:`8627`)
- Wayland: Fix an abort if the terminal program sets a window title longer than 2KB that contains CSI escape sequences and multibyte UTF-8 (:iss:`8619`)
- Quick access terminal: Allow toggling the window to full screen using the standard kitty :sc:`toggle_fullscreen` shortcut (:iss:`8626`)
- Quick access terminal: Allow configuring the monitor to display the panel on in Wayland/X11 (:iss:`8630`)
- A new setting :opt:`remember_window_position` to optionally use the position of the last closed kitty OS Window as the position of the first kitty OS Window when running a new kitty instance (:pull:`8601`)
- Panel kitten: A new ``center-sized`` value for :option:`--edge <kitty +kitten panel --edge>` to allow easily creating sized and centered panels
- Wayland: The `kitty --name` flag now sets the XDG *window tag* on compositors
that support the `xdg-toplevel-tag <https://wayland.app/protocols/xdg-toplevel-tag-v1>`__ protocol.
0.42.0 [2025-05-11]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- A new kitten: :doc:`quick-access-terminal </kittens/quick-access-terminal>` to :ref:`quake`
- The :doc:`panel kitten </kittens/panel>` now works on macOS as well as Wayland (:iss:`2590`)
- The :doc:`panel kitten </kittens/panel>` works on macOS and X11 as well as Wayland (:iss:`2590`)
- **Behavior change**: Now kitty does full grapheme segmentation following the
Unicode 16 spec when splitting text into cells (:iss:`8533`)
- **Behavior change**: The :ref:`automatic color switching functionality <auto_color_scheme>` now also controls background image settings (:iss:`8603`)
- panel kitten: Allow using :option:`kitty +kitten panel --single-instance` to create multiple panels in one process (:iss:`8549`)
- launch: Allow creating desktop panels such as those created by the :doc:`panel kitten </kittens/panel>` (:iss:`8549`)
- Remote control: Allow modifying desktop panels and showing/hiding OS Windows
using the `kitten @ resize-os-window` command (:iss:`8550`)
using the ``kitten @ resize-os-window`` command (:iss:`8550`)
- Allow starting kitty with the OS window hidden via :option:`kitty --start-as`\=hidden useful for single instance mode (:iss:`3466`)
- Remote control launch: Allow waiting for a program launched in a new window
to exit and get the exit code via the `kitty +launch
--wait-for-child-to-exit` command line flag (:disc:`8573`)
- Allow starting kitty with the OS window hidden via :option:`kitty --start-as=hidden <kitty --start-as>`, useful for single instance mode (:iss:`3466`)
- Allow configuring the mouse unhide behavior when using :opt:`mouse_hide_wait` (:pull:`8508`)
- diff kitten: Add half page and full page scroll vim-like bindings (:pull:`8514`)
- diff kitten: Allow diffing named pipes (:iss:`8597`)
- Fix a regression that caused automatic color themes to not be re-applied after config file reload (:iss:`8530`)
- Wayland: When the compositor supports the `xdg-system-bell
@@ -137,8 +166,8 @@ Detailed list of changes
- panel kitten: Allow specifying panel size in pixels in addition to cells
- Fix a regression in 0.36.0 that caused using = with single letter options to
no longer work correctly (:iss:`8556`)
- Fix a regression in 0.36.0 that caused using = with single letter command
line flags to no longer work correctly (:iss:`8556`)
- Single instance: Preserve environment variables from invoking environment in
newly created window (:disc:`8567`)
@@ -148,6 +177,12 @@ Detailed list of changes
- macOS: Fix text color in visual window select ignoring the color theme (:iss:`8579`)
- Launch action: Allow using an env var that resolves to a full command-line as the program to launch (:pull:`8613`)
- :ac:`change_font_size` allow multiplying/dividing the current font size in addition to incrementing it (:iss:`8616`)
- Box drawing: Improve appearance of rounder corners, giving them a uniform line width (:iss:`8299`)
0.41.1 [2025-04-03]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -470,7 +470,8 @@ You need to make sure that the environment variables you define in your shell's
rc files are either also defined system wide or via the :opt:`env` directive in
:file:`kitty.conf`. Common environment variables that cause issues are those
related to localization, such as :envvar:`LANG`, ``LC_*`` and loading of
configuration files such as ``XDG_*``, :envvar:`KITTY_CONFIG_DIRECTORY`.
configuration files such as ``XDG_*``, :envvar:`KITTY_CONFIG_DIRECTORY` and,
most importantly, ``PATH`` to locate binaries.
To see the environment variables that kitty sees, you can add the following
mapping to :file:`kitty.conf`::

View File

@@ -149,14 +149,14 @@ user presses, for example, :kbd:`ctrl+shift+a` the escape code would be ``CSI
97;modifiers u``. It *must not* be ``CSI 65; modifiers u``.
If *alternate key reporting* is requested by the program running in the
terminal, the terminal can send two additional Unicode codepoints, the
*shifted key* and *base layout key*, separated by colons.
The shifted key is simply the upper-case version of ``unicode-codepoint``, or
more technically, the shifted version. So `a` becomes `A` and so on, based on
the current keyboard layout. This is needed to be able to match against a
shortcut such as :kbd:`ctrl+plus` which depending on the type of keyboard could
be either :kbd:`ctrl+shift+equal` or :kbd:`ctrl+plus`. Note that the shifted
key must be present only if shift is also present in the modifiers.
terminal, the terminal can send two additional Unicode codepoints, the *shifted
key* and *base layout key*, separated by colons. The shifted key is simply the
upper-case version of ``unicode-codepoint``, or more technically, the shifted
version, in the currently active keyboard layout. So `a` becomes `A` and so on,
based on the current keyboard layout. This is needed to be able to match
against a shortcut such as :kbd:`ctrl+plus` which depending on the type of
keyboard could be either :kbd:`ctrl+shift+equal` or :kbd:`ctrl+plus`. Note that
the shifted key must be present only if shift is also present in the modifiers.
The *base layout key* is the key corresponding to the physical key in the
standard PC-101 key layout. So for example, if the user is using a Cyrillic

View File

@@ -25,20 +25,14 @@ a dock panel showing system information (Linux only).
.. versionadded:: 0.42.0
Support for macOS (the edge based panels do not prevent other windows from
floating over them because of limitations in Cocoa, but background and
overlay panels work well)
Support for macOS, see :ref:`compatibility matrix <panel_compat>` for details.
and X11 (background and overlay).
.. versionadded:: 0.34.0
Support for Wayland. See :ref:`below <panel_wayland_status>` for which
Support for Wayland. See :ref:`below <panel_compat>` for which
Wayland compositors work.
.. note::
On X11, only the ``top`` and ``bottom`` panels are widely supported,
the other types depend on the window manager used.
Using this kitten is simple, for example::
kitten panel sh -c 'printf "\n\n\nHello, world."; sleep 5s'
@@ -128,44 +122,105 @@ actual script is not public, but there are :ref:`public projects implementing
general purpose panels using kitty <panel_projects>`.
.. _panel_wayland_status:
.. _panel_compat:
Wayland compositor status
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compatibility with various platforms
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Below is a list of the status of various Wayland compositors. The panel kitten
relies of the `wlr layer shell protocol
<https://wayland.app/protocols/wlr-layer-shell-unstable-v1#compositor-support>`__,
which is technically supported by almost all Wayland compositors, but the
implementation in some of them is quite buggy.
.. only:: man
🟢 **Hyprland**
Fully working, no known issues
See the HTML documentation for the compatibility matrix.
🟢 **KDE** (kwin)
Fully working, no known issues
.. only:: not man
🟠 **Sway**
Partially working. Issues include:
* Renders its configured background over the background window instead of
under it. This is likely because it uses the wlr protocol for
backgrounds itself.
* Hiding a dock panel (unmapping the window) does not release the space
used by the dock.
Generated with the help of the :file:`panels.py` test script.
🟠 niri
Breaks when hiding (unmapping) layer shell windows. This means the quick
access terminal is non-functional, but background and dock panels work.
More technically, keyboard focus gets stuck in the hidden window and when trying
to remap the hidden window niri never sends configure events for the remapped surface.
.. tab:: Wayland
🟠 labwc
Breaks when hiding (unmapping) layer shell windows. This means the quick
access terminal is non-functional, but background and dock panels work.
More technically, when unmapping the surface (attaching a NULL buffer to
it) labwc continues to send configure events to the unmapped surface,
leading to Wayland protocol errors and a crash of labwc.
Below is a list of the status of various Wayland compositors. The panel kitten
relies of the `wlr layer shell protocol
<https://wayland.app/protocols/wlr-layer-shell-unstable-v1#compositor-support>`__,
which is technically supported by almost all Wayland compositors, but the
implementation in some of them is quite buggy.
🔴 GNOME (mutter)
Does not implement the wlr protocol at all, nothing works.
🟢 **Hyprland**
Fully working, no known issues
🟢 **KDE** (kwin)
Fully working, no known issues. KDE uses an `undocumented mapping <https://invent.kde.org/plasma/kwin/-/blob/3dc5cee6b34792486b343098e55e7f2b90dfcd00/src/layershellv1window.cpp#L24>`__ under Wayland to set the window type from the :code:`kitten panel --app-id` flag. You might want to use :code:`--app-id=dock` so that KDE treats the window as a dock panel, and disables window
appearing/disappearing animations for it.
🟠 **Sway**
Partially working. Issues include:
* Renders its configured background over the background window instead of
under it. This is likely because it uses the wlr protocol for
backgrounds itself.
* Hiding a dock panel (unmapping the window) does not release the space
used by the dock.
🟠 **niri**
Breaks when hiding (unmapping) layer shell windows. This means the quick
access terminal is non-functional, but background and dock panels work.
More technically, keyboard focus gets stuck in the hidden window and when trying
to remap the hidden window niri never sends configure events for the remapped surface.
🟠 **labwc**
Breaks when hiding (unmapping) layer shell windows. This means the quick
access terminal is non-functional, but background and dock panels work.
More technically, when unmapping the surface (attaching a NULL buffer to
it) labwc continues to send configure events to the unmapped surface,
leading to Wayland protocol errors and a crash of labwc.
🔴 **GNOME** (mutter)
Does not implement the wlr protocol at all, nothing works.
.. tab:: macOS
Mostly everything works, with the notable exception that dock panels do not
prevent other windows from covering them. This is because Apple does not
provide and way to do this in their APIs.
.. tab:: X11
Support is highly dependent on the quirks of individual window
managers. See the matrix below:
.. list-table:: Compatibility matrix
:header-rows: 1
:stub-columns: 1
* - WM
- Desktop
- Dock
- Quick
- Notes
* - KDE
- 🟠
- 🟢
- 🟢
- transparency does not work for :option:`--edge=background <--edge>`
* - GNOME
- 🟢
- 🟢
- 🟢
-
* - XFCE
- 🟢
- 🟢
- 🟢
-
* - i3
- 🔴
- 🟠
- 🔴
- only top and bottom dock panels, without transparency
* - xmonad
- 🔴
- 🔴
- 🔴
- doesn't support the needed NET_WM protocols

View File

@@ -14,8 +14,7 @@ Make a Quake like quick access terminal
.. include:: ../quake-screenshots.rst
.. versionadded:: 0.42.0
Works on macOS and Wayland, see :ref:`here for Wayland compositor support
status <panel_wayland_status>`.
See :ref:`here for what platforms it works on <panel_compat>`.
This kitten can be used to make a quick access terminal, that appears and
disappears at a key press. To do so use the following command:

View File

@@ -70,7 +70,8 @@ This works by creating three files: :file:`dark-theme.auto.conf`,
:file:`light-theme.auto.conf` and :file:`no-preference-theme.auto.conf` in the
kitty config directory. When these files exist, kitty queries the OS for its color scheme
and uses the appropriate file. Note that the colors in these files override all other
colors, even those specified using the :option:`kitty --override` command line flag.
colors, and also all background image settings,
even those specified using the :option:`kitty --override` command line flag.
kitty will also automatically change colors when the OS color scheme changes,
for example, during night/day transitions.

View File

@@ -259,9 +259,9 @@ def completion_for_launch_wrappers(*names: str) -> None:
def generate_completions_for_kitty() -> None:
print('package completion\n')
print('import "kitty/tools/cli"')
print('import "kitty/tools/cmd/tool"')
print('import "kitty/tools/cmd/at"')
print('import "github.com/kovidgoyal/kitty/tools/cli"')
print('import "github.com/kovidgoyal/kitty/tools/cmd/tool"')
print('import "github.com/kovidgoyal/kitty/tools/cmd/at"')
print('func kitty(root *cli.Command) {')
@@ -458,7 +458,7 @@ def generate_conf_parser(kitten: str, defn: Definition) -> None:
def generate_extra_cli_parser(name: str, spec: str) -> None:
print('import "kitty/tools/cli"')
print('import "github.com/kovidgoyal/kitty/tools/cli"')
go_opts = tuple(go_options_for_seq(parse_option_spec(spec)[0]))
print(f'type {name}_options struct ''{')
for opt in go_opts:
@@ -508,7 +508,7 @@ def kitten_clis() -> None:
has_underscore = '_' in kitten
print(f'package {kitten}')
print('import "fmt"')
print('import "kitty/tools/cli"')
print('import "github.com/kovidgoyal/kitty/tools/cli"')
print('var _ = fmt.Sprintf')
print('func create_cmd(root *cli.Command, run_func func(*cli.Command, *Options, []string)(int, error)) {')
print('ans := root.AddSubCommand(&cli.Command{')
@@ -723,7 +723,7 @@ def update_at_commands() -> None:
odef = '\n'.join(opt_def)
code = f'''
package at
import "kitty/tools/cli"
import "github.com/kovidgoyal/kitty/tools/cli"
type rc_global_options struct {{
{sdef}
}}
@@ -751,7 +751,7 @@ def update_completion() -> None:
with replace_if_needed('tools/cmd/edit_in_kitty/launch_generated.go'):
print('package edit_in_kitty')
print('import "kitty/tools/cli"')
print('import "github.com/kovidgoyal/kitty/tools/cli"')
print('func AddCloneSafeOpts(cmd *cli.Command) {')
completion_for_launch_wrappers('cmd')
print(''.join(CompletionSpec.from_string('type:file mime:text/* group:"Text files"').as_go_code('cmd.ArgCompleter', ' = ')))

View File

@@ -125,6 +125,7 @@ typedef struct _GLFWwindowNS
id delegate;
id view;
id layer;
pid_t previous_front_most_application;
bool maximized;
bool retina;

View File

@@ -1940,6 +1940,22 @@ screen_for_window_center(_GLFWwindow *window) {
return NSScreen.mainScreen;
}
const GLFWLayerShellConfig*
_glfwPlatformGetLayerShellConfig(_GLFWwindow *window) {
return &window->ns.layer_shell.config;
}
static NSScreen*
screen_for_name(const char *name) {
int count = 0;
GLFWmonitor **monitors = glfwGetMonitors(&count);
for (int i = 0; i < count; i++) {
const char *q = glfwGetMonitorName(monitors[i]);
if (q && strcmp(q, name) == 0) return ((_GLFWmonitor*)monitors[i])->ns.screen;
}
return NULL;
}
bool
_glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) {
#define config window->ns.layer_shell.config
@@ -1970,6 +1986,10 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
// HACK: Changing the style mask can cause the first responder to be cleared
[nswindow makeFirstResponder:window->ns.view];
NSScreen *screen = screen_for_window_center(window);
if (config.output_name[0]) {
NSScreen *q = screen_for_name(config.output_name);
if (q) screen = q;
}
unsigned cell_width, cell_height; double left_edge_spacing, top_edge_spacing, right_edge_spacing, bottom_edge_spacing;
float xscale = (float)config.expected.xscale, yscale = (float)config.expected.yscale;
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
@@ -2011,6 +2031,11 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
x += width - panel_width + 1.;
width = panel_width;
break;
case GLFW_EDGE_CENTER_SIZED:
x += (width - panel_width) / 2;
y += (height - panel_height) / 2;
width = panel_width; height = panel_height;
break;
default: // top left
y += height - panel_height + 1.;
height = panel_height; width = panel_width;
@@ -2020,8 +2045,10 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
if (height < 1.) height = NSWidth(screen.visibleFrame);
}
x += config.requested_left_margin; width -= config.requested_left_margin + config.requested_right_margin;
y += config.requested_bottom_margin; height -= config.requested_top_margin + config.requested_bottom_margin;
if (config.edge != GLFW_EDGE_CENTER_SIZED) {
x += config.requested_left_margin; width -= config.requested_left_margin + config.requested_right_margin;
y += config.requested_bottom_margin; height -= config.requested_top_margin + config.requested_bottom_margin;
}
[nswindow setAnimationBehavior:animation_behavior];
[nswindow setLevel:level];
@@ -2201,14 +2228,39 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
NSRunningApplication *app = [[NSWorkspace sharedWorkspace] frontmostApplication];
window->ns.previous_front_most_application = 0;
if (app && app.processIdentifier != getpid()) window->ns.previous_front_most_application = app.processIdentifier;
if (window->ns.layer_shell.is_active && window->ns.layer_shell.config.type == GLFW_LAYER_SHELL_BACKGROUND) {
[window->ns.object orderBack:nil];
} else [window->ns.object orderFront:nil];
debug("Previously active application pid: %d bundle identifier: %s\n",
window->ns.previous_front_most_application, app ? app.bundleIdentifier.UTF8String : "");
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
[window->ns.object orderOut:nil];
pid_t prev_app_pid = window->ns.previous_front_most_application; window->ns.previous_front_most_application = 0;
NSRunningApplication *app;
if (window->ns.layer_shell.is_active && prev_app_pid > 0 && (app = [NSRunningApplication runningApplicationWithProcessIdentifier:prev_app_pid])) {
unsigned num_visible = 0;
for (_GLFWwindow *w = _glfw.windowListHead; w; w = w->next) {
if (_glfwPlatformWindowVisible(w)) num_visible++;
}
if (!num_visible) {
// yieldActivationToApplication was introduced in macOS 14 (Sonoma)
SEL selector = NSSelectorFromString(@"yieldActivationToApplication:");
if ([NSApp respondsToSelector:selector]) {
[NSApp performSelector:selector withObject:app];
[app activateWithOptions:0];
} else {
#define NSApplicationActivateIgnoringOtherApps 2
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
#undef NSApplicationActivateIgnoringOtherApps
}
}
}
}
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED)

11
glfw/dbus_glfw.c vendored
View File

@@ -214,13 +214,6 @@ typedef struct {
void *user_data;
} MethodResponse;
static const char*
format_message_error(DBusError *err) {
static char buf[1024];
snprintf(buf, sizeof(buf), "[%s] %s", err->name ? err->name : "", err->message);
return buf;
}
static void
method_reply_received(DBusPendingCall *pending, void *user_data) {
MethodResponse *res = (MethodResponse*)user_data;
@@ -228,7 +221,7 @@ method_reply_received(DBusPendingCall *pending, void *user_data) {
if (msg) {
DBusError err;
dbus_error_init(&err);
if (dbus_set_error_from_message(&err, msg)) res->callback(NULL, format_message_error(&err), res->user_data);
if (dbus_set_error_from_message(&err, msg)) res->callback(NULL, &err, res->user_data);
else res->callback(msg, NULL, res->user_data);
}
}
@@ -243,7 +236,7 @@ call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_p
DBusError error; dbus_error_init(&error);
RAII_MSG(reply, dbus_connection_send_with_reply_and_block(session_bus, msg, timeout, &error));
if (dbus_error_is_set(&error)) {
callback(reply, error.message, user_data);
callback(reply, &error, user_data);
return false;
} else if (reply) {
callback(reply, NULL, user_data);

2
glfw/dbus_glfw.h vendored
View File

@@ -33,7 +33,7 @@
static inline void cleanup_msg(void *p) { DBusMessage *m = *(DBusMessage**)p; if (m) dbus_message_unref(m); m = NULL; }
#define RAII_MSG(name, initializer) __attribute__((cleanup(cleanup_msg))) DBusMessage *name = initializer
typedef void(*dbus_pending_callback)(DBusMessage *msg, const char* err, void* data);
typedef void(*dbus_pending_callback)(DBusMessage *msg, const DBusError *err, void* data);
typedef struct {
EventLoopData* eld;

View File

@@ -325,7 +325,6 @@ def generate_wrappers(glfw_header: str) -> None:
void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle)
bool glfwWaylandIsWindowFullyCreated(GLFWwindow *handle)
bool glfwWaylandBeep(GLFWwindow *handle)
GLFWLayerShellConfig* glfwWaylandLayerShellConfig(GLFWwindow *handle)
pid_t glfwWaylandCompositorPID(void)
unsigned long long glfwDBusUserNotify(const GLFWDBUSNotificationData *n, GLFWDBusnotificationcreatedfun callback, void *data)
void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler)

12
glfw/glfw3.h vendored
View File

@@ -1056,6 +1056,7 @@ typedef enum {
#define GLFW_WAYLAND_APP_ID 0x00025001
#define GLFW_WAYLAND_BGCOLOR 0x00025002
#define GLFW_WAYLAND_WINDOW_TAG 0x00025003
/*! @} */
#define GLFW_NO_API 0
@@ -1302,14 +1303,19 @@ typedef struct GLFWkeyevent
typedef enum { GLFW_LAYER_SHELL_NONE, GLFW_LAYER_SHELL_BACKGROUND, GLFW_LAYER_SHELL_PANEL, GLFW_LAYER_SHELL_TOP, GLFW_LAYER_SHELL_OVERLAY } GLFWLayerShellType;
typedef enum { GLFW_EDGE_TOP, GLFW_EDGE_BOTTOM, GLFW_EDGE_LEFT, GLFW_EDGE_RIGHT, GLFW_EDGE_CENTER, GLFW_EDGE_NONE } GLFWEdge;
typedef enum { GLFW_EDGE_TOP, GLFW_EDGE_BOTTOM, GLFW_EDGE_LEFT, GLFW_EDGE_RIGHT, GLFW_EDGE_CENTER, GLFW_EDGE_NONE, GLFW_EDGE_CENTER_SIZED } GLFWEdge;
typedef enum { GLFW_FOCUS_NOT_ALLOWED, GLFW_FOCUS_EXCLUSIVE, GLFW_FOCUS_ON_DEMAND} GLFWFocusPolicy;
typedef struct GLFWLayerShellConfig {
GLFWLayerShellType type;
GLFWEdge edge;
char output_name[64];
struct {
GLFWEdge edge;
int requested_top_margin, requested_left_margin, requested_bottom_margin, requested_right_margin;
} previous;
bool was_toggled_to_fullscreen;
char output_name[128];
GLFWFocusPolicy focus_policy;
unsigned x_size_in_cells, x_size_in_pixels;
unsigned y_size_in_cells, y_size_in_pixels;
@@ -2380,6 +2386,7 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, flo
* @ingroup monitor
*/
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
GLFWAPI const char* glfwGetMonitorDescription(GLFWmonitor* monitor);
/*! @brief Sets the user pointer of the specified monitor.
*
@@ -2874,6 +2881,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, G
GLFWAPI bool glfwToggleFullscreen(GLFWwindow *window, unsigned int flags);
GLFWAPI bool glfwIsFullscreen(GLFWwindow *window, unsigned int flags);
GLFWAPI bool glfwAreSwapsAllowed(const GLFWwindow* window);
GLFWAPI const GLFWLayerShellConfig* glfwGetLayerShellConfig(GLFWwindow* handle);
GLFWAPI bool glfwSetLayerShellConfig(GLFWwindow* handle, const GLFWLayerShellConfig *value);
/*! @brief Destroys the specified window and its context.

12
glfw/ibus_glfw.c vendored
View File

@@ -373,9 +373,9 @@ read_ibus_address(_GLFWIBUSData *ibus) {
}
void
input_context_created(DBusMessage *msg, const char* errmsg, void *data) {
if (errmsg) {
_glfwInputError(GLFW_PLATFORM_ERROR, "IBUS: Failed to create input context with error: %s", errmsg);
input_context_created(DBusMessage *msg, const DBusError *err, void *data) {
if (err) {
_glfwInputError(GLFW_PLATFORM_ERROR, "IBUS: Failed to create input context with error: %s: %s", err->name, err->message);
return;
}
const char *path = NULL;
@@ -488,15 +488,15 @@ glfw_ibus_set_cursor_geometry(_GLFWIBUSData *ibus, int x, int y, int w, int h) {
}
void
key_event_processed(DBusMessage *msg, const char* errmsg, void *data) {
key_event_processed(DBusMessage *msg, const DBusError *err, void *data) {
uint32_t handled = 0;
_GLFWIBUSKeyEvent *ev = (_GLFWIBUSKeyEvent*)data;
// Restore key's text from the text embedded in the structure.
ev->glfw_ev.text = ev->__embedded_text;
bool is_release = ev->glfw_ev.action == GLFW_RELEASE;
bool failed = false;
if (errmsg) {
_glfwInputError(GLFW_PLATFORM_ERROR, "IBUS: Failed to process key with error: %s", errmsg);
if (err) {
_glfwInputError(GLFW_PLATFORM_ERROR, "IBUS: Failed to process key with error: %s: %s", err->name, err->message);
failed = true;
} else {
glfw_dbus_get_args(msg, "Failed to get IBUS handled key from reply", DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID);

5
glfw/internal.h vendored
View File

@@ -331,7 +331,7 @@ struct _GLFWwndconfig
char instanceName[256];
} x11;
struct {
char appId[256];
char appId[256], windowTag[256];
uint32_t bgcolor;
} wl;
};
@@ -490,7 +490,7 @@ struct _GLFWwindow
//
struct _GLFWmonitor
{
char* name;
const char *name, *description;
void* userPointer;
// Physical dimensions in millimeters.
@@ -719,6 +719,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
int count, const GLFWimage* images);
bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value);
const GLFWLayerShellConfig* _glfwPlatformGetLayerShellConfig(_GLFWwindow* window);
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);

View File

@@ -24,15 +24,47 @@ static int theme_size = -1;
static GLFWColorScheme appearance = GLFW_COLOR_SCHEME_NO_PREFERENCE;
static bool cursor_theme_changed = false, appearance_initialized = false;
#define HANDLER(name) static void name(DBusMessage *msg, const char* errmsg, void *data) { \
#define HANDLER(name_) static void name_(DBusMessage *msg, const DBusError* err, void *data) { \
(void)data; \
if (errmsg) { \
_glfwInputError(GLFW_PLATFORM_ERROR, "%s: failed with error: %s", #name, errmsg); \
if (err) { \
_glfwInputError(GLFW_PLATFORM_ERROR, "%s: failed with error: %s: %s", #name_, err->name, err->message); \
return; \
}
HANDLER(get_color_scheme_legacy)
DBusMessageIter iter, variant_iter, variant_iter2;
if (!dbus_message_iter_init(msg, &iter)) return;
dbus_message_iter_recurse(&iter, &variant_iter);
int type = dbus_message_iter_get_arg_type(&variant_iter);
if (type != DBUS_TYPE_VARIANT) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Read for color-scheme did not return a variant"); return;
}
dbus_message_iter_recurse(&variant_iter, &variant_iter2);
if (type != DBUS_TYPE_VARIANT) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Read for color-scheme did not return a nested variant"); return;
}
uint32_t val;
dbus_message_iter_get_basic(&variant_iter2, &val);
if (val < 3) appearance = val;
}
HANDLER(get_color_scheme)
static void
get_color_scheme(DBusMessage *msg, const DBusError* err, void *data) {
(void) data;
if (err) {
if (strcmp("org.freedesktop.DBus.Error.UnknownMethod", err->name) == 0) {
DBusConnection *session_bus = glfw_dbus_session_bus();
if (session_bus) {
const char *namespace = FDO_DESKTOP_NAMESPACE, *key = FDO_APPEARANCE_KEY;
glfw_dbus_call_blocking_method(session_bus, DESKTOP_SERVICE, DESKTOP_PATH, DESKTOP_INTERFACE, "Read", DBUS_TIMEOUT_USE_DEFAULT,
get_color_scheme_legacy, NULL, DBUS_TYPE_STRING, &namespace, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID);
}
return;
} else {
_glfwInputError(GLFW_PLATFORM_ERROR, "%s: failed with error: %s: %s", "get_color_scheme", err->name, err->message);
return;
}
}
uint32_t val;
DBusMessageIter iter, variant_iter;
if (!dbus_message_iter_init(msg, &iter)) return;

10
glfw/linux_notify.c vendored
View File

@@ -32,9 +32,9 @@ glfw_dbus_set_user_notification_activated_handler(GLFWDBusnotificationactivatedf
}
void
notification_created(DBusMessage *msg, const char* errmsg, void *data) {
if (errmsg) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Notify: Failed to create notification error: %s", errmsg);
notification_created(DBusMessage *msg, const DBusError* err, void *data) {
if (err) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Notify: Failed to create notification error: %s: %s", err->name, err->message);
if (data) free(data);
return;
}
@@ -95,9 +95,9 @@ cancel_user_notification(DBusConnection *session_bus, uint32_t *id) {
}
static void
got_capabilities(DBusMessage *msg, const char* err, void* data UNUSED) {
got_capabilities(DBusMessage *msg, const DBusError* err, void* data UNUSED) {
if (err) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Notify: Failed to get server capabilities error: %s", err);
_glfwInputError(GLFW_PLATFORM_ERROR, "Notify: Failed to get server capabilities error: %s: %s", err->name, err->message);
return;
}
#define check_call(func, err, ...) if (!func(__VA_ARGS__)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Notify: GetCapabilities: %s", err); return; }

15
glfw/monitor.c vendored
View File

@@ -186,7 +186,8 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
_glfwFreeGammaArrays(&monitor->currentRamp);
free(monitor->modes);
free(monitor->name);
free((void*)monitor->name);
free((void*)monitor->description);
free(monitor);
}
@@ -393,9 +394,19 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->name;
return monitor->name ? monitor->name : "";
}
GLFWAPI const char* glfwGetMonitorDescription(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->description ? monitor->description : "";
}
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;

View File

@@ -86,6 +86,7 @@
"unstable/idle-inhibit/idle-inhibit-unstable-v1.xml",
"staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml",
"staging/xdg-system-bell/xdg-system-bell-v1.xml",
"staging/xdg-toplevel-tag/xdg-toplevel-tag-v1.xml",
"kwin-blur-v1.xml",
"wlr-layer-shell-unstable-v1.xml"

13
glfw/window.c vendored
View File

@@ -495,6 +495,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
strncpy(_glfw.hints.window.wl.appId, value,
sizeof(_glfw.hints.window.wl.appId) - 1);
return;
case GLFW_WAYLAND_WINDOW_TAG:
strncpy(_glfw.hints.window.wl.windowTag, value,
sizeof(_glfw.hints.window.wl.windowTag) - 1);
return;
}
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
@@ -551,6 +555,15 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
window->shouldClose = value;
}
GLFWAPI const GLFWLayerShellConfig* glfwGetLayerShellConfig(GLFWwindow* handle) {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
return _glfwPlatformGetLayerShellConfig(window);
}
GLFWAPI bool glfwSetLayerShellConfig(GLFWwindow* handle, const GLFWLayerShellConfig *value) {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);

5
glfw/wl_init.c vendored
View File

@@ -605,6 +605,8 @@ static void registryHandleGlobal(void* data UNUSED,
}
else if (is(xdg_system_bell_v1)) {
_glfw.wl.xdg_system_bell_v1 = wl_registry_bind(registry, name, &xdg_system_bell_v1_interface, 1);
} else if (is(xdg_toplevel_tag_manager_v1)) {
_glfw.wl.xdg_toplevel_tag_manager_v1 = wl_registry_bind(registry, name, &xdg_toplevel_tag_manager_v1_interface, 1);
}
#undef is
}
@@ -716,6 +718,7 @@ get_compositor_missing_capabilities(void) {
C(cursor_shape, wp_cursor_shape_manager_v1); C(layer_shell, zwlr_layer_shell_v1);
C(single_pixel_buffer, wp_single_pixel_buffer_manager_v1); C(preferred_scale, has_preferred_buffer_scale);
C(idle_inhibit, idle_inhibit_manager); C(icon, xdg_toplevel_icon_manager_v1); C(bell, xdg_system_bell_v1);
C(window-tag, xdg_toplevel_tag_manager_v1);
if (_glfw.wl.xdg_wm_base_version < 6) p += snprintf(p, sizeof(buf) - (p - buf), "%s ", "window-state-suspended");
if (_glfw.wl.xdg_wm_base_version < 5) p += snprintf(p, sizeof(buf) - (p - buf), "%s ", "window-capabilities");
#undef C
@@ -894,6 +897,8 @@ void _glfwPlatformTerminate(void)
xdg_toplevel_icon_manager_v1_destroy(_glfw.wl.xdg_toplevel_icon_manager_v1);
if (_glfw.wl.xdg_system_bell_v1)
xdg_system_bell_v1_destroy(_glfw.wl.xdg_system_bell_v1);
if (_glfw.wl.xdg_toplevel_tag_manager_v1)
xdg_toplevel_tag_manager_v1_destroy(_glfw.wl.xdg_toplevel_tag_manager_v1);
if (_glfw.wl.wp_single_pixel_buffer_manager_v1)
wp_single_pixel_buffer_manager_v1_destroy(_glfw.wl.wp_single_pixel_buffer_manager_v1);
if (_glfw.wl.wp_cursor_shape_manager_v1)

24
glfw/wl_monitor.c vendored
View File

@@ -41,20 +41,15 @@ static void outputHandleGeometry(void* data,
int32_t physicalWidth,
int32_t physicalHeight,
int32_t subpixel UNUSED,
const char* make,
const char* model,
const char* make UNUSED,
const char* model UNUSED,
int32_t transform UNUSED)
{
struct _GLFWmonitor *monitor = data;
char name[1024];
monitor->wl.x = x;
monitor->wl.y = y;
monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight;
snprintf(name, sizeof(name), "%s %s", make, model);
monitor->name = _glfw_strdup(name);
}
static void outputHandleMode(void* data,
@@ -105,15 +100,20 @@ static void outputHandleName(void* data,
struct wl_output* output UNUSED,
const char* name) {
struct _GLFWmonitor *monitor = data;
if (name) strncpy(monitor->wl.friendly_name, name, sizeof(monitor->wl.friendly_name)-1);
if (name) {
if (monitor->name) free((void*)monitor->name);
monitor->name = _glfw_strdup(name);
}
}
static void outputHandleDescription(void* data,
struct wl_output* output UNUSED,
const char* description) {
struct _GLFWmonitor *monitor = data;
if (description) strncpy(monitor->wl.description, description, sizeof(monitor->wl.description)-1);
if (description) {
if (monitor->description) free((void*)monitor->description);
monitor->description = _glfw_strdup(description);
}
}
static const struct wl_output_listener outputListener = {
@@ -142,8 +142,8 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
return;
}
// The actual name of this output will be set in the geometry handler.
monitor = _glfwAllocMonitor(NULL, 0, 0);
// The actual name of this output will be set in the handlers.
monitor = _glfwAllocMonitor("unnamed", 0, 0);
output = wl_registry_bind(_glfw.wl.registry,
name,

5
glfw/wl_platform.h vendored
View File

@@ -68,6 +68,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
#include "wayland-xdg-toplevel-icon-v1-client-protocol.h"
#include "wayland-xdg-system-bell-v1-client-protocol.h"
#include "wayland-xdg-toplevel-tag-v1-client-protocol.h"
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
@@ -210,7 +211,7 @@ typedef struct _GLFWwindowWayland
double cursorPosX, cursorPosY, allCursorPosX, allCursorPosY;
char* title;
char appId[256];
char appId[256], windowTag[256];
// We need to track the monitors the window spans on to calculate the
// optimal scaling factor.
@@ -340,6 +341,7 @@ typedef struct _GLFWlibraryWayland
struct xdg_activation_v1* xdg_activation_v1;
struct xdg_toplevel_icon_manager_v1* xdg_toplevel_icon_manager_v1;
struct xdg_system_bell_v1* xdg_system_bell_v1;
struct xdg_toplevel_tag_manager_v1* xdg_toplevel_tag_manager_v1;
struct wp_cursor_shape_manager_v1* wp_cursor_shape_manager_v1;
struct wp_cursor_shape_device_v1* wp_cursor_shape_device_v1;
struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1;
@@ -406,7 +408,6 @@ typedef struct _GLFWmonitorWayland
{
struct wl_output* output;
uint32_t name;
char friendly_name[64], description[64];
int currentMode;
int x;

22
glfw/wl_window.c vendored
View File

@@ -971,7 +971,7 @@ find_output_by_name(const char* name) {
if (!name || !name[0]) return NULL;
for (int i = 0; i < _glfw.monitorCount; i++) {
_GLFWmonitor *m = _glfw.monitors[i];
if (strcmp(m->wl.friendly_name, name) == 0) return m->wl.output;
if (strcmp(m->name, name) == 0) return m->wl.output;
}
return NULL;
}
@@ -1028,12 +1028,13 @@ layer_set_properties(const _GLFWwindow *window, bool during_creation, uint32_t w
if (!config.override_exclusive_zone) exclusive_zone = width;
break;
case GLFW_EDGE_CENTER:
which_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
break;
case GLFW_EDGE_CENTER_SIZED:
panel_width = width; panel_height = height;
break;
case GLFW_EDGE_NONE:
which_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
panel_width = width;
panel_height = height;
panel_width = width; panel_height = height;
break;
}
}
@@ -1069,9 +1070,9 @@ calculate_layer_size(_GLFWwindow *window, uint32_t *width, uint32_t *height) {
if (!*height) *height = monitor_height;
return;
}
debug("Calculating layer shell window size at scale: %f\n", xscale);
const unsigned xsz = config->x_size_in_pixels ? (unsigned)(config->x_size_in_pixels * xscale) : (cell_width * config->x_size_in_cells);
const unsigned ysz = config->y_size_in_pixels ? (unsigned)(config->y_size_in_pixels * yscale) : (cell_height * config->y_size_in_cells);
debug("Calculating layer shell window size at scale: %f cell_size: %u %u sz: %u %u\n", xscale, cell_width, cell_height, xsz, ysz);
if (config->edge == GLFW_EDGE_LEFT || config->edge == GLFW_EDGE_RIGHT) {
if (!*height) *height = monitor_height;
double spacing = spacing_x;
@@ -1143,7 +1144,7 @@ create_layer_shell_surface(_GLFWwindow *window) {
struct wl_output *wl_output = find_output_by_name(window->wl.layer_shell.config.output_name);
#define ls window->wl.layer_shell.zwlr_layer_surface_v1
ls = zwlr_layer_shell_v1_get_layer_surface(
_glfw.wl.zwlr_layer_shell_v1, window->wl.surface, wl_output, get_layer_shell_layer(window), "kitty");
_glfw.wl.zwlr_layer_shell_v1, window->wl.surface, wl_output, get_layer_shell_layer(window), window->wl.appId[0] ? window->wl.appId : "kitty");
if (!ls) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: layer-surface creation failed");
return false;
@@ -1197,8 +1198,10 @@ create_window_desktop_surface(_GLFWwindow* window)
zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration, &xdgDecorationListener, window);
}
if (strlen(window->wl.appId))
if (window->wl.appId[0])
xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
if (window->wl.windowTag[0] && _glfw.wl.xdg_toplevel_tag_manager_v1)
xdg_toplevel_tag_manager_v1_set_toplevel_tag(_glfw.wl.xdg_toplevel_tag_manager_v1, window->wl.xdg.toplevel, window->wl.windowTag);
if (window->wl.title)
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
@@ -2892,8 +2895,9 @@ GLFWAPI void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle) {
if (csd_change_title(window)) commit_window_surface_if_safe(window);
}
GLFWAPI GLFWLayerShellConfig* glfwWaylandLayerShellConfig(GLFWwindow *handle) {
return &((_GLFWwindow*)handle)->wl.layer_shell.config;
const GLFWLayerShellConfig*
_glfwPlatformGetLayerShellConfig(_GLFWwindow *window) {
return &window->wl.layer_shell.config;
}
GLFWAPI bool glfwIsLayerShellSupported(void) { return _glfw.wl.zwlr_layer_shell_v1 != NULL; }

82
glfw/x11_init.c vendored
View File

@@ -47,16 +47,11 @@
//
static Atom getAtomIfSupported(Atom* supportedAtoms,
unsigned long atomCount,
const char* atomName)
const Atom atom)
{
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
for (unsigned long i = 0; i < atomCount; i++)
{
if (supportedAtoms[i] == atom)
return atom;
for (unsigned long i = 0; i < atomCount; i++) {
if (supportedAtoms[i] == atom) return atom;
}
return None;
}
@@ -120,49 +115,36 @@ static void detectEWMH(void)
// See which of the atoms we support that are supported by the WM
_glfw.x11.NET_WM_STATE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
_glfw.x11.NET_WM_STATE_ABOVE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
_glfw.x11.NET_WM_STATE_BELOW =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_BELOW");
_glfw.x11.NET_WM_STATE_FULLSCREEN =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
_glfw.x11.NET_WM_STATE_SKIP_TASKBAR =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_SKIP_TASKBAR");
_glfw.x11.NET_WM_STATE_SKIP_PAGER =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_SKIP_PAGER");
_glfw.x11.NET_WM_STATE_STICKY =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_STICKY");
_glfw.x11.NET_WM_FULLSCREEN_MONITORS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
_glfw.x11.NET_WM_WINDOW_TYPE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
_glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
_glfw.x11.NET_WM_WINDOW_TYPE_DOCK =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_DOCK");
_glfw.x11.NET_WM_WINDOW_TYPE_DESKTOP =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_DESKTOP");
_glfw.x11.NET_WORKAREA =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
_glfw.x11.NET_CURRENT_DESKTOP =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
_glfw.x11.NET_ACTIVE_WINDOW =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
_glfw.x11.NET_FRAME_EXTENTS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
_glfw.x11.NET_WM_STRUT_PARTIAL =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STRUT_PARTIAL");
#define ALL_ATOMS \
S(NET_WM_STATE) S(NET_WM_STATE_ABOVE) S(NET_WM_STATE_BELOW) S(NET_WM_STATE_FULLSCREEN) \
S(NET_WM_STATE_MAXIMIZED_VERT) S(NET_WM_STATE_MAXIMIZED_HORZ) S(NET_WM_STATE_DEMANDS_ATTENTION) \
S(NET_WM_STATE_SKIP_TASKBAR) S(NET_WM_STATE_SKIP_PAGER) S(NET_WM_STATE_STICKY) \
\
S(NET_WM_FULLSCREEN_MONITORS) S(NET_WM_STRUT_PARTIAL) \
\
S(NET_WM_WINDOW_TYPE) S(NET_WM_WINDOW_TYPE_NORMAL) S(NET_WM_WINDOW_TYPE_DOCK) S(NET_WM_WINDOW_TYPE_DESKTOP) \
S(NET_WM_WINDOW_TYPE_UTILITY) S(NET_WM_WINDOW_TYPE_SPLASH) S(NET_WM_WINDOW_TYPE_DIALOG) S(NET_WM_WINDOW_TYPE_MENU) \
S(NET_WM_WINDOW_TYPE_NOTIFICATION) \
\
S(NET_WORKAREA) S(NET_CURRENT_DESKTOP) S(NET_ACTIVE_WINDOW) S(NET_FRAME_EXTENTS) S(NET_REQUEST_FRAME_EXTENTS) \
\
S(NET_WM_ALLOWED_ACTIONS) S(NET_WM_ACTION_MOVE) S(NET_WM_ACTION_RESIZE) S(NET_WM_ACTION_MINIMIZE) \
S(NET_WM_ACTION_SHADE) S(NET_WM_ACTION_STICK) S(NET_WM_ACTION_MAXIMIZE_HORZ) S(NET_WM_ACTION_MAXIMIZE_VERT) \
S(NET_WM_ACTION_FULLSCREEN) S(NET_WM_ACTION_CHANGE_DESKTOP) S(NET_WM_ACTION_CLOSE) S(NET_WM_ACTION_ABOVE) \
S(NET_WM_ACTION_BELOW) S(NET_WM_ACTION_ABOVE_BELOW)
static const char* atom_names[40] = {
#define S(x) "_" #x,
ALL_ATOMS
};
#undef S
Atom atoms[arraysz(atom_names)];
XInternAtoms(_glfw.x11.display, (char**)atom_names, arraysz(atom_names), False, atoms);
unsigned i = 0;
#define S(name) _glfw.x11.name = getAtomIfSupported(supportedAtoms, atomCount, atoms[i++]);
ALL_ATOMS
#undef S
#undef ALL_ATOMS
XFree(supportedAtoms);
}

6
glfw/x11_platform.h vendored
View File

@@ -251,14 +251,12 @@ typedef struct _GLFWlibraryX11
Atom WM_STATE;
Atom WM_DELETE_WINDOW;
Atom NET_WM_NAME;
Atom NET_WM_ALLOWED_ACTIONS, NET_WM_ACTION_MOVE, NET_WM_ACTION_RESIZE, NET_WM_ACTION_MINIMIZE, NET_WM_ACTION_SHADE, NET_WM_ACTION_STICK, NET_WM_ACTION_MAXIMIZE_HORZ, NET_WM_ACTION_MAXIMIZE_VERT, NET_WM_ACTION_FULLSCREEN, NET_WM_ACTION_CHANGE_DESKTOP, NET_WM_ACTION_CLOSE, NET_WM_ACTION_ABOVE, NET_WM_ACTION_BELOW, NET_WM_ACTION_ABOVE_BELOW;
Atom NET_WM_ICON_NAME;
Atom NET_WM_ICON;
Atom NET_WM_PID;
Atom NET_WM_PING;
Atom NET_WM_WINDOW_TYPE;
Atom NET_WM_WINDOW_TYPE_NORMAL;
Atom NET_WM_WINDOW_TYPE_DOCK;
Atom NET_WM_WINDOW_TYPE_DESKTOP;
Atom NET_WM_WINDOW_TYPE, NET_WM_WINDOW_TYPE_NORMAL, NET_WM_WINDOW_TYPE_DOCK, NET_WM_WINDOW_TYPE_DESKTOP, NET_WM_WINDOW_TYPE_UTILITY, NET_WM_WINDOW_TYPE_SPLASH, NET_WM_WINDOW_TYPE_DIALOG, NET_WM_WINDOW_TYPE_MENU, NET_WM_WINDOW_TYPE_NOTIFICATION;
Atom NET_WM_STATE;
Atom NET_WM_STATE_ABOVE;
Atom NET_WM_STATE_BELOW;

61
glfw/x11_window.c vendored
View File

@@ -538,13 +538,28 @@ typedef struct WindowGeometry {
strut_type struts[12];
} WindowGeometry;
#define config (window->x11.layer_shell.config)
static _GLFWmonitor*
find_monitor_by_name(const char* name) {
if (!name || !name[0]) return (_GLFWmonitor*)glfwGetPrimaryMonitor();;
for (int i = 0; i < _glfw.monitorCount; i++) {
_GLFWmonitor *m = _glfw.monitors[i];
if (strcmp(m->name, name) == 0) return m;
}
return (_GLFWmonitor*)glfwGetPrimaryMonitor();;
}
static WindowGeometry
calculate_layer_geometry(_GLFWwindow *window) {
_GLFWmonitor *monitor = find_monitor_by_name(config.output_name);
MonitorGeometry mg = _glfwPlatformGetMonitorGeometry((_GLFWmonitor*)glfwGetPrimaryMonitor());
WindowGeometry ans = {0};
debug_rendering("Monitor: %s full: %dx%d@%dx%d workarea: %dx%d@%dx%d\n", monitor->name,
mg.full.width, mg.full.height, mg.full.x, mg.full.y, mg.workarea.width, mg.workarea.height, mg.workarea.x, mg.workarea.y);
ans.width = mg.full.width; ans.height = mg.full.height;
ans.x = mg.full.x; ans.y = mg.full.y;
#define config (window->x11.layer_shell.config)
ans.needs_strut = config.type == GLFW_LAYER_SHELL_PANEL;
if (config.type == GLFW_LAYER_SHELL_BACKGROUND) {
ans.x += config.requested_left_margin; ans.y += config.requested_top_margin;
@@ -560,7 +575,6 @@ calculate_layer_geometry(_GLFWwindow *window) {
double spacing_y = top_edge_spacing + bottom_edge_spacing;
double xsz = config.x_size_in_pixels ? (unsigned)(config.x_size_in_pixels * xscale) : (cell_width * config.x_size_in_cells);
double ysz = config.y_size_in_pixels ? (unsigned)(config.y_size_in_pixels * yscale) : (cell_height * config.y_size_in_cells);
xsz /= xscale; ysz /= yscale;
ans.width = (int)(1. + spacing_x + xsz); ans.height = (int)(1. + spacing_y + ysz);
GeometryRect m = config.type == GLFW_LAYER_SHELL_TOP || config.type == GLFW_LAYER_SHELL_OVERLAY ? mg.workarea : mg.full;
static const struct {
@@ -592,6 +606,11 @@ calculate_layer_geometry(_GLFWwindow *window) {
ans.width = m.width - config.requested_right_margin - config.requested_left_margin;
ans.struts[s.bottom] = ans.height; ans.struts[s.bottom_end_x] = ans.width;
break;
case GLFW_EDGE_CENTER_SIZED:
ans.needs_strut = false;
ans.x = (m.width - ans.width) / 2;
ans.y = (m.height - ans.height) / 2;
break;
default:
ans.needs_strut = false;
ans.x = m.x + config.requested_left_margin;
@@ -600,6 +619,8 @@ calculate_layer_geometry(_GLFWwindow *window) {
ans.width = m.width - config.requested_right_margin - config.requested_left_margin;
break;
}
debug_rendering("Calculating layer geometry at scale: %f cell size: (%u, %u) -> %dx%d@%dx%d needs_strut: %d\n",
xscale, cell_width, cell_height, ans.width, ans.height, ans.x, ans.y, ans.needs_strut)
return ans;
}
@@ -616,15 +637,15 @@ update_wm_hints(_GLFWwindow *window, const WindowGeometry *wg, const _GLFWwndcon
hints->flags = StateHint | InputHint;
hints->initial_state = NormalState;
hints->input = true;
if (is_layer_shell && (config.type == GLFW_LAYER_SHELL_BACKGROUND || config.type == GLFW_LAYER_SHELL_PANEL)) hints->input = false;
if (is_layer_shell && config.focus_policy == GLFW_FOCUS_NOT_ALLOWED) hints->input = false;
XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
} else _glfwInputError(GLFW_OUT_OF_MEMORY, "X11: Failed to allocate WM hints");
if (_glfw.x11.NET_WM_WINDOW_TYPE) {
Atom type = 0;
if (window->x11.layer_shell.is_active) {
if (is_layer_shell) {
const char *name = NULL;
#define S(which) type = _glfw.x11.NET_WM_WINDOW_TYPE_DESKTOP; name = #which
#define S(which) type = _glfw.x11.which; name = #which
switch (config.type) {
case GLFW_LAYER_SHELL_BACKGROUND: S(NET_WM_WINDOW_TYPE_DESKTOP); break;
case GLFW_LAYER_SHELL_PANEL: S(NET_WM_WINDOW_TYPE_DOCK); break;
@@ -663,7 +684,11 @@ update_wm_hints(_GLFWwindow *window, const WindowGeometry *wg, const _GLFWwndcon
#define S(x) if (_glfw.x11.x) { states[count++] = _glfw.x11.x; } else { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Window manager does not support _%s", #x); ok = false; }
switch (config.type) {
case GLFW_LAYER_SHELL_NONE: break;
case GLFW_LAYER_SHELL_BACKGROUND: case GLFW_LAYER_SHELL_PANEL: S(NET_WM_STATE_BELOW); break;
case GLFW_LAYER_SHELL_BACKGROUND: S(NET_WM_STATE_BELOW); break;
case GLFW_LAYER_SHELL_PANEL:
// i3 does not support NET_WM_STATE_BELOW but panels work without it
if (_glfw.x11.NET_WM_STATE_BELOW) { S(NET_WM_STATE_BELOW); }
break;
case GLFW_LAYER_SHELL_TOP: case GLFW_LAYER_SHELL_OVERLAY: S(NET_WM_STATE_ABOVE); break;
}
#undef S
@@ -685,7 +710,10 @@ update_wm_hints(_GLFWwindow *window, const WindowGeometry *wg, const _GLFWwndcon
if (count && _glfw.x11.NET_WM_STATE) XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_STATE,
XA_ATOM, 32, PropModeReplace, (unsigned char*) states, count);
}
if (!wndconfig && ok) _glfwPlatformSetWindowPos(window, wg->x, wg->y);
if (!wndconfig && ok) {
_glfwPlatformSetWindowPos(window, wg->x, wg->y);
_glfwPlatformSetWindowSize(window, wg->width, wg->height);
}
return ok;
#undef config
}
@@ -720,6 +748,7 @@ static bool createNativeWindow(_GLFWwindow* window,
_glfwGrabErrorHandlerX11();
window->x11.parent = _glfw.x11.root;
debug_rendering("Creating window with geometry: %dx%d@%dx%d\n", wg.width, wg.height, wg.x, wg.y);
window->x11.handle = XCreateWindow(_glfw.x11.display,
_glfw.x11.root,
wg.x, wg.y, // Position
@@ -768,6 +797,8 @@ static bool createNativeWindow(_GLFWwindow* window,
}
if (!update_wm_hints(window, &wg, wndconfig)) return false;
// without this floating window position is incorrect on KDE
if (window->x11.layer_shell.is_active) _glfwPlatformSetWindowPos(window, wg.x, wg.y);
// Set ICCCM WM_CLASS property
{
@@ -1530,6 +1561,7 @@ static void processEvent(XEvent *event)
if (event->xconfigure.width != window->x11.width ||
event->xconfigure.height != window->x11.height)
{
debug_rendering("Window resized to: %d %d from: %d %d\n", event->xconfigure.width, event->xconfigure.height, window->x11.width, window->x11.height);
_glfwInputFramebufferSize(window,
event->xconfigure.width,
event->xconfigure.height);
@@ -1564,9 +1596,9 @@ static void processEvent(XEvent *event)
return;
}
}
if (xpos != window->x11.xpos || ypos != window->x11.ypos)
{
debug_rendering("Window moved to: %d %d from: %d %d\n", xpos, ypos, window->x11.xpos, window->x11.xpos);
_glfwInputWindowPos(window, xpos, ypos);
window->x11.xpos = xpos;
window->x11.ypos = ypos;
@@ -2065,7 +2097,13 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
XFlush(_glfw.x11.display);
}
bool _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) {
const GLFWLayerShellConfig*
_glfwPlatformGetLayerShellConfig(_GLFWwindow *window) {
return &window->x11.layer_shell.config;
}
bool
_glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig *value) {
if (value) window->x11.layer_shell.config = *value;
WindowGeometry wg = calculate_layer_geometry(window);
update_wm_hints(window, &wg, NULL);
@@ -2425,6 +2463,11 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
return;
XMapWindow(_glfw.x11.display, window->x11.handle);
// without this floating window position is incorrect on KDE
if (window->x11.layer_shell.is_active) {
WindowGeometry wg = calculate_layer_geometry(window);
_glfwPlatformSetWindowPos(window, wg.x, wg.y);
}
waitForVisibilityNotify(window);
}

8
go.mod
View File

@@ -1,4 +1,4 @@
module kitty
module github.com/kovidgoyal/kitty
go 1.23.0
@@ -6,7 +6,7 @@ toolchain go1.24.1
require (
github.com/ALTree/bigfloat v0.2.0
github.com/alecthomas/chroma/v2 v2.17.0
github.com/alecthomas/chroma/v2 v2.17.2
github.com/bmatcuk/doublestar/v4 v4.8.1
github.com/dlclark/regexp2 v1.11.5
github.com/edwvee/exiffix v0.0.0-20240229113213-0dbb146775be
@@ -17,8 +17,8 @@ require (
github.com/shirou/gopsutil/v3 v3.24.5
github.com/zeebo/xxh3 v1.0.2
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
golang.org/x/image v0.26.0
golang.org/x/sys v0.32.0
golang.org/x/image v0.27.0
golang.org/x/sys v0.33.0
howett.net/plist v1.0.1
)

12
go.sum
View File

@@ -2,8 +2,8 @@ github.com/ALTree/bigfloat v0.2.0 h1:AwNzawrpFuw55/YDVlcPw0F0cmmXrmngBHhVrvdXPvM
github.com/ALTree/bigfloat v0.2.0/go.mod h1:+NaH2gLeY6RPBPPQf4aRotPPStg+eXc8f9ZaE4vRfD4=
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma/v2 v2.17.0 h1:3r2Cgk+nXNICMBxIFGnTRTbQFUwMiLisW+9uos0TtUI=
github.com/alecthomas/chroma/v2 v2.17.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
github.com/alecthomas/chroma/v2 v2.17.2 h1:Rm81SCZ2mPoH+Q8ZCc/9YvzPUN/E7HgPiPJD8SLV6GI=
github.com/alecthomas/chroma/v2 v2.17.2/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38=
@@ -63,15 +63,15 @@ github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaD
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY=
golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c=
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
golang.org/x/image v0.27.0/go.mod h1:xbdrClrAUway1MUTEZDq9mz/UpRwYAkFFNUslZtcB+g=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=

View File

@@ -4,13 +4,13 @@ package ask
import (
"fmt"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
"io"
"kitty/tools/cli/markup"
"kitty/tools/tty"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"os"
"regexp"
"strings"

View File

@@ -9,9 +9,9 @@ import (
"path/filepath"
"time"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -6,9 +6,9 @@ import (
"errors"
"fmt"
"kitty/tools/cli"
"kitty/tools/cli/markup"
"kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/tui"
)
var _ = fmt.Print

View File

@@ -10,7 +10,7 @@ import (
"sync"
"time"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -9,10 +9,10 @@ import (
"strings"
"sync"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -5,8 +5,8 @@ import (
"math"
"sync"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -2,10 +2,10 @@ package choose_fonts
import (
"fmt"
"kitty/tools/tui"
"kitty/tools/tui/subseq"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/subseq"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -5,9 +5,9 @@ import (
"path/filepath"
"strings"
"kitty/tools/config"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -5,10 +5,10 @@ import (
"strconv"
"strings"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -5,11 +5,11 @@ import (
"strings"
"sync"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"os"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/loop"
)
var _ = fmt.Print

View File

@@ -2,7 +2,7 @@ package choose_fonts
import (
"fmt"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils"
"slices"
"strings"
)

View File

@@ -7,8 +7,8 @@ import (
"strings"
"sync"
"kitty/tools/utils"
"kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
)
var _ = fmt.Print

View File

@@ -6,10 +6,10 @@ import (
"strconv"
"sync"
"kitty/tools/tui"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -11,9 +11,9 @@ import (
"os"
"strings"
"kitty/tools/tty"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -5,7 +5,7 @@ package clipboard
import (
"os"
"kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/cli"
)
func run_mime_loop(opts *Options, args []string) (err error) {

View File

@@ -14,10 +14,10 @@ import (
"strings"
"sync"
"kitty/tools/tty"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
)
var _ = fmt.Print
@@ -201,7 +201,7 @@ func unescape_metadata_value(k, x string) (ans string) {
return x
}
func encode_bytes(metadata map[string]string, payload []byte) string {
func Encode_bytes(metadata map[string]string, payload []byte) string {
ans := strings.Builder{}
enc_payload := ""
if len(payload) > 0 {
@@ -228,7 +228,7 @@ func encode_bytes(metadata map[string]string, payload []byte) string {
}
func encode(metadata map[string]string, payload string) string {
return encode_bytes(metadata, utils.UnsafeStringToBytes(payload))
return Encode_bytes(metadata, utils.UnsafeStringToBytes(payload))
}
func error_from_status(status string) error {

View File

@@ -8,10 +8,11 @@ import (
"io"
"os"
"path/filepath"
"slices"
"strings"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print
@@ -37,12 +38,7 @@ func (self *Input) has_mime_matching(predicate func(string) bool) bool {
if predicate(self.mime_type) {
return true
}
for _, i := range self.extra_mime_types {
if predicate(i) {
return true
}
}
return false
return slices.ContainsFunc(self.extra_mime_types, predicate)
}
func write_loop(inputs []*Input, opts *Options) (err error) {
@@ -99,7 +95,7 @@ func write_loop(inputs []*Input, opts *Options) (err error) {
i := inputs[0]
n, err := i.src.Read(buf[:])
if n > 0 {
waiting_for_write = lp.QueueWriteString(encode_bytes(make_metadata("wdata", i.mime_type), buf[:n]))
waiting_for_write = lp.QueueWriteString(Encode_bytes(make_metadata("wdata", i.mime_type), buf[:n]))
}
if err != nil {
if errors.Is(err, io.EOF) {

View File

@@ -11,7 +11,7 @@ import (
"strings"
"unicode/utf8"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -9,7 +9,7 @@ import (
"strings"
"testing"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/google/go-cmp/cmp"
)

View File

@@ -11,8 +11,8 @@ import (
"strings"
"sync"
"kitty/tools/utils"
"kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"

View File

@@ -6,17 +6,18 @@ import (
"archive/tar"
"bytes"
"fmt"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"strings"
"kitty/kittens/ssh"
"kitty/tools/cli"
"kitty/tools/config"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/kittens/ssh"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print
@@ -36,16 +37,33 @@ var conf *Config
var opts *Options
var lp *loop.Loop
func isdir(path string) bool {
if s, err := os.Stat(path); err == nil {
return s.IsDir()
}
return false
}
var temp_files []string
func exists(path string) bool {
_, err := os.Stat(path)
return err == nil
func resolve_path(path string) (ans string, is_dir bool, err error) {
var s fs.FileInfo
if s, err = os.Stat(path); err != nil {
return
} else {
if s.Mode()&fs.ModeNamedPipe != 0 {
var src, dest *os.File
if src, err = os.Open(path); err != nil {
return
}
defer src.Close()
if dest, err = os.CreateTemp("", fmt.Sprintf("*-pipe-%s", filepath.Base(path))); err != nil {
return
}
defer dest.Close()
temp_files = append(temp_files, dest.Name())
if _, err = io.Copy(dest, src); err != nil {
return
}
return dest.Name(), false, nil
} else {
return path, s.IsDir(), nil
}
}
}
func get_ssh_file(hostname, rpath string) (string, error) {
@@ -133,15 +151,22 @@ func main(_ *cli.Command, opts_ *Options, args []string) (rc int, err error) {
if err != nil {
return 1, err
}
if isdir(left) != isdir(right) {
defer func() {
for _, path := range temp_files {
os.Remove(path)
}
}()
var left_is_dir, right_is_dir bool
if left, left_is_dir, err = resolve_path(left); err != nil {
return 1, err
}
if right, right_is_dir, err = resolve_path(right); err != nil {
return 1, err
}
if left_is_dir != right_is_dir {
return 1, fmt.Errorf("The items to be diffed should both be either directories or files. Comparing a directory to a file is not valid.'")
}
if !exists(left) {
return 1, fmt.Errorf("%s does not exist", left)
}
if !exists(right) {
return 1, fmt.Errorf("%s does not exist", right)
}
lp, err = loop.New()
loop.MouseTrackingMode(lp, loop.BUTTONS_AND_DRAG_MOUSE_TRACKING)
if err != nil {

View File

@@ -8,13 +8,13 @@ import (
"strings"
"sync"
"kitty"
"kitty/tools/config"
"kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -6,9 +6,9 @@ import (
"bytes"
"errors"
"fmt"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"os/exec"
"path/filepath"
"strconv"

View File

@@ -10,12 +10,12 @@ import (
"strconv"
"strings"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/tui/sgr"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/sgr"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -9,10 +9,10 @@ import (
"strings"
"sync"
"kitty/tools/tui"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -8,13 +8,13 @@ import (
"strconv"
"strings"
"kitty/tools/config"
"kitty/tools/tui"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -11,13 +11,13 @@ import (
"strings"
"unicode"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -19,10 +19,10 @@ import (
"github.com/dlclark/regexp2"
"github.com/seancfoley/ipaddress-go/ipaddr"
"kitty"
"kitty/tools/config"
"kitty/tools/tty"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -5,8 +5,8 @@ package hints
import (
"errors"
"fmt"
"kitty"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/utils"
"os"
"path/filepath"
"strconv"

View File

@@ -15,8 +15,8 @@ import (
"sync"
"unicode"
"kitty/tools/cli"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/utils"
"golang.org/x/sys/unix"
)

View File

@@ -4,7 +4,7 @@ package hyperlinked_grep
import (
"fmt"
"kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"testing"
"github.com/google/go-cmp/cmp"

View File

@@ -8,11 +8,11 @@ import (
"os"
"time"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/shm"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/shm"
)
var _ = fmt.Print

View File

@@ -5,8 +5,8 @@ package icat
import (
"fmt"
"kitty/tools/tui/graphics"
"kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/utils/images"
)
var _ = fmt.Print

View File

@@ -11,13 +11,13 @@ import (
"sync/atomic"
"time"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/tui/graphics"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/style"
"golang.org/x/sys/unix"
)

View File

@@ -4,13 +4,13 @@ package icat
import (
"fmt"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/shm"
"image"
"image/gif"
"kitty/tools/tty"
"kitty/tools/tui/graphics"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/shm"
"github.com/edwvee/exiffix"
"github.com/kovidgoyal/imaging"

View File

@@ -15,11 +15,11 @@ import (
"path/filepath"
"strings"
"kitty/tools/tty"
"kitty/tools/tui/graphics"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/shm"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/shm"
)
var _ = fmt.Print

View File

@@ -8,20 +8,20 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/kovidgoyal/kitty"
"io"
"kitty"
"math"
not_rand "math/rand/v2"
"os"
"path/filepath"
"strings"
"kitty/tools/tui"
"kitty/tools/tui/graphics"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/images"
"kitty/tools/utils/shm"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/graphics"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/images"
"github.com/kovidgoyal/kitty/tools/utils/shm"
)
var _ = fmt.Print

View File

@@ -12,10 +12,10 @@ import (
"strings"
"time"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -13,7 +13,7 @@ import (
"golang.org/x/sys/unix"
"kitty/tools/simdstring"
"github.com/kovidgoyal/kitty/tools/simdstring"
)
var _ = fmt.Print

View File

@@ -16,8 +16,8 @@ import (
"fmt"
"os"
"kitty/tools/cli"
"kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
)
var _ = fmt.Print

View File

@@ -7,8 +7,8 @@ import (
"runtime"
"strings"
"kitty/tools/cli"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/utils"
"golang.org/x/sys/unix"
)

View File

@@ -13,6 +13,7 @@ from kitty.constants import is_macos, kitten_exe
from kitty.fast_data_types import (
GLFW_EDGE_BOTTOM,
GLFW_EDGE_CENTER,
GLFW_EDGE_CENTER_SIZED,
GLFW_EDGE_LEFT,
GLFW_EDGE_NONE,
GLFW_EDGE_RIGHT,
@@ -66,7 +67,8 @@ def layer_shell_config(opts: PanelCLIOptions) -> LayerShellConfig:
}.get(opts.layer, GLFW_LAYER_SHELL_PANEL)
ltype = GLFW_LAYER_SHELL_BACKGROUND if opts.edge == 'background' else ltype
edge = {
'top': GLFW_EDGE_TOP, 'bottom': GLFW_EDGE_BOTTOM, 'left': GLFW_EDGE_LEFT, 'right': GLFW_EDGE_RIGHT, 'center': GLFW_EDGE_CENTER, 'none': GLFW_EDGE_NONE
'top': GLFW_EDGE_TOP, 'bottom': GLFW_EDGE_BOTTOM, 'left': GLFW_EDGE_LEFT, 'right': GLFW_EDGE_RIGHT,
'center': GLFW_EDGE_CENTER, 'none': GLFW_EDGE_NONE, 'center-sized': GLFW_EDGE_CENTER_SIZED,
}.get(opts.edge, GLFW_EDGE_TOP)
focus_policy = {
'not-allowed': GLFW_FOCUS_NOT_ALLOWED, 'exclusive': GLFW_FOCUS_EXCLUSIVE, 'on-demand': GLFW_FOCUS_ON_DEMAND

View File

@@ -3,14 +3,14 @@ package query_terminal
import (
"bytes"
"fmt"
"kitty"
"github.com/kovidgoyal/kitty"
"os"
"slices"
"strings"
"time"
"kitty/tools/cli"
"kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tui/loop"
)
var _ = fmt.Print

View File

@@ -6,9 +6,9 @@ import (
"path/filepath"
"runtime"
"kitty/kittens/panel"
"kitty/tools/cli"
"kitty/tools/config"
"github.com/kovidgoyal/kitty/kittens/panel"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/config"
"golang.org/x/sys/unix"
)
@@ -37,8 +37,8 @@ func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
return 1, err
}
argv := []string{kitty_exe, "+kitten", "panel", "--toggle-visibility", "--exclusive-zone=0", "--override-exclusive-zone", "--layer=overlay", "--single-instance"}
argv = append(argv, fmt.Sprintf("--lines=%d", conf.Lines))
argv = append(argv, fmt.Sprintf("--columns=%d", conf.Columns))
argv = append(argv, fmt.Sprintf("--lines=%s", conf.Lines))
argv = append(argv, fmt.Sprintf("--columns=%s", conf.Columns))
argv = append(argv, fmt.Sprintf("--edge=%s", conf.Edge))
if conf.Margin_top != 0 {
argv = append(argv, fmt.Sprintf("--margin-top=%d", conf.Margin_top))
@@ -67,6 +67,9 @@ func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
if runtime.GOOS != "darwin" {
argv = append(argv, fmt.Sprintf("--app-id=%s", conf.App_id))
}
if conf.Output_name != "" {
argv = append(argv, fmt.Sprintf("--output-name=%s", conf.Output_name))
}
argv = append(argv, fmt.Sprintf("--focus-policy=%s", conf.Focus_policy))
if conf.Start_as_hidden {
argv = append(argv, `--start-as-hidden`)

View File

@@ -19,13 +19,13 @@ opt = definition.add_option
agr('qat', 'Window appearance')
opt('lines', '25', option_type='positive_int',
opt('lines', '25',
long_text='''
The number of lines shown in the window, when the window is along the top or bottom edges of the screen.
If it has the suffix :code:`px` then it sets the height of the window in pixels instead of lines.
''',)
opt('columns', '80', option_type='positive_int',
opt('columns', '80',
long_text='''
The number of columns shown in the window, when the window is along the left or right edges of the screen.
If it has the suffix :code:`px` then it sets the width of the window in pixels instead of columns.
@@ -67,7 +67,16 @@ opt('+kitty_override', '', long_text='Override individual kitty configuration op
)
opt('app_id', f'{appname}-quick-access',
long_text='The Wayland APP_ID assigned to the quick access window (Linux only)')
long_text='On Wayland set the :italic:`namespace` of the layer shell surface.'
' On X11 set the WM_CLASS assigned to the quick access window. (Linux only)')
opt('output_name', '', long_text='''
The panel can only be displayed on a single monitor (output) at a time. This allows
you to specify which output is used, by name. If not specified the compositor will choose an
output automatically, typically the last output the user interacted with or the primary monitor.
You can get a list of available outputs by running: :code:`kitten panel --output-name list`.
''')
opt('start_as_hidden', 'no', option_type='to_bool',
long_text='Whether to start the quick access terminal hidden. Useful if you are starting it as part of system startup.')

View File

@@ -87,8 +87,8 @@ class KittenMetadata(NamedTuple):
def create_kitten_handler(kitten: str, orig_args: list[str]) -> KittenMetadata:
from kitty.constants import config_dir
kitten = resolved_kitten(kitten)
m = import_kitten_main_module(config_dir, kitten)
kitten = resolved_kitten(kitten)
main = m['start']
handle_result = m['end']
return KittenMetadata(
@@ -110,12 +110,13 @@ def set_debug(kitten: str) -> None:
def launch(args: list[str]) -> None:
config_dir, kitten = args[:2]
original_kitten_name = kitten
kitten = resolved_kitten(kitten)
del args[:2]
args = [kitten] + args
os.environ['KITTY_CONFIG_DIRECTORY'] = config_dir
set_debug(kitten)
m = import_kitten_main_module(config_dir, kitten)
m = import_kitten_main_module(config_dir, original_kitten_name)
try:
result = m['start'](args)
finally:
@@ -139,11 +140,14 @@ def run_kitten(kitten: str, run_name: str = '__main__') -> None:
if kitten in all_kitten_names():
runpy.run_module(f'kittens.{kitten}.main', run_name=run_name)
return
kitten = original_kitten_name
# Look for a custom kitten
if not kitten.endswith('.py'):
kitten += '.py'
from kitty.constants import config_dir
path = path_to_custom_kitten(config_dir, kitten)
if not os.path.exists(path):
path = path_to_custom_kitten(config_dir, resolved_kitten(kitten))
if not os.path.exists(path):
print('Available builtin kittens:', file=sys.stderr)
for kitten in all_kitten_names():

View File

@@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"kitty/tools/cli/markup"
"kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/tui/loop"
)
var _ = fmt.Print

View File

@@ -5,9 +5,9 @@ package show_key
import (
"errors"
"fmt"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/tty"
"io"
"kitty/tools/cli/markup"
"kitty/tools/tty"
"os"
"golang.org/x/sys/unix"

View File

@@ -5,7 +5,7 @@ package show_key
import (
"fmt"
"kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/cli"
)
var _ = fmt.Print

View File

@@ -9,9 +9,9 @@ import (
"strings"
"time"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/utils/shm"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/utils/shm"
)
var _ = fmt.Print

View File

@@ -13,10 +13,10 @@ import (
"strings"
"time"
"kitty/tools/config"
"kitty/tools/utils"
"kitty/tools/utils/paths"
"kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/paths"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"github.com/bmatcuk/doublestar/v4"
"golang.org/x/sys/unix"

View File

@@ -4,7 +4,7 @@ package ssh
import (
"fmt"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils"
"os"
"os/user"
"path/filepath"

View File

@@ -10,9 +10,9 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/kovidgoyal/kitty"
"io"
"io/fs"
"kitty"
"maps"
"net/url"
"os"
@@ -28,16 +28,16 @@ import (
"syscall"
"time"
"kitty/tools/cli"
"kitty/tools/themes"
"kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/tui/shell_integration"
"kitty/tools/utils"
"kitty/tools/utils/secrets"
"kitty/tools/utils/shlex"
"kitty/tools/utils/shm"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/themes"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/shell_integration"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/secrets"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/utils/shm"
"golang.org/x/sys/unix"
)

View File

@@ -6,9 +6,9 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/utils/shm"
"io/fs"
"kitty"
"kitty/tools/utils/shm"
"os"
"os/exec"
"path"

View File

@@ -11,9 +11,9 @@ import (
"strings"
"sync"
"kitty"
"kitty/tools/config"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -9,7 +9,7 @@ import (
"path/filepath"
"testing"
"kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"github.com/google/go-cmp/cmp"
)

View File

@@ -5,9 +5,9 @@ package themes
import (
"fmt"
"kitty/tools/themes"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/themes"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -11,10 +11,10 @@ import (
"strings"
"time"
"kitty/tools/cli"
"kitty/tools/themes"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/themes"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -4,20 +4,20 @@ package themes
import (
"fmt"
"github.com/kovidgoyal/kitty"
"io"
"kitty"
"maps"
"regexp"
"slices"
"strings"
"time"
"kitty/tools/config"
"kitty/tools/themes"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/themes"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -14,8 +14,8 @@ import (
"sync"
"time"
"kitty"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -9,8 +9,8 @@ import (
"strconv"
"strings"
"kitty/tools/cli"
"kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print

View File

@@ -16,15 +16,15 @@ import (
"strings"
"time"
"kitty"
"kitty/kittens/unicode_input"
"kitty/tools/cli/markup"
"kitty/tools/rsync"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/humanize"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/kittens/unicode_input"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/rsync"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/humanize"
"github.com/kovidgoyal/kitty/tools/wcswidth"
"golang.org/x/sys/unix"
)

View File

@@ -20,14 +20,14 @@ import (
"golang.org/x/exp/constraints"
"kitty"
"kitty/tools/cli/markup"
"kitty/tools/rsync"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/humanize"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty"
"github.com/kovidgoyal/kitty/tools/cli/markup"
"github.com/kovidgoyal/kitty/tools/rsync"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/humanize"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -10,9 +10,9 @@ import (
"path/filepath"
"strings"
"kitty/tools/crypto"
"kitty/tools/utils"
"kitty/tools/utils/humanize"
"github.com/kovidgoyal/kitty/tools/crypto"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/humanize"
)
var _ = fmt.Print

View File

@@ -16,15 +16,15 @@ import (
"unicode"
"unicode/utf8"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/unicode_names"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/cli"
"github.com/kovidgoyal/kitty/tools/tty"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/tui/readline"
"github.com/kovidgoyal/kitty/tools/unicode_names"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -8,10 +8,10 @@ import (
"strconv"
"strings"
"kitty/tools/unicode_names"
"kitty/tools/utils"
"kitty/tools/utils/style"
"kitty/tools/wcswidth"
"github.com/kovidgoyal/kitty/tools/unicode_names"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/style"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
var _ = fmt.Print

View File

@@ -85,6 +85,7 @@ from .fast_data_types import (
get_boss,
get_options,
get_os_window_size,
glfw_get_monitor_workarea,
global_font_size,
is_layer_shell_supported,
last_focused_os_window_id,
@@ -141,6 +142,7 @@ from .utils import (
platform_window_id,
safe_print,
sanitize_url_for_dispay_to_user,
shlex_split,
startup_notification_handler,
timed_debug_print,
which,
@@ -1357,7 +1359,17 @@ class Boss:
new_size = get_options().font_size
else:
if increment_operation:
new_size += (1 if increment_operation == '+' else -1) * amt
match increment_operation:
case '+':
new_size += amt
case '-':
new_size -= amt
case '*':
new_size *= amt
case '/':
new_size /= amt
case _:
pass # no-op
else:
new_size = amt
new_size = max(MINIMUM_FONT_SIZE, min(new_size, get_options().font_size * 5))
@@ -1831,9 +1843,14 @@ class Boss:
else:
self.mark_os_window_for_close(os_window_id, NO_CLOSE_REQUESTED)
def on_os_window_closed(self, os_window_id: int, viewport_width: int, viewport_height: int) -> None:
self.cached_values['window-size'] = viewport_width, viewport_height
def on_os_window_closed(self, os_window_id: int, x: int, y: int, viewport_width: int, viewport_height: int, is_layer_shell: bool) -> None:
tm = self.os_window_map.pop(os_window_id, None)
opts = get_options()
if not is_layer_shell:
if opts.remember_window_position and not is_wayland() and not self.os_window_map:
self.cached_values['window-pos'] = x, y
self.cached_values['monitor-workarea'] = glfw_get_monitor_workarea()
self.cached_values['window-size'] = viewport_width, viewport_height
if tm is not None:
tm.destroy()
for window_id in tuple(w.id for w in self.window_id_map.values() if getattr(w, 'os_window_id', None) == os_window_id):
@@ -2655,6 +2672,11 @@ class Boss:
def launch(self, *args: str) -> None:
from kitty.launch import launch, parse_launch_args
opts, args_ = parse_launch_args(args)
if args_ and ' ' in args_[0]:
# this can happen for example with map f1 launch $EDITOR when $EDITOR is not a single command
q = which(args_[0])
if not q or (q is args_[0] and not os.access(q, os.X_OK)):
args_[:1] = shlex_split(args_[0])
if self.window_for_dispatch:
opts.source_window = opts.source_window or f'id:{self.window_for_dispatch.id}'
opts.next_to = opts.next_to or f'id:{self.window_for_dispatch.id}'
@@ -2782,6 +2804,10 @@ class Boss:
self.update_check_process.kill()
self.update_check_process = process
def monitor_pid(self, pid: int, callback: Callable[[int, Exception | None], None]) -> None:
self.background_process_death_notify_map[pid] = callback
monitor_pid(pid)
def on_monitored_pid_death(self, pid: int, exit_status: int) -> None:
callback = self.background_process_death_notify_map.pop(pid, None)
if callback is not None:
@@ -3025,10 +3051,11 @@ class Boss:
self.choose_entry('Choose an OS window to move the tab to', items, chosen)
def set_background_image(self, path: str | None, os_windows: tuple[int, ...], configured: bool, layout: str | None, png_data: bytes = b'') -> None:
set_background_image(path, os_windows, configured, layout, png_data)
for os_window_id in os_windows:
self.default_bg_changed_for(os_window_id)
def set_background_image(
self, path: str | None, os_windows: tuple[int, ...], configured: bool, layout: str | None, png_data: bytes = b'',
linear_interpolation: bool | None = None, tint: float | None = None, tint_gaps: float | None = None
) -> None:
set_background_image(path, os_windows, configured, layout, png_data, linear_interpolation, tint, tint_gaps)
# Can be called with kitty -o "map f1 send_test_notification"
def send_test_notification(self) -> None:
@@ -3052,6 +3079,19 @@ class Boss:
def close_shared_ssh_connections(self) -> None:
cleanup_ssh_control_masters()
@ac('debug', '''Simulate a change in OS color scheme preference''')
def simulate_color_scheme_preference_change(self, which: str) -> None:
which = which.lower().replace('-', '_')
match which:
case 'light':
self.on_system_color_scheme_change('light', False)
case 'dark':
self.on_system_color_scheme_change('dark', False)
case 'no_preference':
self.on_system_color_scheme_change('no_preference', False)
case _:
self.show_error(_('Unknown color scheme type'), _('{} is not a valid color scheme type').format(which))
def launch_urls(self, *urls: str, no_replace_window: bool = False) -> None:
from .launch import force_window_launch
from .open_actions import actions_for_launch

View File

@@ -1114,8 +1114,11 @@ close_os_window(ChildMonitor *self, OSWindow *os_window) {
if (os_window->before_fullscreen.is_set && is_os_window_fullscreen(os_window)) {
w = os_window->before_fullscreen.w; h = os_window->before_fullscreen.h;
}
int x = 0, y = 0;
if (os_window->handle && !global_state.is_wayland) glfwGetWindowPos(os_window->handle, &x, &y);
bool is_layer_shell = os_window->is_layer_shell;
destroy_os_window(os_window);
call_boss(on_os_window_closed, "Kii", os_window->id, w, h);
call_boss(on_os_window_closed, "KiiiiO", os_window->id, x, y, w, h, is_layer_shell ? Py_True : Py_False);
for (size_t t=0; t < os_window->num_tabs; t++) {
Tab *tab = os_window->tabs + t;
for (size_t w = 0; w < tab->num_windows; w++) mark_child_for_close(self, tab->windows[w].id);

Some files were not shown because too many files have changed in this diff Show More