Codebergdnkl

foot

master
ply5 git calls28 ms32 KiB3 cachedprotocol v2
570 lines14 KiBRaw
1#pragma once
3#include <stdint.h>
4#include <stdbool.h>
5#include <time.h>
6#include <uchar.h>
8#include <wayland-client.h>
9#include <xkbcommon/xkbcommon.h>
11/* Wayland protocols */
12#include <color-management-v1.h>
13#include <fractional-scale-v1.h>
14#include <presentation-time.h>
15#include <primary-selection-unstable-v1.h>
16#include <single-pixel-buffer-v1.h>
17#include <text-input-unstable-v3.h>
18#include <viewporter.h>
19#include <xdg-activation-v1.h>
20#include <xdg-decoration-unstable-v1.h>
21#include <xdg-output-unstable-v1.h>
22#include <xdg-shell.h>
23#include <xdg-system-bell-v1.h>
24#include <xdg-toplevel-icon-v1.h>
26#if defined(HAVE_XDG_TOPLEVEL_TAG)
27 #include <xdg-toplevel-tag-v1.h>
28#endif
29#if defined(HAVE_EXT_BACKGROUND_EFFECT)
30 #include <ext-background-effect-v1.h>
31#endif
33#include <fcft/fcft.h>
34#include <tllist.h>
36#include "config.h"
37#include "cursor-shape.h"
38#include "fdm.h"
40/* Forward declarations */
41struct terminal;
42struct buffer;
44/* Mime-types we support when dealing with data offers (e.g. copy-paste, or DnD) */
45enum data_offer_mime_type {
46 DATA_OFFER_MIME_UNSET,
47 DATA_OFFER_MIME_TEXT_PLAIN,
48 DATA_OFFER_MIME_TEXT_UTF8,
49 DATA_OFFER_MIME_URI_LIST,
51 DATA_OFFER_MIME_TEXT_TEXT,
52 DATA_OFFER_MIME_TEXT_STRING,
53 DATA_OFFER_MIME_TEXT_UTF8_STRING,
54};
56enum touch_state {
57 TOUCH_STATE_INHIBITED = -1,
58 TOUCH_STATE_IDLE,
59 TOUCH_STATE_HELD,
60 TOUCH_STATE_DRAGGING,
61 TOUCH_STATE_SCROLLING,
62};
64struct wayl_surface {
65 struct wl_surface *surf;
66 struct wp_viewport *viewport;
67 struct wp_color_management_surface_v1 *color_management;
69#if defined(HAVE_EXT_BACKGROUND_EFFECT)
70 struct ext_background_effect_surface_v1 *background_effect;
71#endif
72};
74struct wayl_sub_surface {
75 struct wayl_surface surface;
76 struct wl_subsurface *sub;
77};
79struct wl_window;
80struct wl_clipboard {
81 struct wl_window *window; /* For DnD */
82 struct wl_data_source *data_source;
83 struct wl_data_offer *data_offer;
84 enum data_offer_mime_type mime_type;
85 char *text;
86 uint32_t serial;
87};
89struct wl_primary {
90 struct zwp_primary_selection_source_v1 *data_source;
91 struct zwp_primary_selection_offer_v1 *data_offer;
92 enum data_offer_mime_type mime_type;
93 char *text;
94 uint32_t serial;
95};
97/* Maps a mouse button to its "owning" surface */
98struct button_tracker {
99 int button;
100 int surf_kind; /* TODO: this is really an "enum term_surface" */
101 bool send_to_client; /* Only valid when surface is the main grid surface */
102};
104struct rect {
105 int x;
106 int y;
107 int width;
108 int height;
109};
111struct seat {
112 struct wayland *wayl;
113 struct wl_seat *wl_seat;
114 uint32_t wl_name;
115 char *name;
117 /* Focused terminals */
118 struct terminal *kbd_focus;
119 struct terminal *mouse_focus;
120 struct terminal *ime_focus;
122 /* Keyboard state */
123 struct wl_keyboard *wl_keyboard;
124 struct {
125 uint32_t serial;
127 struct xkb_context *xkb;
128 struct xkb_keymap *xkb_keymap;
129 struct xkb_state *xkb_state;
130 struct xkb_compose_table *xkb_compose_table;
131 struct xkb_compose_state *xkb_compose_state;
132 struct {
133 int fd;
135 bool dont_re_repeat;
136 int32_t delay;
137 int32_t rate;
138 uint32_t key;
139 } repeat;
141 xkb_mod_index_t mod_shift;
142 xkb_mod_index_t mod_alt;
143 xkb_mod_index_t mod_ctrl;
144 xkb_mod_index_t mod_super;
145 xkb_mod_index_t mod_caps;
146 xkb_mod_index_t mod_num;
148 xkb_mod_mask_t legacy_significant; /* Significant modifiers for the legacy keyboard protocol */
149 xkb_mod_mask_t kitty_significant; /* Significant modifiers for the kitty keyboard protocol */
151 xkb_mod_mask_t virtual_modifiers; /* Set of modifiers to completely ignore */
153 xkb_keycode_t key_arrow_up;
154 xkb_keycode_t key_arrow_down;
156 /* Enabled modifiers */
157 bool shift;
158 bool alt;
159 bool ctrl;
160 bool super;
162 xkb_keysym_t last_shortcut_sym;
163 } kbd;
165 /* Pointer state */
166 struct wl_pointer *wl_pointer;
167 struct {
168 uint32_t serial;
170 /* Client-side cursor */
171 struct wayl_surface surface;
172 struct wl_cursor_theme *theme;
173 struct wl_cursor *cursor;
175 /* Server-side cursor */
176 struct wp_cursor_shape_device_v1 *shape_device;
178 float scale;
179 bool hidden;
180 enum cursor_shape shape;
181 char *last_custom_xcursor;
183 struct wl_callback *xcursor_callback;
184 bool xcursor_pending;
185 } pointer;
187 /* Touch state */
188 struct wl_touch *wl_touch;
189 struct {
190 enum touch_state state;
192 uint32_t serial;
193 uint32_t time;
194 struct wl_surface *surface;
195 int surface_kind;
196 int32_t id;
197 } touch;
199 struct {
200 int x;
201 int y;
202 int col;
203 int row;
205 /* Mouse buttons currently being pressed, and their "owning" surfaces */
206 tll(struct button_tracker) buttons;
208 /* Double- and triple click state */
209 int count;
210 int last_released_button;
211 struct timespec last_time;
213 /* We used a discrete axis event in the current pointer frame */
214 double aggregated[2];
215 double aggregated_120[2];
216 bool have_discrete;
217 } mouse;
219 /* Clipboard */
220 struct wl_data_device *data_device;
221 struct zwp_primary_selection_device_v1 *primary_selection_device;
223 struct wl_clipboard clipboard;
224 struct wl_primary primary;
226#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
227 /* Input Method Editor */
228 struct zwp_text_input_v3 *wl_text_input;
229 struct {
230 struct {
231 struct rect pending;
232 struct rect sent;
233 } cursor_rect;
235 struct {
236 struct {
237 char *text;
238 int32_t cursor_begin;
239 int32_t cursor_end;
240 } pending;
242 char32_t *text;
243 struct cell *cells;
244 int count;
245 struct {
246 bool hidden;
247 int start; /* Cell index, inclusive */
248 int end; /* Cell index, exclusive */
249 } cursor;
250 } preedit;
252 struct {
253 struct {
254 char *text;
255 } pending;
256 } commit;
258 struct {
259 struct {
260 uint32_t before_length;
261 uint32_t after_length;
262 } pending;
263 } surrounding;
265 uint32_t serial;
266 } ime;
267#endif
268};
270enum csd_surface {
271 CSD_SURF_TITLE,
272 CSD_SURF_LEFT,
273 CSD_SURF_RIGHT,
274 CSD_SURF_TOP,
275 CSD_SURF_BOTTOM,
276 CSD_SURF_MINIMIZE,
277 CSD_SURF_MAXIMIZE,
278 CSD_SURF_CLOSE,
279 CSD_SURF_COUNT,
280};
282struct monitor {
283 struct wayland *wayl;
284 struct wl_output *output;
285 struct zxdg_output_v1 *xdg;
286 uint32_t wl_name;
288 int x;
289 int y;
291 struct {
292 /* Physical size, in mm */
293 struct {
294 int width;
295 int height;
296 } mm;
298 /* Physical size, in pixels */
299 struct {
300 int width;
301 int height;
302 } px_real;
304 /* Scaled size, in pixels */
305 struct {
306 int width;
307 int height;
308 } px_scaled;
309 } dim;
311 struct {
312 /* PPI, based on physical size */
313 struct {
314 int x;
315 int y;
316 } real;
318 /* PPI, logical, based on scaled size */
319 struct {
320 int x;
321 int y;
322 } scaled;
323 } ppi;
325 struct {
326 float scaled;
327 float physical;
328 } dpi;
330 int scale;
331 float refresh;
332 enum wl_output_subpixel subpixel;
333 enum wl_output_transform transform;
335 /* From wl_output */
336 char *make;
337 char *model;
339 /* From xdg_output */
340 char *name;
341 char *description;
343 float inch; /* e.g. 24" */
345 bool use_output_release;
346};
348struct wl_url {
349 const struct url *url;
350 struct wayl_sub_surface surf;
351};
353enum csd_mode {CSD_UNKNOWN, CSD_NO, CSD_YES};
355typedef void (*activation_token_cb_t)(const char *token, void *data);
357/*
358 * This context holds data used both in the token::done callback, and
359 * when cleaning up created, by not-yet-done tokens in
360 * wayl_win_destroy().
361 */
362struct xdg_activation_token_context {
363 struct wl_window *win; /* Need for win->xdg_tokens */
364 struct xdg_activation_token_v1 *xdg_token; /* Used to match token in done() */
365 activation_token_cb_t cb; /* User provided callback */
366 void *cb_data; /* Callback user pointer */
367};
369struct wayland;
370struct wl_window {
371 struct terminal *term;
372 struct wayl_surface surface;
373 struct xdg_surface *xdg_surface;
374 struct xdg_toplevel *xdg_toplevel;
375 struct wp_fractional_scale_v1 *fractional_scale;
377 tll(struct xdg_activation_token_context *) xdg_tokens;
378 bool urgency_token_is_pending;
380 bool unmapped;
381 float scale;
382 int preferred_buffer_scale;
384 struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
386 enum csd_mode csd_mode;
388 struct {
389 struct wayl_sub_surface surface[CSD_SURF_COUNT];
390 struct fcft_font *font;
391 int move_timeout_fd;
392 uint32_t serial;
393 } csd;
395 struct {
396 bool maximize:1;
397 bool minimize:1;
398 } wm_capabilities;
400 struct wayl_sub_surface search;
401 struct wayl_sub_surface scrollback_indicator;
402 struct wayl_sub_surface render_timer;
403 struct wayl_sub_surface overlay;
405 struct wl_callback *frame_callback;
407 tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
408 tll(struct wl_url) urls;
410 bool is_configured;
411 bool is_fullscreen;
412 bool is_maximized;
413 bool is_resizing;
414 bool is_suspended;
415 bool is_tiled_top;
416 bool is_tiled_bottom;
417 bool is_tiled_left;
418 bool is_tiled_right;
419 bool is_tiled; /* At least one of is_tiled_{top,bottom,left,right} is true */
421 bool is_constrained_top;
422 bool is_constrained_bottom;
423 bool is_constrained_left;
424 bool is_constrained_right;
426 struct {
427 int width;
428 int height;
429 bool is_activated:1;
430 bool is_suspended:1;
431 bool is_fullscreen:1;
432 bool is_maximized:1;
433 bool is_resizing:1;
435 bool is_tiled_top:1;
436 bool is_tiled_bottom:1;
437 bool is_tiled_left:1;
438 bool is_tiled_right:1;
440 bool is_constrained_top:1;
441 bool is_constrained_bottom:1;
442 bool is_constrained_left:1;
443 bool is_constrained_right:1;
445 enum csd_mode csd_mode;
446 } configure;
448 int resize_timeout_fd;
449};
451struct terminal;
452struct wayland {
453 struct fdm *fdm;
454 struct key_binding_manager *key_binding_manager;
456 int fd;
458 struct wl_display *display;
459 struct wl_registry *registry;
460#if defined(WL_FIXES_INTERFACE)
461 struct wl_fixes *fixes;
462 int fixes_version;
463#endif
464 struct wl_compositor *compositor;
465 struct wl_subcompositor *sub_compositor;
466 struct wl_shm *shm;
468 struct zxdg_output_manager_v1 *xdg_output_manager;
470 struct xdg_wm_base *shell;
471 struct zxdg_decoration_manager_v1 *xdg_decoration_manager;
473 struct wl_data_device_manager *data_device_manager;
474 struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager;
476 struct xdg_activation_v1 *xdg_activation;
478 struct wp_viewporter *viewporter;
479 struct wp_fractional_scale_manager_v1 *fractional_scale_manager;
481 struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
482 int shape_manager_version;
484 struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;
486 struct xdg_toplevel_icon_manager_v1 *toplevel_icon_manager;
488 struct xdg_system_bell_v1 *system_bell;
490 struct {
491 struct wp_color_manager_v1 *manager;
492 struct wp_image_description_v1 *img_description;
493 bool have_intent_perceptual;
494 bool have_feat_parametric;
495 bool have_tf_ext_linear;
496 bool have_primaries_srgb;
497 } color_management;
499 bool presentation_timings;
500 struct wp_presentation *presentation;
501 uint32_t presentation_clock_id;
503#if defined(HAVE_XDG_TOPLEVEL_TAG)
504 struct xdg_toplevel_tag_manager_v1 *toplevel_tag_manager;
505#endif
506#if defined(HAVE_EXT_BACKGROUND_EFFECT)
507 struct ext_background_effect_manager_v1 *background_effect_manager;
508 bool have_background_blur;
509#endif
511#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
512 struct zwp_text_input_manager_v3 *text_input_manager;
513#endif
515 tll(struct monitor) monitors; /* All available outputs */
516 tll(struct seat) seats;
518 tll(struct terminal *) terms;
520 /* WL_SHM >= 2 */
521 bool use_shm_release;
523 bool shm_have_argb2101010:1;
524 bool shm_have_abgr2101010:1;
525 bool shm_have_abgr161616:1;
526};
528struct wayland *wayl_init(
529 struct fdm *fdm, struct key_binding_manager *key_binding_manager,
530 bool presentation_timings);
531void wayl_destroy(struct wayland *wayl);
533bool wayl_reload_xcursor_theme(struct seat *seat, float new_scale);
535void wayl_flush(struct wayland *wayl);
536void wayl_roundtrip(struct wayland *wayl);
538bool wayl_fractional_scaling(const struct wayland *wayl);
539void wayl_surface_scale(
540 const struct wl_window *win, const struct wayl_surface *surf,
541 const struct buffer *buf, float scale);
542void wayl_surface_scale_explicit_width_height(
543 const struct wl_window *win, const struct wayl_surface *surf,
544 int width, int height, float scale);
546struct wl_window *wayl_win_init(struct terminal *term, const char *token);
547void wayl_win_destroy(struct wl_window *win);
549void wayl_win_scale(struct wl_window *win, const struct buffer *buf);
550void wayl_win_alpha_changed(struct wl_window *win);
551bool wayl_win_set_urgent(struct wl_window *win);
552bool wayl_win_ring_bell(const struct wl_window *win);
554bool wayl_win_csd_titlebar_visible(const struct wl_window *win);
555bool wayl_win_csd_borders_visible(const struct wl_window *win);
557bool wayl_win_subsurface_new(
558 struct wl_window *win, struct wayl_sub_surface *surf,
559 bool allow_pointer_input);
560bool wayl_win_subsurface_new_with_custom_parent(
561 struct wl_window *win, struct wl_surface *parent,
562 struct wayl_sub_surface *surf, bool allow_pointer_input);
563void wayl_win_subsurface_destroy(struct wayl_sub_surface *surf);
565bool wayl_get_activation_token(
566 struct wayland *wayl, struct seat *seat, uint32_t serial,
567 struct wl_window *win, activation_token_cb_t cb, void *cb_data);
568void wayl_activate(struct wayland *wayl, struct wl_window *win, const char *token);
570bool wayl_do_linear_blending(const struct wayland *wayl, const struct config *conf);
Diagnostics5 git calls · 28 ms
CallStatusSizeTime028 ms
discover200178 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=178
git.server.agent=git/2.56.1-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=178
git.pkt.payload.max=35
ls-refs20010 KiB2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=10322
git.response.cache=UPDATING
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=108
git.pkt.data=107
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=10322
git.pkt.payload.max=106
git.ls_refs.count=107
git.ls_refs.head=refs/heads/master
fetchcombine:blob:none+tree:2 · deepen 12008.6 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=8830
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=8830
git.pkt.payload.max=8730
git.sideband.band1.bytes=8730
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=14
git.pack.bytes=8730
git.fetch.wide.objects=14
git.fetch.wide.extra_bytes=9909
git.fetch.wide.blobs=0
fetchtree:0 · deepen 102009.3 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=23
git.response.bytes=9489
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=9489
git.pkt.payload.max=9389
git.sideband.band1.bytes=9389
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=10
git.pack.bytes=9389
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=de930681b6073ba5b599a0f956bfbd114762ad5a
git.pack.full=10
Open pack map
fetch2003.9 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3978
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=11a383685927c5d0e7377e4e7b2deebf92ae9e48
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3978
git.pkt.payload.max=3951
git.sideband.band1.bytes=3951
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://codeberg.org/dnkl/foot
Ref
refs/heads/master
Commit
c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
cf-ray
a5e2f707598c3a24
Request
7ed06e73…
Protocol
v2 · sha1
Agent
git/2.56.1-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format