mirror of
https://github.com/labwc/labwc.git
synced 2026-02-23 01:40:18 -05:00
cursor.c: rebase cursor when exiting interactive mode
cursor_rebase() sets the cursor icon and sends a motion-event to the surface below the cursor. It is made public in anticipation of using it in various view_* functions.
This commit is contained in:
parent
1c831bc051
commit
afa299c080
2 changed files with 35 additions and 1 deletions
|
|
@ -424,6 +424,18 @@ struct view *desktop_surface_and_view_at(struct server *server, double lx,
|
||||||
|
|
||||||
struct view *desktop_view_at_cursor(struct server *server);
|
struct view *desktop_view_at_cursor(struct server *server);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cursor_rebase - set cursor icon for and send motion-event to surface below it
|
||||||
|
* @seat - current seat
|
||||||
|
* @time_msec - time now
|
||||||
|
*/
|
||||||
|
void cursor_rebase(struct seat *seat, uint32_t time_msec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cursor_set - set cursor icon
|
||||||
|
* @seat - current seat
|
||||||
|
* @cursor_name - name of cursor, for example "left_ptr" or "grab"
|
||||||
|
*/
|
||||||
void cursor_set(struct seat *seat, const char *cursor_name);
|
void cursor_set(struct seat *seat, const char *cursor_name);
|
||||||
void cursor_init(struct seat *seat);
|
void cursor_init(struct seat *seat);
|
||||||
|
|
||||||
|
|
|
||||||
24
src/cursor.c
24
src/cursor.c
|
|
@ -3,12 +3,32 @@
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
#include "resistance.h"
|
#include "resistance.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "config/mousebind.h"
|
#include "config/mousebind.h"
|
||||||
#include <wlr/types/wlr_primary_selection.h>
|
|
||||||
|
void
|
||||||
|
cursor_rebase(struct seat *seat, uint32_t time_msec)
|
||||||
|
{
|
||||||
|
double sx, sy;
|
||||||
|
struct wlr_surface *surface;
|
||||||
|
int view_area = LAB_SSD_NONE;
|
||||||
|
|
||||||
|
desktop_surface_and_view_at(seat->server, seat->cursor->x,
|
||||||
|
seat->cursor->y, &surface, &sx, &sy, &view_area);
|
||||||
|
|
||||||
|
if (surface) {
|
||||||
|
wlr_seat_pointer_notify_clear_focus(seat->seat);
|
||||||
|
wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
|
||||||
|
wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy);
|
||||||
|
} else {
|
||||||
|
cursor_set(seat, "left_ptr");
|
||||||
|
wlr_seat_pointer_notify_clear_focus(seat->seat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
request_cursor_notify(struct wl_listener *listener, void *data)
|
request_cursor_notify(struct wl_listener *listener, void *data)
|
||||||
|
|
@ -530,6 +550,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||||
/* Exit interactive move/resize/menu mode. */
|
/* Exit interactive move/resize/menu mode. */
|
||||||
server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
||||||
|
cursor_rebase(&server->seat, event->time_msec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goto mousebindings;
|
goto mousebindings;
|
||||||
|
|
@ -538,6 +559,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||||
menu_action_selected(server, server->rootmenu);
|
menu_action_selected(server, server->rootmenu);
|
||||||
server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
||||||
|
cursor_rebase(&server->seat, event->time_msec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue