Mouse enter/leave/move for non-focused window

This commit is contained in:
Kevin Lange 2014-04-20 13:44:17 -07:00
parent d967fae3a5
commit 3241d36e6d
5 changed files with 45 additions and 4 deletions

View File

@ -1010,11 +1010,37 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
free(response);
} else {
yg->mouse_window = get_focused(yg);
yutani_server_window_t * tmp_window = top_at(yg, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE);
if (yg->mouse_window) {
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
int32_t x, y;
device_to_window(yg->mouse_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
}
if (tmp_window) {
int32_t x, y;
yutani_msg_t * response;
if (tmp_window != yg->old_hover_window) {
device_to_window(tmp_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_ENTER);
pex_send(yg->server, tmp_window->owner, response->size, (char *)response);
free(response);
if (yg->old_hover_window) {
device_to_window(yg->old_hover_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(yg->old_hover_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_LEAVE);
pex_send(yg->server, yg->old_hover_window->owner, response->size, (char *)response);
free(response);
}
yg->old_hover_window = tmp_window;
}
if (tmp_window != yg->mouse_window) {
device_to_window(tmp_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
pex_send(yg->server, tmp_window->owner, response->size, (char *)response);
free(response);
}
}
}
}
break;
@ -1380,11 +1406,18 @@ int main(int argc, char * argv[]) {
yutani_server_window_t * w = hashmap_get(yg->wids_to_windows, (void *)wa->wid);
if (w) {
set_focused_window(yg, w);
yutani_msg_t * response = yutani_msg_build_notify();
foreach(node, yg->window_subscribers) {
uint32_t subscriber = (uint32_t)node->value;
pex_send(server, subscriber, response->size, (char *)response);
}
free(response);
}
}
break;
default:
{
fprintf(stderr, "[yutani-server] Unknown type!\n");
fprintf(stderr, "[yutani-server] Unknown type: 0x%8x\n", m->type);
}
break;
}

View File

@ -118,6 +118,8 @@ typedef struct {
volatile int redraw_lock;
yutani_server_window_t * old_hover_window;
} yutani_globals_t;
static void mark_window(yutani_globals_t * yg, yutani_server_window_t * window);

View File

@ -113,7 +113,7 @@ void panel_check_click(struct yutani_msg_window_mouse_event * evt) {
}
}
}
} else if (evt->command == YUTANI_MOUSE_EVENT_MOVE) {
} else if (evt->command == YUTANI_MOUSE_EVENT_MOVE || evt->command == YUTANI_MOUSE_EVENT_ENTER) {
if (evt->new_y < PANEL_HEIGHT) {
for (int i = 0; i < 18; ++i) {
if (icon_lefts[i] == 0) {
@ -128,6 +128,8 @@ void panel_check_click(struct yutani_msg_window_mouse_event * evt) {
} else {
set_focused(-1);
}
} else if (evt->command == YUTANI_MOUSE_EVENT_LEAVE) {
set_focused(-1);
}
}

View File

@ -130,7 +130,7 @@ void wallpaper_check_click(struct yutani_msg_window_mouse_event * evt) {
}
/* Within the icon range */
}
} else if (evt->command == YUTANI_MOUSE_EVENT_MOVE) {
} else if (evt->command == YUTANI_MOUSE_EVENT_MOVE || evt->command == YUTANI_MOUSE_EVENT_ENTER) {
if (evt->new_x > 0 && evt->new_x < ICON_X + ICON_WIDTH + EXTRA_WIDTH) {
uint32_t i = 0;
while (1) {
@ -149,6 +149,8 @@ void wallpaper_check_click(struct yutani_msg_window_mouse_event * evt) {
} else {
set_focused(-1);
}
} else if (evt->command == YUTANI_MOUSE_EVENT_LEAVE) {
set_focused(-1);
}
}

View File

@ -194,6 +194,8 @@ typedef struct yutani_window {
#define YUTANI_MOUSE_EVENT_RAISE 2
#define YUTANI_MOUSE_EVENT_DOWN 3
#define YUTANI_MOUSE_EVENT_MOVE 4
#define YUTANI_MOUSE_EVENT_LEAVE 5
#define YUTANI_MOUSE_EVENT_ENTER 6
typedef struct {
int x;