Skip to content

Commit

Permalink
Pass the event list through to the pointer barrier code to return it
Browse files Browse the repository at this point in the history
Instead of having the pointer barrier code enqueue events separately from
GetPointerEvents, pass the event list through and let it add to it.

Signed-off-by: Peter Hutterer <[email protected]>
Reviewed-by: Jasper St. Pierre <[email protected]>
  • Loading branch information
whot committed Dec 17, 2012
1 parent 707b4dc commit 21a15f9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
15 changes: 12 additions & 3 deletions Xi/xibarriers.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ void
input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
int current_x, int current_y,
int dest_x, int dest_y,
int *out_x, int *out_y)
int *out_x, int *out_y,
int *nevents, InternalEvent* events)
{
/* Clamped coordinates here refer to screen edge clamping. */
BarrierScreenPtr cs = GetBarrierScreen(screen);
Expand All @@ -356,6 +357,10 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
.dy = dest_y - current_y,
.root = screen->root->drawable.id,
};
InternalEvent *barrier_events = events;

if (nevents)
*nevents = 0;

if (xorg_list_is_empty(&cs->barriers) || IsFloating(dev))
goto out;
Expand Down Expand Up @@ -402,7 +407,9 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
ev.window = c->window->drawable.id;
c->last_timestamp = ms;

mieqEnqueue(dev, (InternalEvent *) &ev);
barrier_events->barrier_event = ev;
barrier_events++;
*nevents += 1;
}

xorg_list_for_each_entry(c, &cs->barriers, entry) {
Expand All @@ -429,7 +436,9 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
ev.window = c->window->drawable.id;
c->last_timestamp = ms;

mieqEnqueue(dev, (InternalEvent *) &ev);
barrier_events->barrier_event = ev;
barrier_events++;
*nevents += 1;

/* If we've left the hit box, this is the
* start of a new event ID. */
Expand Down
15 changes: 11 additions & 4 deletions dix/getevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,13 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
* @param[in,out] devy y desktop-wide coordinate in device coordinate system
* @param[in,out] screenx x coordinate in desktop coordinate system
* @param[in,out] screeny y coordinate in desktop coordinate system
* @param[out] nevents Number of barrier events added to events
* @param[in,out] events List of events barrier events are added to
*/
static ScreenPtr
positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
double *devx, double *devy, double *screenx, double *screeny)
double *devx, double *devy, double *screenx, double *screeny,
int *nevents, InternalEvent* events)
{
ScreenPtr scr = miPointerGetScreen(dev);
double tmpx, tmpy;
Expand All @@ -933,7 +936,7 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
/* miPointerSetPosition takes care of crossing screens for us, as well as
* clipping to the current screen. Coordinates returned are in desktop
* coord system */
scr = miPointerSetPosition(dev, mode, screenx, screeny);
scr = miPointerSetPosition(dev, mode, screenx, screeny, nevents, events);

/* If we were constrained, rescale x/y from the screen coordinates so
* the device valuators reflect the correct position. For screen
Expand Down Expand Up @@ -1319,6 +1322,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
int sx, sy; /* for POINTER_SCREEN */
ValuatorMask mask;
ScreenPtr scr;
int num_barrier_events = 0;

switch (type) {
case MotionNotify:
Expand Down Expand Up @@ -1395,7 +1399,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
}

scr = positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
&mask, &devx, &devy, &screenx, &screeny);
&mask, &devx, &devy, &screenx, &screeny,
&num_barrier_events, events);
num_events += num_barrier_events;
events += num_barrier_events;

/* screenx, screeny are in desktop coordinates,
mask is in device coordinates per-screen (the event data)
Expand Down Expand Up @@ -1945,7 +1952,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
scr = scale_to_desktop(dev, &mask, &devx, &devy, &screenx, &screeny);
if (emulate_pointer)
scr = positionSprite(dev, Absolute, &mask,
&devx, &devy, &screenx, &screeny);
&devx, &devy, &screenx, &screeny, NULL, NULL);

/* see fill_pointer_events for coordinate systems */
if (emulate_pointer)
Expand Down
3 changes: 2 additions & 1 deletion include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ extern _X_HIDDEN void update_desktop_dimensions(void);
extern _X_HIDDEN void input_constrain_cursor(DeviceIntPtr pDev, ScreenPtr screen,
int current_x, int current_y,
int dest_x, int dest_y,
int *out_x, int *out_y);
int *out_x, int *out_y,
int *nevents, InternalEvent* events);

#endif /* INPUT_H */
6 changes: 4 additions & 2 deletions mi/mipointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
*/
ScreenPtr
miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
double *screeny)
double *screeny,
int *nevents, InternalEvent* events)
{
miPointerScreenPtr pScreenPriv;
ScreenPtr pScreen;
Expand Down Expand Up @@ -598,7 +599,8 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,

input_constrain_cursor(pDev, pScreen,
current_x, current_y, x, y,
&constrained_x, &constrained_y);
&constrained_x, &constrained_y,
nevents, events);

x = constrained_x;
y = constrained_y;
Expand Down
3 changes: 2 additions & 1 deletion mi/mipointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y);
/* Moves the cursor to the specified position. May clip the co-ordinates:
* x and y are modified in-place. */
extern _X_EXPORT ScreenPtr
miPointerSetPosition(DeviceIntPtr pDev, int mode, double *x, double *y);
miPointerSetPosition(DeviceIntPtr pDev, int mode, double *x, double *y,
int *nevents, InternalEvent *events);

extern _X_EXPORT void
miPointerUpdateSprite(DeviceIntPtr pDev);
Expand Down

0 comments on commit 21a15f9

Please sign in to comment.