mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-03 13:13:35 +02:00
The OS Window regions should have right/bottom edges not inclusive
Currently it was a bit ambiguous some places assuming inclusive some not. Also there seemed to be one left over pixel at the bottom/right edges of the calculated regions compared to viewport size.This fixes that. Hopefully doesnt break anything else, we will see.
This commit is contained in:
@@ -196,6 +196,7 @@ typedef struct ImageAnchorPosition {
|
||||
typedef enum UTF8State { UTF8_ACCEPT = 0, UTF8_REJECT = 1} UTF8State;
|
||||
|
||||
typedef struct {
|
||||
// right = left + width, bottom = top + height
|
||||
uint32_t left, top, right, bottom;
|
||||
} Region;
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ window_bottom(Window *w) {
|
||||
static bool
|
||||
contains_mouse(Window *w) {
|
||||
double x = global_state.callback_os_window->mouse_x, y = global_state.callback_os_window->mouse_y;
|
||||
return (w->visible && window_left(w) <= x && x <= window_right(w) && window_top(w) <= y && y <= window_bottom(w));
|
||||
return (w->visible && window_left(w) <= x && x < window_right(w) && window_top(w) <= y && y < window_bottom(w));
|
||||
}
|
||||
|
||||
static double
|
||||
@@ -645,8 +645,8 @@ handle_tab_bar_mouse(int button, int modifiers, int action) {
|
||||
static bool
|
||||
mouse_in_region(Region *r) {
|
||||
if (r->left == r->right) return false;
|
||||
if (global_state.callback_os_window->mouse_y < r->top || global_state.callback_os_window->mouse_y > r->bottom) return false;
|
||||
if (global_state.callback_os_window->mouse_x < r->left || global_state.callback_os_window->mouse_x > r->right) return false;
|
||||
if (global_state.callback_os_window->mouse_y < r->top || global_state.callback_os_window->mouse_y >= r->bottom) return false;
|
||||
if (global_state.callback_os_window->mouse_x < r->left || global_state.callback_os_window->mouse_x >= r->right) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ window_for_event(unsigned int *window_idx, bool *in_tab_bar) {
|
||||
const OSWindow* w = global_state.callback_os_window;
|
||||
if (!in_central) {
|
||||
if (
|
||||
(tab_bar.top < central.top && w->mouse_y <= central.top) ||
|
||||
(tab_bar.top < central.top && w->mouse_y < central.top) ||
|
||||
(tab_bar.bottom > central.bottom && w->mouse_y >= central.bottom)
|
||||
) *in_tab_bar = true;
|
||||
}
|
||||
|
||||
@@ -595,27 +595,28 @@ os_window_regions(OSWindow *os_window, Region *central, Region *tab_bar) {
|
||||
if (!OPT(tab_bar_hidden) && os_window->num_tabs >= OPT(tab_bar_min_tabs)) {
|
||||
long margin_outer = pt_to_px_for_os_window(OPT(tab_bar_margin_height.outer), os_window);
|
||||
long margin_inner = pt_to_px_for_os_window(OPT(tab_bar_margin_height.inner), os_window);
|
||||
central->left = 0; central->right = os_window->viewport_width;
|
||||
unsigned tab_bar_height = os_window->fonts_data->fcm.cell_height + margin_inner + margin_outer;
|
||||
switch(OPT(tab_bar_edge)) {
|
||||
case TOP_EDGE:
|
||||
central->left = 0; central->right = os_window->viewport_width - 1;
|
||||
central->top = os_window->fonts_data->fcm.cell_height + margin_inner + margin_outer - 1;
|
||||
central->bottom = os_window->viewport_height - 1;
|
||||
central->top = tab_bar_height;
|
||||
central->bottom = os_window->viewport_height;
|
||||
central->top = MIN(central->top, central->bottom);
|
||||
tab_bar->top = margin_outer;
|
||||
break;
|
||||
default:
|
||||
central->left = 0; central->top = 0; central->right = os_window->viewport_width - 1;
|
||||
long bottom = os_window->viewport_height - os_window->fonts_data->fcm.cell_height - 1 - margin_inner - margin_outer;
|
||||
central->top = 0;
|
||||
long bottom = os_window->viewport_height - tab_bar_height;
|
||||
central->bottom = MAX(0, bottom);
|
||||
tab_bar->top = central->bottom + 1 + margin_inner;
|
||||
break;
|
||||
}
|
||||
tab_bar->left = central->left; tab_bar->right = central->right;
|
||||
tab_bar->bottom = tab_bar->top + os_window->fonts_data->fcm.cell_height - 1;
|
||||
tab_bar->bottom = tab_bar->top + tab_bar_height;
|
||||
} else {
|
||||
zero_at_ptr(tab_bar);
|
||||
central->left = 0; central->top = 0; central->right = os_window->viewport_width - 1;
|
||||
central->bottom = os_window->viewport_height - 1;
|
||||
central->left = 0; central->top = 0; central->right = os_window->viewport_width;
|
||||
central->bottom = os_window->viewport_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user