Exemple #1
0
/* _al_xwin_mouse_motion_notify_handler: [bgman thread]
 *  Called by _xwin_process_event() for MotionNotify events received from the X
 *  server.
 */
void _al_xwin_mouse_motion_notify_handler(int x, int y,
   ALLEGRO_DISPLAY *display)
{
   ALLEGRO_DISPLAY_XGLX *glx = (void *)display;
   int event_type = ALLEGRO_EVENT_MOUSE_AXES;

   if (!xmouse_installed)
      return;

   /* Is this an event generated in response to al_set_mouse_xy? */
   if (glx->mouse_warp) {
      glx->mouse_warp = false;
      event_type = ALLEGRO_EVENT_MOUSE_WARPED;
   }

   _al_event_source_lock(&the_mouse.parent.es);
   scale_xy(&x, &y);

   int dx = x - the_mouse.state.x;
   int dy = y - the_mouse.state.y;

   the_mouse.state.x = x;
   the_mouse.state.y = y;
   the_mouse.state.display = display;

   generate_mouse_event(
      event_type,
      the_mouse.state.x, the_mouse.state.y, the_mouse.state.z,
      the_mouse.state.w, the_mouse.state.pressure,
      dx, dy, 0, 0,
      0, display);

   _al_event_source_unlock(&the_mouse.parent.es);
}
Exemple #2
0
void
draw_clock(int x, int y, int w, int h, GR_WINDOW_ID pmap, GR_GC_ID gc,
	   GR_WINDOW_ID window)
{
    int i;

    GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOW));
    GrFillRect(pmap, gc, 0, 0, w, h);

    tick();
    push_matrix();
    translate(x + w / 2.0 - .5, y + h / 2.0 - .5);
    scale_xy((w - 1) / 28.0, (h - 1) / 28.0);
    if (type() == ROUND_CLOCK) {
	GrSetGCForeground(gc, BLACK);
	begin_polygon();
	circle(0, 0, 14, pmap, gc, w, h);
	end_polygon(pmap, gc);
	GrSetGCForeground(gc, BLACK);
	begin_loop();
	circle(0, 0, 14, pmap, gc, w, h);
	end_loop(pmap, gc);
    }
    //draw the shadows
    push_matrix();
    translate(0.60, 0.60);
    draw_clock_hands(LTGRAY, LTGRAY, pmap, gc);
    pop_matrix();
    //draw the tick marks
    push_matrix();
    GrSetGCForeground(gc, BLACK);
    for (i = 0; i < 12; i++) {
	if (6 == i)
	    rect(-0.5, 9, 1, 2, pmap, gc);
	else if (3 == i || 0 == i || 9 == i)
	    rect(-0.5, 9.5, 1, 1, pmap, gc);
	else
	    rect(-0.25, 9.5, .5, 1, pmap, gc);
	rotate(-30);
    }
    pop_matrix();
    //draw the hands
    draw_clock_hands(GRAY, BLACK, pmap, gc);
    pop_matrix();
    GrCopyArea(window, gc, 0, 0, w, h, pmap, 0, 0, MWROP_SRCCOPY);
}