diff --git a/apps/compositor.c b/apps/compositor.c index 50b76e5e..120496cf 100644 --- a/apps/compositor.c +++ b/apps/compositor.c @@ -530,6 +530,7 @@ static void draw_cursor(yutani_globals_t * yg, int x, int y, int cursor) { case YUTANI_CURSOR_TYPE_RESIZE_UP_DOWN: sprite = &yg->mouse_sprite_resize_da; break; case YUTANI_CURSOR_TYPE_RESIZE_DOWN_UP: sprite = &yg->mouse_sprite_resize_db; break; case YUTANI_CURSOR_TYPE_POINT: sprite = &yg->mouse_sprite_point; break; + case YUTANI_CURSOR_TYPE_IBEAM: sprite = &yg->mouse_sprite_ibeam; break; } } if (sprite != previous) { @@ -2091,6 +2092,7 @@ int main(int argc, char * argv[]) { load_sprite(&yg->mouse_sprite_resize_da, MOUSE_DIR "resize-uldr.png"); load_sprite(&yg->mouse_sprite_resize_db, MOUSE_DIR "resize-dlur.png"); load_sprite(&yg->mouse_sprite_point, MOUSE_DIR "point.png"); + load_sprite(&yg->mouse_sprite_ibeam, MOUSE_DIR "ibeam.png"); TRACE("Done."); TRACE("Initializing variables..."); diff --git a/apps/file-browser.c b/apps/file-browser.c index 394a551a..33ed8e44 100644 --- a/apps/file-browser.c +++ b/apps/file-browser.c @@ -2221,6 +2221,9 @@ int main(int argc, char * argv[]) { } } } + if (main_window->mouse_state == YUTANI_CURSOR_TYPE_IBEAM) { + yutani_window_show_mouse(yctx, main_window, YUTANI_CURSOR_TYPE_RESET); + } } else { _set_hilight(-1,0); if (me->command == YUTANI_MOUSE_EVENT_DOWN) { @@ -2228,9 +2231,15 @@ int main(int argc, char * argv[]) { _figure_out_navbar_cursor(me->new_x, bounds); redraw = 1; } + if (main_window->mouse_state == YUTANI_CURSOR_TYPE_RESET) { + yutani_window_show_mouse(yctx, main_window, YUTANI_CURSOR_TYPE_IBEAM); + } } } } else { + if (main_window->mouse_state == YUTANI_CURSOR_TYPE_IBEAM) { + yutani_window_show_mouse(yctx, main_window, YUTANI_CURSOR_TYPE_RESET); + } if (me->command == YUTANI_MOUSE_EVENT_DOWN) { if (nav_bar_focused) { nav_bar_focused = 0; diff --git a/apps/terminal.c b/apps/terminal.c index 557e870a..54c78404 100644 --- a/apps/terminal.c +++ b/apps/terminal.c @@ -1983,16 +1983,27 @@ static void * handle_incoming(void) { menu_bar_mouse_event(yctx, window, &terminal_menu_bar, me, me->new_x, me->new_y); } - if (me->new_x < 0 || me->new_y < 0) break; - if (!_no_frame) { - if (me->new_x >= (int)window_width + (int)decor_width) break; - if (me->new_y < (int)decor_top_height+menu_bar_height) break; - if (me->new_y >= (int)(window_height + decor_top_height+menu_bar_height)) break; - if (me->new_x < (int)decor_left_width) break; - if (me->new_x >= (int)(window_width + decor_left_width)) break; + if (me->new_x < 0 || me->new_y < 0 || + (!_no_frame && (me->new_x >= (int)window_width + (int)decor_width || + me->new_y < (int)decor_top_height+menu_bar_height || + me->new_y >= (int)(window_height + decor_top_height+menu_bar_height) || + me->new_x < (int)decor_left_width || + me->new_x >= (int)(window_width + decor_left_width))) || + (me->new_x >= (int)window_width || me->new_y >= (int)window_height)) { + if (window->mouse_state == YUTANI_CURSOR_TYPE_IBEAM) { + yutani_window_show_mouse(yctx, window, YUTANI_CURSOR_TYPE_RESET); + } + break; + } + + if (!(ansi_state->mouse_on & TERMEMU_MOUSE_ENABLE)) { + if (window->mouse_state == YUTANI_CURSOR_TYPE_RESET) { + yutani_window_show_mouse(yctx, window, YUTANI_CURSOR_TYPE_IBEAM); + } } else { - if (me->new_x >= (int)window_width) break; - if (me->new_y >= (int)window_height) break; + if (window->mouse_state == YUTANI_CURSOR_TYPE_IBEAM) { + yutani_window_show_mouse(yctx, window, YUTANI_CURSOR_TYPE_RESET); + } } int new_x = me->new_x; diff --git a/base/usr/include/toaru/yutani-server.h b/base/usr/include/toaru/yutani-server.h index 3b68c352..cbe459fe 100644 --- a/base/usr/include/toaru/yutani-server.h +++ b/base/usr/include/toaru/yutani-server.h @@ -216,6 +216,7 @@ typedef struct YutaniGlobals { sprite_t mouse_sprite_resize_da; sprite_t mouse_sprite_resize_db; sprite_t mouse_sprite_point; + sprite_t mouse_sprite_ibeam; int current_cursor; /* Server backend communication identifier */ diff --git a/base/usr/include/toaru/yutani.h b/base/usr/include/toaru/yutani.h index d1b42d43..43409f3a 100644 --- a/base/usr/include/toaru/yutani.h +++ b/base/usr/include/toaru/yutani.h @@ -79,6 +79,8 @@ typedef struct yutani_window { /* Server context that owns this window */ yutani_t * ctx; + + int32_t mouse_state; } yutani_window_t; typedef struct yutani_message { @@ -458,6 +460,7 @@ struct yutani_msg_clipboard { #define YUTANI_CURSOR_TYPE_RESIZE_UP_DOWN 5 #define YUTANI_CURSOR_TYPE_RESIZE_DOWN_UP 6 #define YUTANI_CURSOR_TYPE_POINT 7 +#define YUTANI_CURSOR_TYPE_IBEAM 8 /* * YUTANI_WINDOW_FLAG diff --git a/base/usr/share/cursor/ibeam.png b/base/usr/share/cursor/ibeam.png new file mode 100644 index 00000000..12ffdbd5 Binary files /dev/null and b/base/usr/share/cursor/ibeam.png differ diff --git a/lib/decorations.c b/lib/decorations.c index e3798096..688b35f3 100644 --- a/lib/decorations.c +++ b/lib/decorations.c @@ -328,7 +328,7 @@ int decor_handle_event(yutani_t * yctx, yutani_msg_t * m) { } else { if (old_resize_direction != SCALE_NONE) { yutani_window_show_mouse(yctx, window, YUTANI_CURSOR_TYPE_RESET); - old_resize_direction = 0; + old_resize_direction = SCALE_NONE; } } } diff --git a/lib/yutani.c b/lib/yutani.c index 2d3d4250..ccf46951 100644 --- a/lib/yutani.c +++ b/lib/yutani.c @@ -585,6 +585,7 @@ yutani_window_t * yutani_window_create_flags(yutani_t * y, int width, int height win->y = 0; win->user_data = NULL; win->ctx = y; + win->mouse_state = -1; free(mm); hashmap_set(y->windows, (void*)(uintptr_t)win->wid, win); @@ -979,9 +980,12 @@ void yutani_window_warp_mouse(yutani_t * yctx, yutani_window_t * window, int32_t * TODO: We should add a way to use client-provided cursor textures. */ void yutani_window_show_mouse(yutani_t * yctx, yutani_window_t * window, int32_t show_mouse) { - yutani_msg_buildx_window_show_mouse_alloc(m); - yutani_msg_buildx_window_show_mouse(m, window->wid, show_mouse); - yutani_msg_send(yctx, m); + if (window->mouse_state != show_mouse) { + window->mouse_state = show_mouse; + yutani_msg_buildx_window_show_mouse_alloc(m); + yutani_msg_buildx_window_show_mouse(m, window->wid, show_mouse); + yutani_msg_send(yctx, m); + } } /**