Merge branch 'panel-edge-center' of https://github.com/alex-huff/kitty
This commit is contained in:
commit
218fc01070
7 changed files with 29 additions and 17 deletions
2
glfw/glfw3.h
vendored
2
glfw/glfw3.h
vendored
|
|
@ -1302,7 +1302,7 @@ 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_NONE } GLFWEdge;
|
||||
typedef enum { GLFW_EDGE_TOP, GLFW_EDGE_BOTTOM, GLFW_EDGE_LEFT, GLFW_EDGE_RIGHT, GLFW_EDGE_CENTER, GLFW_EDGE_NONE } GLFWEdge;
|
||||
|
||||
typedef enum { GLFW_FOCUS_NOT_ALLOWED, GLFW_FOCUS_EXCLUSIVE, GLFW_FOCUS_ON_DEMAND} GLFWFocusPolicy;
|
||||
|
||||
|
|
|
|||
5
glfw/wl_window.c
vendored
5
glfw/wl_window.c
vendored
|
|
@ -1009,8 +1009,11 @@ layer_set_properties(_GLFWwindow *window) {
|
|||
panel_width = window->wl.width;
|
||||
if (!window->wl.layer_shell.config.override_exclusive_zone) exclusive_zone = window->wl.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_NONE:
|
||||
which_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; // None is anchored to "top left"
|
||||
which_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
|
||||
panel_width = window->wl.width;
|
||||
panel_height = window->wl.height;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
from kitty.constants import appname, is_macos, is_wayland
|
||||
from kitty.fast_data_types import (
|
||||
GLFW_EDGE_BOTTOM,
|
||||
GLFW_EDGE_CENTER,
|
||||
GLFW_EDGE_LEFT,
|
||||
GLFW_EDGE_NONE,
|
||||
GLFW_EDGE_RIGHT,
|
||||
|
|
@ -32,13 +33,13 @@
|
|||
--lines
|
||||
type=int
|
||||
default=1
|
||||
The number of lines shown in the panel. Ignored for background and vertical panels.
|
||||
The number of lines shown in the panel. Ignored for background, centered, and vertical panels.
|
||||
|
||||
|
||||
--columns
|
||||
type=int
|
||||
default=1
|
||||
The number of columns shown in the panel. Ignored for background and horizontal panels.
|
||||
The number of columns shown in the panel. Ignored for background, centered, and horizontal panels.
|
||||
|
||||
|
||||
--margin-top
|
||||
|
|
@ -70,7 +71,7 @@
|
|||
|
||||
|
||||
--edge
|
||||
choices=top,bottom,left,right,background,none
|
||||
choices=top,bottom,left,right,background,center,none
|
||||
default=top
|
||||
Which edge of the screen to place the panel on. Note that some window managers
|
||||
(such as i3) do not support placing docked windows on the left and right edges.
|
||||
|
|
@ -78,8 +79,10 @@
|
|||
is only supported on Wayland, not X11 and note that when using sway if you set
|
||||
a background in your sway config it will cover the background drawn using this
|
||||
kitten.
|
||||
The value :code:`none` anchors the panel to the top left corner by default
|
||||
and the panel should be placed using margins parameters, works only on Wayland.
|
||||
The value :code:`center` anchors the panel to all sides and covers the entire
|
||||
display by default. The panel can be shrinked using the margin parameters.
|
||||
The value :code:`none` anchors the panel to the top left corner and should be
|
||||
placed using the margin parameters, works only on Wayland.
|
||||
|
||||
|
||||
--layer
|
||||
|
|
@ -131,8 +134,8 @@
|
|||
default=-1
|
||||
On a Wayland compositor that supports the wlr layer shell protocol, request a given exclusive zone for the panel.
|
||||
Please refer to the wlr layer shell documentation for more details on the meaning of exclusive and its value.
|
||||
If :option:`--edge` is set to anything else than :code:`none`, this flag will not have any effect unless
|
||||
the flag :option:`--override-exclusive-zone` is also set.
|
||||
If :option:`--edge` is set to anything else than :code:`center` or :code:`none`, this flag will not have any
|
||||
effect unless the flag :option:`--override-exclusive-zone` is also set.
|
||||
If :option:`--edge` is set to :code:`background`, this option has no effect.
|
||||
|
||||
|
||||
|
|
@ -215,7 +218,7 @@ def initial_window_size(cell_width: int, cell_height: int, dpi_x: float, dpi_y:
|
|||
spacing = es('top') + es('bottom')
|
||||
window_height = int(cell_height * args.lines / yscale + (dpi_y / 72) * spacing + 1)
|
||||
window_width = monitor_width
|
||||
elif args.edge == 'background':
|
||||
elif args.edge in {'background', 'center'}:
|
||||
window_width, window_height = monitor_width, monitor_height
|
||||
else:
|
||||
spacing = es('left') + es('right')
|
||||
|
|
@ -233,7 +236,7 @@ def layer_shell_config(opts: PanelCLIOptions) -> LayerShellConfig:
|
|||
'overlay': GLFW_LAYER_SHELL_OVERLAY}.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, '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
|
||||
}.get(opts.edge, GLFW_EDGE_TOP)
|
||||
focus_policy = {
|
||||
'not-allowed': GLFW_FOCUS_NOT_ALLOWED, 'exclusive': GLFW_FOCUS_EXCLUSIVE, 'on-demand': GLFW_FOCUS_ON_DEMAND
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ GLFW_EDGE_TOP: int
|
|||
GLFW_EDGE_BOTTOM: int
|
||||
GLFW_EDGE_LEFT: int
|
||||
GLFW_EDGE_RIGHT: int
|
||||
GLFW_EDGE_CENTER: int
|
||||
GLFW_EDGE_NONE: int
|
||||
GLFW_FOCUS_NOT_ALLOWED: int
|
||||
GLFW_FOCUS_EXCLUSIVE: int
|
||||
|
|
|
|||
2
kitty/glfw-wrapper.h
generated
2
kitty/glfw-wrapper.h
generated
|
|
@ -1040,7 +1040,7 @@ 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_NONE } GLFWEdge;
|
||||
typedef enum { GLFW_EDGE_TOP, GLFW_EDGE_BOTTOM, GLFW_EDGE_LEFT, GLFW_EDGE_RIGHT, GLFW_EDGE_CENTER, GLFW_EDGE_NONE } GLFWEdge;
|
||||
|
||||
typedef enum { GLFW_FOCUS_NOT_ALLOWED, GLFW_FOCUS_EXCLUSIVE, GLFW_FOCUS_ON_DEMAND} GLFWFocusPolicy;
|
||||
|
||||
|
|
|
|||
13
kitty/glfw.c
13
kitty/glfw.c
|
|
@ -1041,7 +1041,9 @@ edge_spacing(GLFWEdge which) {
|
|||
case GLFW_EDGE_BOTTOM: edge = "bottom"; break;
|
||||
case GLFW_EDGE_LEFT: edge = "left"; break;
|
||||
case GLFW_EDGE_RIGHT: edge = "right"; break;
|
||||
case GLFW_EDGE_NONE: edge = "left"; break; // GLFW_EDGE_NONE is considered as "top left"
|
||||
case GLFW_EDGE_CENTER:
|
||||
case GLFW_EDGE_NONE:
|
||||
return 0;
|
||||
}
|
||||
if (!edge_spacing_func) {
|
||||
log_error("Attempt to call edge_spacing() without first setting edge_spacing_func");
|
||||
|
|
@ -1080,11 +1082,14 @@ calculate_layer_shell_window_size(
|
|||
spacing *= ydpi / 72.;
|
||||
spacing += (fonts_data->fcm.cell_height * config->y_size_in_cells) / yscale;
|
||||
*height = (uint32_t)(1. + spacing);
|
||||
} else if (config->edge == GLFW_EDGE_CENTER) {
|
||||
if (!*width) *width = monitor_width;
|
||||
if (!*height) *height = monitor_height;
|
||||
} else {
|
||||
double spacing_x = edge_spacing(GLFW_EDGE_LEFT);
|
||||
double spacing_x = edge_spacing(GLFW_EDGE_LEFT) + edge_spacing(GLFW_EDGE_RIGHT);
|
||||
spacing_x *= xdpi / 72.;
|
||||
spacing_x += (fonts_data->fcm.cell_width * config->x_size_in_cells) / xscale;
|
||||
double spacing_y = edge_spacing(GLFW_EDGE_TOP);
|
||||
double spacing_y = edge_spacing(GLFW_EDGE_TOP) + edge_spacing(GLFW_EDGE_BOTTOM);
|
||||
spacing_y *= ydpi / 72.;
|
||||
spacing_y += (fonts_data->fcm.cell_height * config->y_size_in_cells) / yscale;
|
||||
*width = (uint32_t)(1. + spacing_x);
|
||||
|
|
@ -2382,7 +2387,7 @@ init_glfw(PyObject *m) {
|
|||
ADDC(GLFW_PRIMARY_SELECTION); ADDC(GLFW_CLIPBOARD);
|
||||
ADDC(GLFW_LAYER_SHELL_NONE); ADDC(GLFW_LAYER_SHELL_PANEL); ADDC(GLFW_LAYER_SHELL_BACKGROUND); ADDC(GLFW_LAYER_SHELL_TOP); ADDC(GLFW_LAYER_SHELL_OVERLAY);
|
||||
ADDC(GLFW_FOCUS_NOT_ALLOWED); ADDC(GLFW_FOCUS_EXCLUSIVE); ADDC(GLFW_FOCUS_ON_DEMAND);
|
||||
ADDC(GLFW_EDGE_TOP); ADDC(GLFW_EDGE_BOTTOM); ADDC(GLFW_EDGE_LEFT); ADDC(GLFW_EDGE_RIGHT); ADDC(GLFW_EDGE_NONE)
|
||||
ADDC(GLFW_EDGE_TOP); ADDC(GLFW_EDGE_BOTTOM); ADDC(GLFW_EDGE_LEFT); ADDC(GLFW_EDGE_RIGHT); ADDC(GLFW_EDGE_CENTER); ADDC(GLFW_EDGE_NONE);
|
||||
ADDC(GLFW_COLOR_SCHEME_NO_PREFERENCE); ADDC(GLFW_COLOR_SCHEME_DARK); ADDC(GLFW_COLOR_SCHEME_LIGHT);
|
||||
|
||||
/* start glfw functional keys (auto generated by gen-key-constants.py do not edit) */
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ def sanitize_window_size(x: Any) -> int:
|
|||
return max(20, min(ans, 50000))
|
||||
|
||||
|
||||
def edge_spacing(which: EdgeLiteral, opts:WindowSizeData | Options | None = None) -> float:
|
||||
def edge_spacing(which: EdgeLiteral, opts: WindowSizeData | Options | None = None) -> float:
|
||||
if opts is None:
|
||||
opts = get_options()
|
||||
margin: float = getattr(opts.single_window_margin_width, which)
|
||||
|
|
|
|||
Loading…
Reference in a new issue