static Atom proto_atom= None, delete_atom= None;
long event_mask;
- unsigned int button_state = 0;
double fov = 70.0;
double yaw = 0.0;
XConfigureEvent *cev = (XConfigureEvent *) &event;
printf ("XConfigureEvent received: width = %i; height = %i;\n",
cev->width, cev->height);
- /* TODO, FIXME: re-create `view' and `ximage' with cev->width, cev->height */
+
+ ui_destroy (view);
+ view = ui_create (cev->width, cev->height);
+ isChanged = 1;
}
break;
zoom_out (&fov);
isChanged = 1;
break;
+
+ case XK_Up:
+ pitch += 5.0;
+ if (pitch > 90.0)
+ pitch = 90.0;
+ isChanged = 1;
+ break;
+
+ case XK_Down:
+ pitch -= 5.0;
+ if (pitch < -90.0)
+ pitch = -90.0;
+ isChanged = 1;
+ break;
+
+ case XK_Right:
+ yaw += 5.0;
+ if (yaw > 180.0)
+ yaw -= 360.0;
+ isChanged = 1;
+ break;
+
+ case XK_Left:
+ yaw -= 5.0;
+ if (yaw <= -180.0)
+ yaw += 360.0;
+ isChanged = 1;
+ break;
}
}
break;
case ButtonRelease:
{
XButtonEvent *bev = (XButtonEvent *) &event;
- button_state = bev->state;
+ pos_x_old = pos_x_new = bev->x;
+ pos_y_old = pos_y_new = bev->y;
}
break;
pos_x_old = pos_x_new;
pos_y_old = pos_y_new;
- pos_x_new = mev->x;
- pos_y_new = mev->y;
- if (button_state & Button1Mask)
+ do
+ {
+ pos_x_new = mev->x;
+ pos_y_new = mev->y;
+ }
+ while (XCheckTypedEvent (disp_g, MotionNotify, &event));
+
+ printf ("XMotionEvent received: [%u,%u] -> [%u,%u]\n",
+ pos_x_old, pos_y_old, pos_x_new, pos_y_new);
+
+ if (mev->state & Button1Mask)
{
double yaw_diff = (pos_x_new - pos_x_old) / 24.0;
if (yaw_diff > 90.0)