mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-10 05:33:51 -04:00
Merge branch 'window-menu'
This commit is contained in:
commit
90cfdcf1a5
5 changed files with 67 additions and 22 deletions
26
input.c
26
input.c
|
|
@ -1725,7 +1725,7 @@ is_bottom_right(const struct terminal *term, int x, int y)
|
||||||
(term->active_surface == TERM_SURF_BORDER_BOTTOM && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale)));
|
(term->active_surface == TERM_SURF_BORDER_BOTTOM && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
const char *
|
||||||
xcursor_for_csd_border(struct terminal *term, int x, int y)
|
xcursor_for_csd_border(struct terminal *term, int x, int y)
|
||||||
{
|
{
|
||||||
if (is_top_left(term, x, y)) return XCURSOR_TOP_LEFT_CORNER;
|
if (is_top_left(term, x, y)) return XCURSOR_TOP_LEFT_CORNER;
|
||||||
|
|
@ -1758,11 +1758,18 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
struct wl_window *win = wl_surface_get_user_data(surface);
|
struct wl_window *win = wl_surface_get_user_data(surface);
|
||||||
struct terminal *term = win->term;
|
struct terminal *term = win->term;
|
||||||
|
|
||||||
|
int x = wl_fixed_to_int(surface_x) * term->scale;
|
||||||
|
int y = wl_fixed_to_int(surface_y) * term->scale;
|
||||||
|
|
||||||
seat->pointer.serial = serial;
|
seat->pointer.serial = serial;
|
||||||
seat->pointer.hidden = false;
|
seat->pointer.hidden = false;
|
||||||
|
seat->mouse.x = x;
|
||||||
|
seat->mouse.y = y;
|
||||||
|
|
||||||
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p",
|
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p, "
|
||||||
(void *)wl_pointer, serial, (void *)surface, (void *)term);
|
"x=%d, y=%d",
|
||||||
|
(void *)wl_pointer, serial, (void *)surface, (void *)term,
|
||||||
|
x, y);
|
||||||
|
|
||||||
xassert(tll_length(seat->mouse.buttons) == 0);
|
xassert(tll_length(seat->mouse.buttons) == 0);
|
||||||
|
|
||||||
|
|
@ -1771,9 +1778,6 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
seat->mouse_focus = term;
|
seat->mouse_focus = term;
|
||||||
|
|
||||||
int x = wl_fixed_to_int(surface_x) * term->scale;
|
|
||||||
int y = wl_fixed_to_int(surface_y) * term->scale;
|
|
||||||
|
|
||||||
switch ((term->active_surface = term_surface_kind(term, surface))) {
|
switch ((term->active_surface = term_surface_kind(term, surface))) {
|
||||||
case TERM_SURF_GRID: {
|
case TERM_SURF_GRID: {
|
||||||
/*
|
/*
|
||||||
|
|
@ -2276,6 +2280,16 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (button == BTN_RIGHT && tll_length(seat->mouse.buttons) == 1) {
|
||||||
|
struct csd_data info;
|
||||||
|
info = get_csd_data(term, CSD_SURF_TITLE);
|
||||||
|
xdg_toplevel_show_window_menu(
|
||||||
|
win->xdg_toplevel,
|
||||||
|
seat->wl_seat,
|
||||||
|
seat->pointer.serial,
|
||||||
|
seat->mouse.x + info.x, seat->mouse.y + info.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||||
|
|
|
||||||
2
input.h
2
input.h
|
|
@ -26,3 +26,5 @@ extern const struct wl_keyboard_listener keyboard_listener;
|
||||||
extern const struct wl_pointer_listener pointer_listener;
|
extern const struct wl_pointer_listener pointer_listener;
|
||||||
|
|
||||||
void input_repeat(struct seat *seat, uint32_t key);
|
void input_repeat(struct seat *seat, uint32_t key);
|
||||||
|
|
||||||
|
const char * xcursor_for_csd_border(struct terminal *term, int x, int y);
|
||||||
|
|
|
||||||
9
render.c
9
render.c
|
|
@ -1521,14 +1521,7 @@ render_worker_thread(void *_ctx)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct csd_data {
|
struct csd_data
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct csd_data
|
|
||||||
get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
|
get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
|
||||||
{
|
{
|
||||||
xassert(term->window->csd_mode == CSD_YES);
|
xassert(term->window->csd_mode == CSD_YES);
|
||||||
|
|
|
||||||
9
render.h
9
render.h
|
|
@ -24,3 +24,12 @@ struct render_worker_context {
|
||||||
struct terminal *term;
|
struct terminal *term;
|
||||||
};
|
};
|
||||||
int render_worker_thread(void *_ctx);
|
int render_worker_thread(void *_ctx);
|
||||||
|
|
||||||
|
struct csd_data {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct csd_data get_csd_data(const struct terminal *term, enum csd_surface surf_idx);
|
||||||
|
|
|
||||||
43
terminal.c
43
terminal.c
|
|
@ -2962,14 +2962,41 @@ term_mouse_motion(struct terminal *term, int button, int row, int col,
|
||||||
void
|
void
|
||||||
term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
|
term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
|
||||||
{
|
{
|
||||||
const char *xcursor
|
const char *xcursor;
|
||||||
= seat->pointer.hidden ? XCURSOR_HIDDEN
|
|
||||||
: term->is_searching ? XCURSOR_LEFT_PTR
|
switch (term->active_surface) {
|
||||||
: (seat->mouse.col >= 0 &&
|
case TERM_SURF_GRID: {
|
||||||
seat->mouse.row >= 0 &&
|
xcursor = seat->pointer.hidden ? XCURSOR_HIDDEN
|
||||||
term_mouse_grabbed(term, seat)) ? XCURSOR_TEXT
|
: term->is_searching ? XCURSOR_LEFT_PTR
|
||||||
: term->is_searching ? XCURSOR_TEXT
|
: (seat->mouse.col >= 0 &&
|
||||||
: XCURSOR_LEFT_PTR;
|
seat->mouse.row >= 0 &&
|
||||||
|
term_mouse_grabbed(term, seat)) ? XCURSOR_TEXT
|
||||||
|
: term->is_searching ? XCURSOR_TEXT
|
||||||
|
: XCURSOR_LEFT_PTR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TERM_SURF_SEARCH:
|
||||||
|
case TERM_SURF_SCROLLBACK_INDICATOR:
|
||||||
|
case TERM_SURF_RENDER_TIMER:
|
||||||
|
case TERM_SURF_JUMP_LABEL:
|
||||||
|
case TERM_SURF_TITLE:
|
||||||
|
case TERM_SURF_BUTTON_MINIMIZE:
|
||||||
|
case TERM_SURF_BUTTON_MAXIMIZE:
|
||||||
|
case TERM_SURF_BUTTON_CLOSE:
|
||||||
|
xcursor = XCURSOR_LEFT_PTR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TERM_SURF_BORDER_LEFT:
|
||||||
|
case TERM_SURF_BORDER_RIGHT:
|
||||||
|
case TERM_SURF_BORDER_TOP:
|
||||||
|
case TERM_SURF_BORDER_BOTTOM:
|
||||||
|
xcursor = xcursor_for_csd_border(term, seat->mouse.x, seat->mouse.y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TERM_SURF_NONE:
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
render_xcursor_set(seat, term, xcursor);
|
render_xcursor_set(seat, term, xcursor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue