Bugfix: Ignore enter_notify when warping pointer (makes "goto" work correctly)
This commit is contained in:
parent
2a3d44a794
commit
7d6e80b5ef
|
@ -13,6 +13,14 @@
|
||||||
|
|
||||||
#include <xcb/randr.h>
|
#include <xcb/randr.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the sequence number of an event to the ignored events.
|
||||||
|
* Useful to ignore for example the enter notify caused by a pointer warp of
|
||||||
|
* i3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void add_ignore_event(const int sequence);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There was a key press. We compare this key code with our bindings table and
|
* There was a key press. We compare this key code with our bindings table and
|
||||||
* pass the bound action to parse_command().
|
* pass the bound action to parse_command().
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "handlers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Removes the given client from the container, either because it will be inserted into another
|
* Removes the given client from the container, either because it will be inserted into another
|
||||||
|
@ -62,7 +63,12 @@ void client_remove_from_container(xcb_connection_t *conn, Client *client, Contai
|
||||||
void client_warp_pointer_into(xcb_connection_t *conn, Client *client) {
|
void client_warp_pointer_into(xcb_connection_t *conn, Client *client) {
|
||||||
int mid_x = client->rect.width / 2,
|
int mid_x = client->rect.width / 2,
|
||||||
mid_y = client->rect.height / 2;
|
mid_y = client->rect.height / 2;
|
||||||
xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, mid_x, mid_y);
|
xcb_void_cookie_t cookie;
|
||||||
|
cookie = xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, mid_x, mid_y);
|
||||||
|
/* We need to add this event twice because we get one enter_notify for
|
||||||
|
* the child and one for the frame */
|
||||||
|
add_ignore_event(cookie.sequence);
|
||||||
|
add_ignore_event(cookie.sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -46,7 +46,13 @@
|
||||||
changing workspaces */
|
changing workspaces */
|
||||||
static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
|
static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
|
||||||
|
|
||||||
static void add_ignore_event(const int sequence) {
|
/*
|
||||||
|
* Adds the sequence number of an event to the ignored events.
|
||||||
|
* Useful to ignore for example the enter notify caused by a pointer warp of
|
||||||
|
* i3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void add_ignore_event(const int sequence) {
|
||||||
struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event));
|
struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event));
|
||||||
|
|
||||||
event->sequence = sequence;
|
event->sequence = sequence;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
#include "handlers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to the workspace with the given number (starting at 0),
|
* Returns a pointer to the workspace with the given number (starting at 0),
|
||||||
|
@ -139,8 +140,10 @@ void workspace_show(xcb_connection_t *conn, int workspace) {
|
||||||
need_warp = true;
|
need_warp = true;
|
||||||
else {
|
else {
|
||||||
Rect *dims = &(c_ws->output->rect);
|
Rect *dims = &(c_ws->output->rect);
|
||||||
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
|
xcb_void_cookie_t cookie;
|
||||||
|
cookie = xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
|
||||||
dims->x + (dims->width / 2), dims->y + (dims->height / 2));
|
dims->x + (dims->width / 2), dims->y + (dims->height / 2));
|
||||||
|
add_ignore_event(cookie.sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-decorate the old client, it’s not focused anymore */
|
/* Re-decorate the old client, it’s not focused anymore */
|
||||||
|
|
Loading…
Reference in New Issue