|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net> |
3 | 3 |
|
4 | | -from typing import TYPE_CHECKING, Any |
5 | | - |
6 | | -from kitty.fast_data_types import ( |
7 | | - GLFW_FOCUS_ON_DEMAND, |
8 | | - GLFW_LAYER_SHELL_BACKGROUND, |
9 | | -) |
10 | | -from kitty.types import LayerShellConfig |
| 4 | +from typing import TYPE_CHECKING |
11 | 5 |
|
12 | 6 | from .base import ( |
13 | 7 | MATCH_WINDOW_OPTION, |
@@ -124,41 +118,23 @@ def response_from_kitty(self, boss: Boss, window: Window | None, payload_get: Pa |
124 | 118 | f'The OS Window {os_window_id} is not a panel you should not use the --action=resize option to resize it') |
125 | 119 | if not panels: |
126 | 120 | raise RemoteControlErrorWithoutTraceback('Must specify at least one panel setting') |
127 | | - from kitty.launch import layer_shell_config_from_panel_opts |
128 | | - seen_options: dict[str, Any] = {} |
129 | | - try: |
130 | | - lsc = layer_shell_config_from_panel_opts(panels, track_seen_options=seen_options) |
131 | | - except Exception as e: |
132 | | - raise RemoteControlErrorWithoutTraceback( |
133 | | - f'Invalid panel options specified: {e}') |
134 | 121 | if payload_get('incremental'): |
135 | | - cli_option_to_lsc_configs_map = { |
136 | | - 'lines': ('y_size_in_cells', 'y_size_in_pixels'), |
137 | | - 'columns': ('x_size_in_cells', 'x_size_in_pixels'), |
138 | | - 'margin_top': ('requested_top_margin',), |
139 | | - 'margin_left': ('requested_left_margin',), |
140 | | - 'margin_bottom': ('requested_bottom_margin',), |
141 | | - 'margin_right': ('requested_right_margin',), |
142 | | - 'edge': ('edge',), |
143 | | - 'layer': ('type',), |
144 | | - 'output_name': ('output_name',), |
145 | | - 'focus_policy': ('focus_policy',), |
146 | | - 'exclusive_zone': ('requested_exclusive_zone',), |
147 | | - 'override_exclusive_zone': ('override_exclusive_zone',), |
148 | | - 'hide_on_focus_loss': ('hide_on_focus_loss',) |
149 | | - } |
150 | 122 | existing = layer_shell_config_for_os_window(os_window_id) |
151 | 123 | if existing is None: |
152 | 124 | raise RemoteControlErrorWithoutTraceback( |
153 | 125 | f'The OS Window {os_window_id} has no panel configuration') |
154 | | - for option in seen_options: |
155 | | - for config in cli_option_to_lsc_configs_map[option]: |
156 | | - existing[config] = getattr(lsc, config) |
157 | | - if seen_options.get('edge') == 'background': |
158 | | - existing['type'] = GLFW_LAYER_SHELL_BACKGROUND |
159 | | - if existing['hide_on_focus_loss']: |
160 | | - existing['focus_policy'] = GLFW_FOCUS_ON_DEMAND |
161 | | - lsc = LayerShellConfig(**existing) |
| 126 | + from kittens.panel.main import incrementally_update_layer_shell_config |
| 127 | + try: |
| 128 | + lsc = incrementally_update_layer_shell_config(existing, panels) |
| 129 | + except Exception as e: |
| 130 | + raise RemoteControlErrorWithoutTraceback(str(e)) |
| 131 | + else: |
| 132 | + from kitty.launch import layer_shell_config_from_panel_opts |
| 133 | + try: |
| 134 | + lsc = layer_shell_config_from_panel_opts(panels) |
| 135 | + except Exception as e: |
| 136 | + raise RemoteControlErrorWithoutTraceback( |
| 137 | + f'Invalid panel options specified: {e}') |
162 | 138 | if not set_layer_shell_config(os_window_id, lsc): |
163 | 139 | raise RemoteControlErrorWithoutTraceback(f'Failed to change panel configuration for OS Window {os_window_id}') |
164 | 140 | elif ac == 'toggle-visibility': |
|
0 commit comments