Beispiel #1
0
/***********************************************************************
 *           MsgWaitForMultipleObjectsEx   (X11DRV.@)
 */
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
                                          DWORD timeout, DWORD mask, DWORD flags )
{
    DWORD i, ret;
    struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );

    if (!data || data->process_event_count)
    {
        if (!count && !timeout) return WAIT_TIMEOUT;
        return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
                                         timeout, flags & MWMO_ALERTABLE );
    }

    /* check whether only server queue handle was passed in */
    if (count < 2) flags &= ~MWMO_WAITALL;

    data->process_event_count++;

    if (process_events( data->display, mask )) ret = count;
    else if (count || timeout)
    {
        HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1];  /* FIXME! */

        for (i = 0; i < count; i++) new_handles[i] = handles[i];
        new_handles[count] = data->display_fd;

        ret = WaitForMultipleObjectsEx( count+1, new_handles, flags & MWMO_WAITALL,
                                        timeout, flags & MWMO_ALERTABLE );
        if (ret == count) process_events( data->display, mask );
    }
    else ret = WAIT_TIMEOUT;

    data->process_event_count--;
    return ret;
}
Beispiel #2
0
/***********************************************************************
 *              MsgWaitForMultipleObjectsEx   (MACDRV.@)
 */
DWORD CDECL macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
                                               DWORD timeout, DWORD mask, DWORD flags)
{
    DWORD ret;
    struct macdrv_thread_data *data = macdrv_thread_data();
    macdrv_event_mask event_mask = get_event_mask(mask);

    TRACE("count %d, handles %p, timeout %u, mask %x, flags %x\n", count,
          handles, timeout, mask, flags);

    if (!data)
    {
        if (!count && !timeout) return WAIT_TIMEOUT;
        return WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
                                        timeout, flags & MWMO_ALERTABLE);
    }

    if (data->current_event && data->current_event->type != QUERY_EVENT &&
        data->current_event->type != QUERY_EVENT_NO_PREEMPT_WAIT &&
        data->current_event->type != APP_QUIT_REQUESTED &&
        data->current_event->type != WINDOW_DRAG_BEGIN)
        event_mask = 0;  /* don't process nested events */

    if (process_events(data->queue, event_mask)) ret = count - 1;
    else if (count || timeout)
    {
        ret = WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
                                       timeout, flags & MWMO_ALERTABLE);
        if (ret == count - 1) process_events(data->queue, event_mask);
    }
    else ret = WAIT_TIMEOUT;

    return ret;
}
void ble_do_events()
{
        spi_old = SPCR;
        SPI.setBitOrder(LSBFIRST);
        SPI.setClockDivider(SPI_CLOCK_DIV8);
        SPI.setDataMode(SPI_MODE0);

	if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX))
	{
		if(tx_buffer_len > 0)
		{	
			unsigned char Index = 0;
			while(tx_buffer_len > 20)
			{
				if(true == lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, &tx_buff[Index], 20))
				{
					Serial.print("data transmmit success!  Length: ");
					Serial.print(20, DEC);
					Serial.print("    ");
				}
				else
				{
					Serial.println("data transmmit fail !");
				}
				tx_buffer_len -= 20;
				Index += 20;
				aci_state.data_credit_available--;
				Serial.print("Data Credit available: ");
				Serial.println(aci_state.data_credit_available,DEC);
				ack = 0;
				while (!ack)
					process_events();
			}

			if(true == lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX,& tx_buff[Index], tx_buffer_len))
			{
				Serial.print("data transmmit success!  Length: ");
				Serial.print(tx_buffer_len, DEC);
				Serial.print("    ");
			}
			else
			{
				Serial.println("data transmmit fail !");
			}
			tx_buffer_len = 0;
			aci_state.data_credit_available--;
			Serial.print("Data Credit available: ");
			Serial.println(aci_state.data_credit_available,DEC);
			ack = 0;
			while (!ack)
				process_events();
		}
	}

	process_events();

	SPCR = spi_old;
}
Beispiel #4
0
static void*
event_thread(void *data)
{
    QUEUE* event_q = (QUEUE*) data;
    parrot_event* event;
    QUEUE_ENTRY *entry;
    int running = 1;

    LOCK(event_q->queue_mutex);
    /*
     * we might already have an event in the queue
     */
    if (peek_entry(event_q))
        running = process_events(event_q);
    while (running) {
        entry = peek_entry(event_q);
        if (!entry) {
            /* wait infinite until entry arrives */
            queue_wait(event_q);
        }
        else if (entry->type == QUEUE_ENTRY_TYPE_TIMED_EVENT) {
            /* do a_timedwait for entry */
            struct timespec abs_time;
            FLOATVAL when;
            event = (parrot_event* )entry->data;
            when = event->u.timer_event.abs_time;
            abs_time.tv_sec = (time_t) when;
            abs_time.tv_nsec = (when - abs_time.tv_sec) *
                (1000L*1000L*1000L);
            queue_timedwait(event_q, &abs_time);
        }
        else {
            /* we shouldn't get here probably
             */
            internal_exception(1, "Spurious event");

        }
        /*
         * one or more entries arrived - we hold the mutex again
         * so we have to use the nonsync_pop_entry to pop off event entries
         */
        running = process_events(event_q);
    } /* event loop */
    /*
     * the main interpreter is dying
     * TODO empty the queue
     */
    UNLOCK(event_q->queue_mutex);
    queue_destroy(event_q);
    stop_io_thread();
    edebug((stderr, "event thread stopped\n"));
    return NULL;
}
Beispiel #5
0
void ble_do_events()
{
			if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX))
			{
				if(tx_buffer_len > 0)
				{	
					unsigned char Index = 0;
					while(tx_buffer_len > 20)
					{
						if(true == lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, &tx_buff[Index], 20))
						{
							Serial.print("data transmmit success!  Length: ");
							Serial.print(20, DEC);
							Serial.print("    ");
						}
						else
						{
							Serial.println("data transmmit fail !");
						}
						tx_buffer_len -= 20;
						Index += 20;
						aci_state.data_credit_available--;
						Serial.print("Data Credit available: ");
						Serial.println(aci_state.data_credit_available,DEC);
						ack = 0;
						while (!ack)
							process_events();
					}

						if(true == lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX,& tx_buff[Index], tx_buffer_len))
						{
							Serial.print("data transmmit success!  Length: ");
							Serial.print(tx_buffer_len, DEC);
							Serial.print("    ");
						}
						else
						{
							Serial.println("data transmmit fail !");
						}
						tx_buffer_len = 0;
						aci_state.data_credit_available--;
						Serial.print("Data Credit available: ");
						Serial.println(aci_state.data_credit_available,DEC);
						ack = 0;
						while (!ack)
							process_events();
				}
			}
			process_events();
}
Beispiel #6
0
/* XoXus: FIXME: Should get_keypress block? */
static int gfx_get_key ()
{
	UINT16 k;

	process_events ();
	while (key_value == 0) {
		process_events ();
	}

	k = key_value;
	key_value= 0;

	return k;
}
Beispiel #7
0
static ERL_NIF_TERM process_events(ErlNifEnv* env, events_t **events,
				   yaml_parser_t *parser, int flags)
{
    ERL_NIF_TERM els, el;
    yaml_event_t *event;
    els = enif_make_list(env, 0);

    if (events) {
	while (*events) {
	    event = hd(events);
	    if (event) {
		switch (event->type) {
		case YAML_SEQUENCE_END_EVENT:
		    el = process_events(env, events, parser, flags);
		    els = enif_make_list_cell(env, el, els);
		    break;
		case YAML_MAPPING_END_EVENT:
		    el = process_events(env, events, parser, flags);
		    els = enif_make_list_cell(env, el, els);
		    break;
		case YAML_MAPPING_START_EVENT:
		    yaml_event_delete(event);
		    enif_free(event);
		    return zip(env, els);
		case YAML_SEQUENCE_START_EVENT:
		    yaml_event_delete(event);
		    enif_free(event);
		    return els;
		case YAML_SCALAR_EVENT:
		    el = make_scalar(env, event, flags);
		    els = enif_make_list_cell(env, el, els);
		    break;
		case YAML_ALIAS_EVENT:
		    el = make_alias(env, event);
		    els = enif_make_list_cell(env, el, els);
		    break;
		default:
		    break;
		}
		yaml_event_delete(event);
		enif_free(event);
	    } else {
		break;
	    }
	}
    }

    return els;
}
Beispiel #8
0
int main()
{
  int retcode;
  retcode=SDL_Init(SDL_INIT_VIDEO);
  if(-1==retcode)
    {
      std::cerr << "sdlInitFailed: " << SDL_GetError() << std::endl;
      return retcode;
    }

  if(!init_sdl_context() )
    {
      SDL_Quit();
      return -1;
    }

  if(!init_gl())
    {
      SDL_Quit();
      return -1;
    }

  init_music();

  while(true)
    {
      process_events();
      render_gl();
    }
  terminate_music();
  terminate_gl();
  SDL_Quit();

  return 0;
}
Beispiel #9
0
/******************************************************************************
 *                                                                            *
 * Function: process_time_functions                                           *
 *                                                                            *
 * Purpose: re-calculate and update values of time-driven functions           *
 *                                                                            *
 * Author: Alexei Vladishev, Aleksandrs Saveljevs                             *
 *                                                                            *
 ******************************************************************************/
static void	process_time_functions(int *triggers_count, int *events_count)
{
	const char		*__function_name = "process_time_functions";
	DC_TRIGGER		*trigger_info = NULL;
	zbx_vector_ptr_t	trigger_order;

	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

	zbx_vector_ptr_create(&trigger_order);

	DCconfig_get_time_based_triggers(&trigger_info, &trigger_order, process_num, triggers_count);

	if (0 == trigger_order.values_num)
		goto clean;

	evaluate_expressions(&trigger_order);

	DBbegin();

	process_triggers(&trigger_order);

	DCfree_triggers(&trigger_order);

	*events_count = process_events();

	DBcommit();
clean:
	zbx_free(trigger_info);
	zbx_vector_ptr_destroy(&trigger_order);

	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
}
Beispiel #10
0
int main( int argc, char* argv[] )
{
  if (argc > 1) {
    cout << "Retro Quake2 Model - W.P. van Paassen - 2002" << endl;
    return -1;
  }
  
  TDEC_init_video();

  SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
  
  if (!TDEC_set_video_GL(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_DOUBLEBUF | SDL_HWACCEL | SDL_HWSURFACE | SDL_HWPALETTE  
			 /*| SDL_FULLSCREEN*/))
    quit(1);
  
  TDEC_init_timer();
  
  SDL_WM_SetCaption("Retro Quake2 Model effect ", "");
  
  WP_Init* wpcg = new WP_Init(argc, argv);
  wpcg->vSetViewPort(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);	
  init();

  Uint32 ntime, time = SDL_GetTicks();
  Uint32 next = SDL_GetTicks() + TICK_INTERVAL; 

  /* time based demo loop */
  while( 1 ) 
    {
     if ((ntime = SDL_GetTicks()) < next)
     {
	     draw_screen();
	     if (ntime - time >= 1000)
	     {
		     rfps = fps;//(Uint32)(((float)fps / (ntime - time)) * 1000);
		     fps = 0;
		     time = SDL_GetTicks();
	     }
	     else
	     	fps++;
     }
     else
	{
     	  process_events();
  	  demon->setNewHeading(heading);
  	  weapon->setNewHeading(heading);
  	  heading += 0.6f;
  	  if (heading >= 360.0f)
    		heading -= 360.0f;
  	  manager->updateAll();
	  next = SDL_GetTicks() + TICK_INTERVAL;
	}
    }
  
  return 0; /* never reached */
}
Beispiel #11
0
/*
 * Messages incoming from the phone
 */
void received_message(DictionaryIterator *received, void *context) {
   // Gather the bits of a calendar together	
   Tuple *tuple = dict_find(received, CALENDAR_RESPONSE_KEY);
	  
   if (tuple) {
	    set_event_status(STATUS_REPLY);
    	uint8_t i, j;

		if (count > received_rows) {
      		i = received_rows;
      		j = 0;
        } else {
      	    count = tuple->value->data[0];
      	    i = 0;
      	    j = 1;
        }

        while (i < count && j < tuple->length) {
    	    memcpy(&temp_event, &tuple->value->data[j], sizeof(Event));
      	    memcpy(&events[temp_event.index], &temp_event, sizeof(Event));

      	    i++;
      	    j += sizeof(Event);
        }

        received_rows = i;

        if (count == received_rows) {
			    max_entries = count;
			    calendar_request_outstanding = false;
			          process_events();
	    }
	}

}
Beispiel #12
0
void sdl_thread() {
	for (;;) {

		// Wait for the emulation thread to signal that a frame has completed

		SDL_LockMutex(frame_lock);
		ready_to_draw_new_frame = true;
		while (!frame_available && !pending_sdl_thread_exit)
			SDL_CondWait(frame_available_cond, frame_lock);
		if (pending_sdl_thread_exit) {
			SDL_UnlockMutex(frame_lock);
			return;
		}
		frame_available = ready_to_draw_new_frame = false;
		SDL_UnlockMutex(frame_lock);

		// Process events and calculate controller input state (which might
		// need left+right/up+down elimination)

		process_events();

		// Draw the new frame

		fail_if(SDL_UpdateTexture(screen_tex, 0, front_buffer, 256*sizeof(Uint32)),
				"failed to update screen texture: %s", SDL_GetError());
		fail_if(SDL_RenderCopy(renderer, screen_tex, 0, 0),
				"failed to copy rendered frame to render target: %s", SDL_GetError());
		SDL_RenderPresent(renderer);
	}
}
Beispiel #13
0
	int app::exec(bool aQuitWhenLastWindowClosed)
	{
		try
		{
			surface_manager().layout_surfaces();
			surface_manager().invalidate_surfaces();
			iQuitWhenLastWindowClosed = aQuitWhenLastWindowClosed;
			while (!iQuitResultCode.is_initialized())
				process_events(*iContext);
			return *iQuitResultCode;
		}
		catch (std::exception& e)
		{
			halt();
			std::cerr << "neogfx::app::exec: terminating with exception: " << e.what() << std::endl;
			iSurfaceManager->display_error_message(iName.empty() ? "Abnormal Program Termination" : "Abnormal Program Termination - " + iName, std::string("neogfx::app::exec: terminating with exception: ") + e.what());
			std::exit(EXIT_FAILURE);
		}
		catch (...)
		{
			halt();
			std::cerr << "neogfx::app::exec: terminating with unknown exception" << std::endl;
			iSurfaceManager->display_error_message(iName.empty() ? "Abnormal Program Termination" : "Abnormal Program Termination - " + iName, "neogfx::app::exec: terminating with unknown exception");
			std::exit(EXIT_FAILURE);
		}
	}
Beispiel #14
0
void main_loop() {
  struct timespec ptime;
  struct timespec ctime;
  struct timespec diff;
  clock_gettime(CLOCK_MONOTONIC_COARSE, &ctime);
  while (running) {
    clock_gettime(CLOCK_MONOTONIC_COARSE, &ptime);

    reshape_window();
    poll_geometry();
    process_events();
    display_func();

    clock_gettime(CLOCK_MONOTONIC_COARSE, &ctime);
    diff.tv_sec  = ctime.tv_sec - ptime.tv_sec;
    diff.tv_nsec = ctime.tv_nsec - ptime.tv_nsec;
    long sleeptime = 16666666l - ( diff.tv_sec * 1000000000l + diff.tv_nsec );
    diff.tv_sec  = 0;
    diff.tv_nsec = sleeptime;

    while (diff.tv_nsec > 0) {
      struct timespec rem;
      int i = nanosleep(&diff, &rem);
      if (i < 0) {
        diff.tv_sec  = rem.tv_sec;
        diff.tv_nsec = rem.tv_nsec;
      } else {
        break;
      }
    }
  }
}
Beispiel #15
0
int main(int argc, char* argv[]) {
	// If intialising of SDL fails -> quit the program with error code 1
	if (!init_SDL()) {
		quit_program(1);
	}
	
	// If intialising of OpenGL fails -> quit the program with error code 1
	if (!init_OpenGL(default_width, default_height)) {
		quit_program(1);
	}
	
	// Repeat forever
	while(true) {
		// Draw your graphics
		draw_screen();
		
		// Process any ocuring events 
		process_events();
		fflush(stdout);
	}
	
	// You shouldn't get here. Only if someone changes the while condition...
	quit_program(0);
	
	return 0;
}
Beispiel #16
0
int main(int argc, char **argv)
{
	if(argc == 1) {
		fprintf(stderr, "Usage: %s FILE\n", argv[0]);
		exit(1);
	}

	errno = 0;
	size_t size;
	int32_t *mem = read_file(argv[1], &size);
	if(!mem) {
		if(errno)
			perror(argv[0]);
		else
			fprintf(stderr, "%s: The file was invalid.\n", argv[0]);
		exit(1);
	}

	init_vm(mem, size);

	while(1) {
		run_vm();
		render_screen();
		process_events();
		delay();
	}
}
Beispiel #17
0
int main(int argc, char** argv) {
    uint32_t last_frame_time = 0;
    uint32_t width = 640;
    uint32_t height = 480;
    bool quit = false;
    SDL_Window* window = NULL;
    SDL_Renderer* ren = NULL;
    SDL_Texture* texture = NULL;
    static uint32_t* pxbuf = NULL;
    static uint8_t* bug_data = NULL;
    //Initialize game
    pxbuf = new uint32_t[width*height];
    bug_data = new uint8_t[width*height];
    memset(pxbuf, 0x00, width*height); 
    memset(bug_data, 0x00, width*height); 

    if(init_sdl(width, height, &window, &ren, &texture)) {
        return 1;
    }   printf("SDL successfully initialized.\n");

    while (!quit) {
        last_frame_time = SDL_GetTicks();
        if (process_events() == -1) {
            quit = true;
        }
        update_bugs(width, height, bug_data);
        update_world(width, height, pxbuf, bug_data, texture);
        draw_world(width, height, texture, ren);
        printf("FPS: %f  \r", 1000./(SDL_GetTicks()-last_frame_time));
    }
    SDL_Quit();
    return 0;
}
Beispiel #18
0
/** Mainloop for processing event input devices
 *
 * @param path  vector of input device paths
 * @param count number of paths in the path
 * @param identify if nonzero print input device information
 * @param trace stay in loop and print out events as they arrive
 */
static
void
mainloop(char **path, int count, int identify, int trace)
{
  struct pollfd pfd[count];

  int closed = 0;

  for( int i = 0; i < count; ++i )
  {
    if( (pfd[i].fd = evdev_open_device(path[i])) == -1 )
    {
      ++closed;
      continue;
    }

    if( identify )
    {
      printf("----====( %s )====----\n", path[i]);
      evdev_identify_device(pfd[i].fd);
      printf("\n");
    }
  }

  if( !trace )
  {
    goto cleanup;
  }

  while( closed < count )
  {
    for( int i = 0; i < count; ++i )
    {
      pfd[i].events = (pfd[i].fd < 0) ? 0 : POLLIN;
    }

    poll(pfd, count, -1);

    for( int i = 0; i < count; ++i )
    {
      if( pfd[i].revents )
      {
        if( process_events(pfd[i].fd, path[i]) <= 0 )
        {
          close(pfd[i].fd);
          pfd[i].fd = -1;
          ++closed;
        }
      }
    }
  }

cleanup:

  for( int i = 0; i < count; ++i )
  {
    if( pfd[i].fd != -1 ) close(pfd[i].fd);
  }
}
Beispiel #19
0
void
ScreenManager::run()
{
  Uint32 last_ticks = 0;
  Uint32 elapsed_ticks = 0;

  handle_screen_switch();

  while (!m_screen_stack.empty())
  {
    Uint32 ticks = SDL_GetTicks();
    elapsed_ticks += ticks - last_ticks;
    last_ticks = ticks;

    /** ticks (as returned from SDL_GetTicks) per frame */
    const Uint32 ticks_per_frame = static_cast<Uint32>(1000.0 / m_target_framerate * g_debug.get_game_speed_multiplier());

    if (elapsed_ticks > ticks_per_frame*4)
    {
      // when the game loads up or levels are switched the
      // elapsed_ticks grows extremely large, so we just ignore those
      // large time jumps
      elapsed_ticks = 0;
    }

    if (elapsed_ticks < ticks_per_frame)
    {
      Uint32 delay_ticks = ticks_per_frame - elapsed_ticks;
      SDL_Delay(delay_ticks);
      last_ticks += delay_ticks;
      elapsed_ticks += delay_ticks;
    }

    int frames = 0;

    while (elapsed_ticks >= ticks_per_frame && frames < MAX_FRAME_SKIP)
    {
      elapsed_ticks -= ticks_per_frame;
      float timestep = 1.0f / m_target_framerate;
      g_real_time += timestep;
      timestep *= m_speed;
      g_game_time += timestep;

      process_events();
      update_gamelogic(timestep);
      frames += 1;
    }

    if (!m_screen_stack.empty())
    {
      Compositor compositor(m_video_system);
      draw(compositor);
    }

    SoundManager::current()->update();

    handle_screen_switch();
  }
}
Beispiel #20
0
void tick()
{
  process_events();

  update_enemies();
  update_towers();
  update_player();
}
Beispiel #21
0
void Dodger::loop()
{
    while (window.isOpen() && running) {
        process_events();
        update();
        draw();
    }
}
void BLE::waitForACIResponse() {

  _aci_cmd_pending = true;
  while (_aci_cmd_pending) process_events();

  // Reset hung-loop detection
  loopingSinceLastBark = false;
}
void BLE::waitForDataCredit() {

  _data_credit_pending = true;
  while (_data_credit_pending) process_events();

  // Reset hung-loop detection
  loopingSinceLastBark = false;
}
int main(int argc, char **argv) {
    uint32_t width = test_width - 2 * INSET_X;
    uint32_t height = test_height - 2 * INSET_Y;
    int snum;
    xcb_void_cookie_t check_cookie;
    xcb_window_t w;
    xcb_gcontext_t gc;
    xcb_pixmap_t pix;
    xcb_connection_t *c = xcb_connect(0, &snum);
    xcb_screen_t *s = xcb_aux_get_screen(c, snum);
    xcb_alloc_named_color_cookie_t bg_cookie =
	xcb_alloc_named_color(c, s->default_colormap,
			      strlen("white"), "white");
    xcb_alloc_named_color_cookie_t fg_cookie =
	xcb_alloc_named_color(c, s->default_colormap,
			      strlen("black"), "black");
    xcb_alloc_named_color_reply_t *bg_reply =
	xcb_alloc_named_color_reply(c, bg_cookie, 0);
    xcb_alloc_named_color_reply_t *fg_reply =
	xcb_alloc_named_color_reply(c, fg_cookie, 0);
    uint32_t fg, bg;
    xcb_image_t *image, *native_image, *subimage;
    uint32_t mask = 0;
    xcb_params_gc_t gcv;

    assert(bg_reply && fg_reply);
    bg = bg_reply->pixel;
    fg = fg_reply->pixel;
    free(bg_reply);
    free(fg_reply);
    w = make_window(c, s, bg, fg, width, height);
    gc = xcb_generate_id(c);
    check_cookie = xcb_create_gc_checked(c, gc, w, 0, 0);
    assert(!xcb_request_check(c, check_cookie));
    image = xcb_image_create_from_bitmap_data((uint8_t *)test_bits,
					      test_width, test_height);
    native_image = xcb_image_native(c, image, 1);
    assert(native_image);
    if (native_image != image)
	xcb_image_destroy(image);
    subimage = xcb_image_subimage(native_image, INSET_X, INSET_Y,
				  width, height,
				  0, 0, 0);
    assert(subimage);
    xcb_image_destroy(native_image);
    subimage->format = XCB_IMAGE_FORMAT_XY_BITMAP;
    pix = xcb_generate_id(c);
    xcb_create_pixmap(c, s->root_depth, pix, w,
		      subimage->width, subimage->height);
    gc = xcb_generate_id(c);
    XCB_AUX_ADD_PARAM(&mask, &gcv, foreground, fg);
    XCB_AUX_ADD_PARAM(&mask, &gcv, background, bg);
    xcb_aux_create_gc(c, gc, pix, mask, &gcv);
    xcb_image_put(c, pix, gc, subimage, 0, 0, 0);
    process_events(c, gc, w, pix, width, height);
    xcb_disconnect(c);
    return 1;
}
Beispiel #25
0
void video_output_qt::trigger_resize(int w, int h)
{
    _container_widget->set_recommended_size(w, h);
    _container_widget->updateGeometry();
    // Process events to propagate the information that the geometry needs updating.
    process_events();
    if (!_container_is_external)
        _container_widget->adjustSize();
}
Beispiel #26
0
Datei: o6.c Projekt: manish05/TCR
/* Program entry point */
int main (int argc, char* argv[]) {
   debug=fopen("debug.txt","w");

    // window dimensions
    int width  = 640;
    int height = 480;
    const SDL_VideoInfo *info;

    /* initialize SDL's video subsystem */
    if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
        fprintf( stderr, "Video initialization failed: %s\n", SDL_GetError( ) );
        return -1;
    }

    /* retrieve video information */
    info = SDL_GetVideoInfo( );
    if (!info) {
        fprintf( stderr, "Video query failed: %s\n", SDL_GetError( ) );
        return -1;
    }

    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,   8 ); /* min 8bit red */
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8 ); /* min 8bit green */
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,  8 ); /* min 8bit blue */
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); /* 16bit depth buffer */
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); /* require double buffering */

    /* Set video mode */
    SDL_Surface * surface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, SDL_OPENGL);
    if (!surface) {
        fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) );
        return -1;
    }

    /* OpenGL initialization */
    setup_opengl(width, height);

    init();
    lys();
    tekstur();

    /* main event loop */
    while (running) {
      animer();
        /* Process incoming events */
        process_events();
        /* Draw the screen */
        draw_scene();

      sprett();
        SDL_Delay(1000/500); /* limit to 5fps */
    }

    SDL_Quit(); /* unload SDL */
    fclose(debug);
    return 0;
}
Beispiel #27
0
void App::run()
{
	while ( true )
	{
		display();			// draw scene
		if (process_events())	// handle user events
			return;
	}
}
Beispiel #28
0
static gboolean  
event_dispatch (GSource     *source,
		GSourceFunc  callback,
		gpointer     user_data)
{
	process_events ();

	return TRUE;
}
Beispiel #29
0
void android_main(struct android_app* state) {
	app_dummy();

	Engine engine;

	state->userData = &engine;
	state->onAppCmd = handle_cmd;
	//state->onInputEvent = engine_handle_input;

	while(!initialized)
		process_events(state);

	while (process_events(state)) {
		engine.run_one_frame();
	}

	engine.finalize();
}
Beispiel #30
0
  void kqueue_monitor::run()
  {
    initialize_kqueue();

    for(;;)
    {
#ifdef HAVE_CXX_MUTEX
      unique_lock<mutex> run_guard(run_mutex);
      if (should_stop) break;
      run_guard.unlock();
#endif

      // remove the deleted descriptors
      remove_deleted();

      // rescan the pending descriptors
      rescan_pending();

      // scan the root paths to check whether someone is missing
      scan_root_paths();

      vector<struct kevent> changes;
      vector<struct kevent> event_list;

      for (const pair<int, string>& fd_path : load->file_names_by_descriptor)
      {
        struct kevent change;

        EV_SET(&change,
               fd_path.first,
               EVFILT_VNODE,
               EV_ADD | EV_ENABLE | EV_CLEAR,
               NOTE_DELETE | NOTE_EXTEND | NOTE_RENAME | NOTE_WRITE | NOTE_ATTRIB | NOTE_LINK | NOTE_REVOKE,
               0,
               0);

        changes.push_back(change);
        struct kevent event;
        event_list.push_back(event);
      }

      /*
       * If no files can be observed yet, then wait and repeat the loop.
       */
      if (!changes.size())
      {
        sleep(latency);
        continue;
      }

      const int event_num = wait_for_events(changes, event_list);
      process_events(changes, event_list, event_num);
    }

    terminate_kqueue();
  }