示例#1
0
int main(int argc, char** argv) {
    if (argc != 2 || !argv[1][0] || !argv[1][1]) {
        fprintf(stderr, "Usage: %s chrootdisplay\n", argv[0]);
        return 2;
    }
    /* Make sure the displays aren't equal */
    char *cros_n = XDisplayName(NULL);
    if (cros_n[1] == argv[1][1]) {
        fprintf(stderr, "You must specify a different display.\n");
        return 2;
    }
    /* Open the displays */
    Display *cros_d, *chroot_d;
    Window cros_w, chroot_w;
    if (!(cros_d = XOpenDisplay(NULL))) {
        fprintf(stderr, "Failed to open Chromium OS display\n");
        return 1;
    }
    if (!(chroot_d = XOpenDisplay(argv[1]))) {
        fprintf(stderr, "Failed to open chroot display %s\n", argv[1]);
        return 1;
    }
    /* Get the XFixes extension for the chroot to monitor the cursor */
    int xfixes_event, xfixes_error;
    if (!XFixesQueryExtension(chroot_d, &xfixes_event, &xfixes_error)) {
        fprintf(stderr, "chroot is missing XFixes extension\n");
        return 1;

    }
    XSetErrorHandler(error_handler);
    /* Get the root windows */
    cros_w = DefaultRootWindow(cros_d);
    chroot_w = DefaultRootWindow(chroot_d);
    /* Monitor the chroot root window for cursor changes */
    XFixesSelectCursorInput(chroot_d, chroot_w, XFixesDisplayCursorNotifyMask);
    XEvent e;
    while (!error) {
        XNextEvent(chroot_d, &e);
        if (error) break;
        if (e.type != xfixes_event + XFixesCursorNotify) continue;
        /* Grab the new cursor and apply it to the Chromium OS X11 server */
        XFixesCursorImage *img = XFixesGetCursorImage(chroot_d);
        apply_cursor(cros_d, cros_w, img);
        XFree(img);
    }
    /* Clean up */
    apply_cursor(cros_d, cros_w, NULL);
    XCloseDisplay(cros_d);
    XCloseDisplay(chroot_d);
    return 0;
}
 void
 IBeamTool::on_motion_notify_event (GdkEventMotion *event)
 {
   Tool::on_motion_notify_event(event);
   
   // Ensure that we can't get a mixed up state
   ENSURE(isDragging == (dragType != None));
     
   if (isDragging)
     {
       set_leading_x(event->x);
       
       // Is the mouse out of bounds? if so we must begin scrolling
       const Gdk::Rectangle body_rect(get_body_rectangle());
       if (event->x < 0)
         begin_scroll_slide(
           event->x / ScrollSlideRateDivisor);
       else
       if (event->x > body_rect.get_width())
         begin_scroll_slide(
           (event->x - body_rect.get_width()) / ScrollSlideRateDivisor);
       else end_scroll_slide();
     }
     
   apply_cursor();
 }
示例#3
0
void cursor_tick()
{
    if (blink_delay--)
        return;
    blink_status ^= 1;
    apply_cursor();
}
 void
 IBeamTool::on_button_release_event (GdkEventButton* event)
 { 
   // Ensure that we can't get a mixed up state
   ENSURE(isDragging == (dragType != None));
   ENSURE(isDragging == (event->button == 1));
   
   if (event->button == 1)
     {
       set_leading_x(event->x);
       
       // Terminate the drag now the button is released
       dragType = None;
       
       // If there was a scroll slide, terminate it
       end_scroll_slide();
       
       // Apply the cursor - there are some corner cases where it can
       // change by the end of the drag
       apply_cursor();
     }
   
   Tool::on_button_release_event(event);
 }
示例#5
0
static void reset_blink()
{
    blink_status = 1;
    apply_cursor();
}
示例#6
0
文件: game.cpp 项目: Gaxx42/Purgatory
uint32_t Game::run()
{
//This is a main game

    //Quit flag
    bool quit = false;

    //The frame rate regulator
    Timer fps;

    ih_init();
    music_init();
    world_init();

    //SOME SORT OF MENU SHOULD BE HERE


    //Constructor calls etc
    Player *player = new Player();
    center_camera((player->get_x() + PLAYER_WIDTH/2), (player->get_y() + PLAYER_HEIGTH/2));

    show_message();
    //BOX FOR TEST
    world_generate();


    //main loop
    while(quit == false)
    {
        //Start the frame timer
        fps.start();

        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            handle_events(player);
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        music_play();


        //MOVES
        player->move();
        player->center();

        //CLS
        ih_clear_screen();

        //DRAWING

        //hide cursor
        SDL_ShowCursor(0);
        apply_cursor();

        player->draw();

        start_over();

        while(get_curr())
        {
            get_curr()->draw();
            traverse();
        }

        ih_update();

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }

    }


    delete player;
    world_finit();
    music_finit();
    ih_cleanup();


    return 0;
}