native: fix pointer constraining

fix copy-paste mistake in computing bottom constrain.
Also save few instructions by moving setting of
always-the-same value off loop.

https://bugzilla.gnome.org/show_bug.cgi?id=727337
This commit is contained in:
Marek Chalupa 2015-03-02 07:46:16 -05:00 committed by Rui Matos
parent 301a65e05a
commit 6234f7d1db

View File

@ -100,7 +100,7 @@ check_all_screen_monitors(MetaMonitorInfo *monitors,
left = monitor->rect.x; left = monitor->rect.x;
right = left + monitor->rect.width; right = left + monitor->rect.width;
top = monitor->rect.y; top = monitor->rect.y;
bottom = left + monitor->rect.height; bottom = top + monitor->rect.height;
if ((x >= left) && (x < right) && (y >= top) && (y < bottom)) if ((x >= left) && (x < right) && (y >= top) && (y < bottom))
return TRUE; return TRUE;
@ -118,25 +118,25 @@ constrain_all_screen_monitors (ClutterInputDevice *device,
{ {
ClutterPoint current; ClutterPoint current;
unsigned int i; unsigned int i;
float cx, cy;
clutter_input_device_get_coords (device, NULL, &current); clutter_input_device_get_coords (device, NULL, &current);
cx = current.x;
cy = current.y;
/* if we're trying to escape, clamp to the CRTC we're coming from */ /* if we're trying to escape, clamp to the CRTC we're coming from */
for (i = 0; i < n_monitors; i++) for (i = 0; i < n_monitors; i++)
{ {
MetaMonitorInfo *monitor = &monitors[i]; MetaMonitorInfo *monitor = &monitors[i];
int left, right, top, bottom; int left, right, top, bottom;
float nx, ny;
left = monitor->rect.x; left = monitor->rect.x;
right = left + monitor->rect.width; right = left + monitor->rect.width;
top = monitor->rect.y; top = monitor->rect.y;
bottom = left + monitor->rect.height; bottom = top + monitor->rect.height;
nx = current.x; if ((cx >= left) && (cx < right) && (cy >= top) && (cy < bottom))
ny = current.y;
if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom))
{ {
if (*x < left) if (*x < left)
*x = left; *x = left;