Beispiel #1
0
/*!
  Wait for a click from one of the mouse button and get the position
  of the clicked image point.

  \param ip [out] : The coordinates of the clicked image point.

  \param blocking [in] : true for a blocking behaviour waiting a mouse
  button click, false for a non blocking behaviour.

  \return 
  - true if a button was clicked. This is always the case if blocking is set 
    to \e true.
  - false if no button was clicked. This can occur if blocking is set
    to \e false.

*/
bool
vpDisplayGTK::getClick(vpImagePoint &ip, bool blocking)
{
  bool ret = false;

  if (displayHasBeenInitialized) {

    double u, v ;
    do {
      GdkEvent *ev = NULL;
      while ((ev = gdk_event_get())!=NULL){
        if (ev->any.window == widget->window && ev->type == GDK_BUTTON_PRESS) {
          u = ((GdkEventButton *)ev)->x ;
          v = ((GdkEventButton *)ev)->y ;
	  ip.set_u( u );
	  ip.set_v( v );
          ret = true ;
        }
        gdk_event_free(ev) ;
      }
      if (blocking){
        flushDisplay();
        vpTime::wait(100);
      }
    } while ( ret == false && blocking == true);
  }
  else {
    vpERROR_TRACE("GTK not initialized " ) ;
    throw(vpDisplayException(vpDisplayException::notInitializedError,
                             "GTK not initialized")) ;
  }
  return ret ;
}
Beispiel #2
0
/*!
  Wait for a click from one of the mouse button.

  \param blocking [in] : Blocking behavior.
  - When set to true, this method waits until a mouse button is
    pressed and then returns always true.
  - When set to false, returns true only if a mouse button is
    pressed, otherwise returns false.

  \return 
  - true if a button was clicked. This is always the case if blocking is set 
    to \e true.
  - false if no button was clicked. This can occur if blocking is set
    to \e false.
*/
bool
vpDisplayGTK::getClick(bool blocking)
{
  bool ret = false;

  if (displayHasBeenInitialized) {

    //    flushDisplay() ;
    //int cpt =0;
    do {
      GdkEvent *ev = NULL;
      while ((ev = gdk_event_get())!=NULL){
        //cpt++;
        //	printf("event %d type %d on window %p My window %p\n",
        //cpt, ev->type, ev->any.window, widget->window);

        if (ev->any.window == widget->window && ev->type == GDK_BUTTON_PRESS){
          ret = true ;
          //printf("Click detection\n");
        }
        gdk_event_free(ev) ;
      }
      if (blocking){
        flushDisplay();
        vpTime::wait(100);
      }
    } while ( ret == false && blocking == true);
  }
  else {
    vpERROR_TRACE("GTK not initialized " ) ;
    throw(vpDisplayException(vpDisplayException::notInitializedError,
                             "GTK not initialized")) ;
  }
  return ret;
}
Beispiel #3
0
static gboolean
conversation_nick_clicked(PurpleConversation* conv, gchar* nick, guint button)
{
    GdkEvent* next_event = NULL;
    PidginConversation* pidgin_conv = NULL;
    gint event_timeout = 100; /* milliseconds */

    if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_CHAT)
    {
        purple_debug_warning(USERCAST_PLUGIN_NAME, "Conversation `%s' is not a chat\n", conv->name);
        return FALSE;
    }

    if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
    {
        purple_debug_warning(USERCAST_PLUGIN_NAME, "Conversation `%s' is not a pidgin conversation\n",
                             conv->name);
        return FALSE;
    }

    if (button != 1)
        return FALSE;

    /* Wait for either GDK_2BUTTON_EVENT or something else to arrive */
    for (; event_timeout > 0; event_timeout--)
    {
        if ((next_event = gdk_event_peek()))
            break;
        g_usleep(1000); /* 1 millisecond */
    }

    /* Pingin handles GDK_2BUTTON_PRESS separately */
    if (next_event && next_event->type == GDK_2BUTTON_PRESS)
    {
        /* Remove GDK_2BUTTON_PRESS from event queue */
        gdk_event_free(next_event);
        gdk_event_free(gdk_event_get());

        pidgin_conv = PIDGIN_CONVERSATION(conv);
        cast_nick(pidgin_conv, nick);
        gtk_widget_grab_focus(pidgin_conv->entry);

        purple_debug_info(USERCAST_PLUGIN_NAME, "Casted user `%s' to `%s'\n", nick, conv->name);
        return TRUE;
    }

    return FALSE;
}
Beispiel #4
0
static void
__session_periodic_cb(struct ev_loop *loop, struct ev_periodic *w, int revents)
{
  GtkWidget *wgt = w->data;
  printf("%s:%d\n", __FUNCTION__, __LINE__);
  while (gdk_events_pending())
    {
      GdkEvent *ev = gdk_event_get();
      if (ev)
        {
          on_mainwin_frame_event(GTK_WINDOW(wgt), ev, NULL);
          gdk_event_free(ev);
        }
    }
  __invalidate(wgt, NULL, wgt);
}
Beispiel #5
0
/*!

  Wait for a mouse button click release and get the position of the
  image point were the click release occurs.  The button used to click is
  also set. Same method as getClick(unsigned int&, unsigned int&,
  vpMouseButton::vpMouseButtonType &, bool).

  \param ip [out] : Position of the clicked image point.

  \param button [in] : Button used to click.

  \param blocking [in] : true for a blocking behaviour waiting a mouse
  button click, false for a non blocking behaviour.

  \return 
  - true if a button was clicked. This is always the case if blocking is set 
    to \e true.
  - false if no button was clicked. This can occur if blocking is set
    to \e false.

  \sa getClick(vpImagePoint &, vpMouseButton::vpMouseButtonType &, bool)

*/
bool
vpDisplayGTK::getClickUp(vpImagePoint &ip,
                         vpMouseButton::vpMouseButtonType& button,
                         bool blocking)
{
  bool ret = false;

  if ( displayHasBeenInitialized ) {

    //flushDisplay() ;
     double u, v ;
    do {
       GdkEvent *ev = NULL;
       while ((ev = gdk_event_get())!=NULL){
        if ( ev->any.window == widget->window  
	     && ev->type == GDK_BUTTON_RELEASE) {
          u = ((GdkEventButton *)ev)->x ;
          v = ((GdkEventButton *)ev)->y ;
	  ip.set_u( u );
	  ip.set_v( v );

          switch ( ( int ) ( ( GdkEventButton * ) ev )->button ) {
            case 1:
              button = vpMouseButton::button1; break;
            case 2:
              button = vpMouseButton::button2; break;
            case 3:
              button = vpMouseButton::button3; break;
          }
          ret = true ;
        }
        gdk_event_free(ev) ;
      }
      if (blocking){
        flushDisplay();
        vpTime::wait(100);
      }

    } while ( ret == false && blocking == true);
  }
  else {
    vpERROR_TRACE ( "GTK not initialized " ) ;
    throw ( vpDisplayException ( vpDisplayException::notInitializedError,
                                 "GTK not initialized" ) ) ;
  }
  return ret;
}
Beispiel #6
0
/* dir is either ZOOM_IN, ZOOM_OUT or ZOOM_FULL which are defined in globals.h */
void
a_zoom(GschemToplevel *w_current, GschemPageView *page_view, int dir, int selected_from)
{
  g_return_if_fail (page_view != NULL);

  GschemPageGeometry *geometry = gschem_page_view_get_page_geometry (page_view);
  g_return_if_fail (geometry != NULL);

  double world_pan_center_x,world_pan_center_y,relativ_zoom_factor = - 1;
  int start_x, start_y;
  double top, bottom, right, left;


  /* NB: w_current->zoom_gain is a percentage increase */
  switch(dir) {
  case(ZOOM_IN):
    relativ_zoom_factor = (100.0 + w_current->zoom_gain) / 100.0;
    break;

  case(ZOOM_OUT):
    relativ_zoom_factor = 100.0 / (100.0 + w_current->zoom_gain);
    break;

  case(ZOOM_FULL):
    /* indicate the zoom full with a negative zoomfactor */
    relativ_zoom_factor = -1;
    break;
  }

  /* calc center: either "mouse_to_world" or center=center or a
     virtual center if warp_cursor is disabled */
  if (w_current->zoom_with_pan == TRUE && selected_from == HOTKEY) {
    if (!x_event_get_pointer_position(w_current, FALSE,
				      &start_x, &start_y))
      return;
    if ( w_current->warp_cursor ) {
      world_pan_center_x = start_x;
      world_pan_center_y = start_y;
    } else {
      left = ((geometry->viewport_left - start_x) * (1/relativ_zoom_factor) + start_x);
      right = ((geometry->viewport_right - start_x) * (1/relativ_zoom_factor) + start_x);
      top = ((geometry->viewport_top - start_y) * (1/relativ_zoom_factor) + start_y);
      bottom = ((geometry->viewport_bottom - start_y) * (1/relativ_zoom_factor) + start_y);
      world_pan_center_x = (right + left) / 2;
      world_pan_center_y = (top + bottom) / 2;
    }
  } else {
    world_pan_center_x = (double) (geometry->viewport_left + geometry->viewport_right) / 2;
    world_pan_center_y = (double) (geometry->viewport_top + geometry->viewport_bottom) / 2;
  }

#if DEBUG
  printf("relative zoomfactor: %E\n", relativ_zoom_factor);
  printf("new center: x: %E, y: %E \n",
         world_pan_center_x, world_pan_center_y);
#endif


  /* calculate new window and draw it */
  gschem_page_view_pan_general (page_view,
                                world_pan_center_x,
                                world_pan_center_y,
                                relativ_zoom_factor);

  /* Before warping the cursor, filter out any consecutive scroll events
   * from the event queue.  If the program receives more than one scroll
   * event before it can process the first one, then the globals mouse_x
   * and mouse_y won't contain the proper mouse position,
   * because the handler for the mouse moved event needs to
   * run first to set these values.
   */
  GdkEvent *topEvent = gdk_event_get();
  while( topEvent != NULL ) {
    if( topEvent->type != GDK_SCROLL ) {
      gdk_event_put( topEvent );
      gdk_event_free( topEvent );
      break;
    }
    gdk_event_free( topEvent );
    topEvent = gdk_event_get();
  }

  /* warp the cursor to the right position */
  if (w_current->warp_cursor) {
     gschem_page_view_WORLDtoSCREEN (page_view,
                                     world_pan_center_x, world_pan_center_y,
                                     &start_x, &start_y);
     x_basic_warp_cursor (GTK_WIDGET (page_view), start_x, start_y);
  }
}
Beispiel #7
0
static VALUE
gdkevent_s_get(G_GNUC_UNUSED VALUE self)
{
    return GDKEVENT2RVAL(gdk_event_get());
}
Beispiel #8
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
gint
x_event_motion (GschemPageView *page_view, GdkEventMotion *event, GschemToplevel *w_current)
{
  PAGE *page = gschem_page_view_get_page (page_view);
  int w_x, w_y;
  int unsnapped_wx, unsnapped_wy;
  int skip_event=0;
  GdkEvent *test_event;

  g_return_val_if_fail ((w_current != NULL), 0);

  if (page == NULL) {
    return TRUE; /* terminate event */
  }

  w_current->SHIFTKEY   = (event->state & GDK_SHIFT_MASK  ) ? 1 : 0;
  w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
  w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;

#if DEBUG
  /*  printf("MOTION!\n");*/
#endif

#ifdef HAVE_LIBSTROKE
  if (DOING_STROKE == TRUE) {
    x_stroke_record (w_current, event->x, event->y);
    return(0);
  }
#endif /* HAVE_LIBSTROKE */

  /* skip the moving event if there are other moving events in the
     gdk event queue (Werner)
     Only skip the event if is the same event and no buttons or modifier
     keys changed*/
  if ((test_event = gdk_event_get()) != NULL) {
    if (test_event->type == GDK_MOTION_NOTIFY
        && ((GdkEventMotion *) test_event)->state == event->state) {
      skip_event= 1;
    }
    gdk_event_put(test_event); /* put it back in front of the queue */
    gdk_event_free(test_event);
    if (skip_event == 1)
      return 0;
  }

  gschem_page_view_SCREENtoWORLD (page_view, (int) event->x, (int) event->y,
                                  &unsnapped_wx, &unsnapped_wy);
  w_x = snap_grid (w_current, unsnapped_wx);
  w_y = snap_grid (w_current, unsnapped_wy);

  if (w_current->cowindow) {
    coord_display_update(w_current, (int) event->x, (int) event->y);
  }

  gschem_page_view_pan_motion (page_view, w_current->mousepan_gain, (int) event->x, (int) event->y);

  /* Huge switch statement to evaluate state transitions. Jump to
   * end_motion label to escape the state evaluation rather
   * than returning from the function directly. */
  scm_dynwind_begin ((scm_t_dynwind_flags) 0);
  g_dynwind_window (w_current);

  if (w_current->inside_action) {
    if (page->place_list != NULL) {
      switch(w_current->event_state) {
        case (COPYMODE)   :
        case (MCOPYMODE)  :
        case (COMPMODE)   :
        case (PASTEMODE)  :
        case (TEXTMODE)   : o_place_motion (w_current, w_x, w_y); break;
        case (MOVEMODE)   : o_move_motion (w_current, w_x, w_y); break;
        default: break;
      }
    } else {
      switch(w_current->event_state) {
        case (ARCMODE)    : o_arc_motion (w_current, w_x, w_y, ARC_RADIUS); break;
        case (BOXMODE)    : o_box_motion  (w_current, w_x, w_y); break;
        case (BUSMODE)    : o_bus_motion (w_current, w_x, w_y); break;
        case (CIRCLEMODE) : o_circle_motion (w_current, w_x, w_y); break;
        case (LINEMODE)   : o_line_motion (w_current, w_x, w_y); break;
        case (NETMODE)    : o_net_motion (w_current, w_x, w_y); break;
        case (PATHMODE)   : o_path_motion (w_current, w_x, w_y); break;
        case (PICTUREMODE): o_picture_motion (w_current, w_x, w_y); break;
        case (PINMODE)    : o_pin_motion (w_current, w_x, w_y); break;
        case (GRIPS)      : o_grips_motion(w_current, w_x, w_y); break;
        case (SBOX)       : o_select_box_motion (w_current, unsnapped_wx, unsnapped_wy); break;
        case (ZOOMBOX)    : a_zoom_box_motion (w_current, unsnapped_wx, unsnapped_wy); break;
        case (SELECT)     : o_select_motion (w_current, w_x, w_y); break;
        default: break;
      }
    }
  } else {
    switch(w_current->event_state) {
      case(NETMODE)    :   o_net_start_magnetic(w_current, w_x, w_y); break;
      default: break;
    }
  }

  scm_dynwind_end ();

  return(0);
}
Beispiel #9
0
int main(int argc, char **argv)
#endif
{
    char execute[256];
#ifndef GKRELLM_BFM
    int proximity = 0;
    int ch;
#endif
#ifdef FPS
    int f, o;
    time_t y;
#endif
#ifdef PRO
    int cnt = 25000;
#endif

#ifndef GKRELLM_BFM
    GdkEvent *event;
#endif

#ifdef FPS
    o = f = y = 0;
#endif

    /* initialize GDK */
#ifndef GKRELLM_BFM
    if (!gdk_init_check(&argc, &argv)) {
	fprintf(stderr,
		"GDK init failed, bye bye.  Check \"DISPLAY\" variable.\n");
	exit(-1);
    }
#endif
    gdk_rgb_init();

    /* dynamically generate getopt string depending on compile options
     * we are going to borrow 256 char string from exec function, and
     * also build up the "compiled features" string */
    memset(execute, 0, 256);
    strcat(execute, "h");	/* help, always in */
#ifdef ENABLE_DUCK
    strcat(options, "DUCK ");
    strcat(execute, "d");
#ifdef UPSIDE_DOWN_DUCK
    strcat(options, "INVERT ");
    strcat(execute, "u");
#endif				/* UPSIDE_DOWN_DUCK */
#endif				/* ENABLE_DUCK */
#ifdef ENABLE_CPU
    strcat(options, "CPU ");
    strcat(execute, "c");
#endif				/* ENABLE_CPU */
#ifdef ENABLE_MEMSCREEN
    strcat(options, "MEMSCREEN ");
    strcat(execute, "pmk");
#endif				/* ENABLE_MEMSCREEN */
#ifdef ENABLE_FISH
    strcat(options, "FISH ");
    strcat(execute, "f");
    strcat(execute, "n::");
#endif
#ifdef ENABLE_TIME
    strcat(options, "TIME ");
    strcat(execute, "t");
#endif

#ifndef GKRELLM_BFM
    /* command line options */
    while ((ch = getopt(argc, argv, execute)) != -1) {
	switch (ch) {
#ifdef ENABLE_DUCK
	case 'd':
	    duck_enabled = 0;
	    break;
#ifdef UPSIDE_DOWN_DUCK
	case 'u':
	    upside_down_duck_enabled = 0;
	    break;
#endif				/* UPSIDE_DOWN_DUCK */
#endif				/* ENABLE_DUCK */
#ifdef ENABLE_CPU
	case 'c':
	    cpu_enabled = 0;
	    break;
#endif				/* ENABLE_CPU */
#ifdef ENABLE_MEMSCREEN
	case 'm':
	    memscreen_enabled = 0;
	    break;
	case 'p':
	    {
		/* no sense having -p if memscreen isn't compiled in, right?
		 * what we are going to do is to change the colors as follows:
		 * 
		 * (48,140,240) replaced with (158,196,237) - more pale blue
		 * (237,23,23) replaced with (0,255,233) */
		unsigned char *p = mem_screen;

		while (p < mem_screen + sizeof(mem_screen))
		    if (*p == 48) {	/* hopefully no other colors beginning with 48 */
			*p++ = 158;
			*p++ = 196;
			*p++ = 237;
		    } else if (*p == 237) {	/* hopefully no other colors beginning with 237 */
			*p++ = 0;
			*p++ = 255;
			*p++ = 233;
		    } else
			p += 3;

		p = load_screen;

		while (p < load_screen + sizeof(load_screen))
		    if (*p == 48) {	/* hopefully no other colors beginning with 48 */
			*p++ = 158;
			*p++ = 196;
			*p++ = 237;
		    } else
			p += 3;
	    }
	    break;
	case 'k':
	    memscreen_megabytes = 1;
	    break;
#endif				/* ENABLE_MEMSCREEN */

#ifdef ENABLE_FISH
	case 'f':
	    fish_enabled = 0;
	    break;
	case 'n':
	    fish_traffic = 1;
	    if (optarg)
	      network_interface = optarg;
	    break;
#endif
#ifdef ENABLE_TIME
	case 't':
	    time_enabled = 1;
	    break;
#endif
	default:
	    print_usage();
	    exit(-1);
	    break;
	}
    }

    argc -= optind;
    argv += optind;

#endif

    /* zero data structure */
    memset(&bm, 0, sizeof(bm));

#ifdef __FreeBSD__
    if (init_stuff())
	exit(-1);
#endif

    /* set default things, from Xresources or compiled-in defaults */
    bubblemon_session_defaults();

    /* create dockapp window. creates windows, allocates memory, etc */
    make_new_bubblemon_dockapp();

#ifdef ENABLE_FISH
    if(fish_enabled)
    {
	prepare_sprites();
    }
#endif

#ifndef GKRELLM_BFM
#ifdef PRO
    while (cnt--) {
#else
    while (1) {
#endif
	while (gdk_events_pending()) {
	    event = gdk_event_get();
	    if (event) {
		switch (event->type) {
		case GDK_DESTROY:
		    gdk_exit(0);
		    exit(0);
		    break;
		case GDK_BUTTON_PRESS:
		    if (event->button.button == 3) {
			bm.picture_lock = 1;
			break;
		    }
		    if (event->button.button <= argc) {
			snprintf(execute, 250, "%s &",
				 argv[event->button.button - 1]);
			system(execute);
		    }
		    break;
#if defined(ENABLE_CPU) || defined(ENABLE_MEMSCREEN)
		case GDK_ENTER_NOTIFY:
		    /* mouse in: make it darker, and eventually bring up
		     * meminfo */
		    proximity = 1;

		    bm.screen_type = get_screen_selection();
		    bm.picture_lock = 0;
		    break;
		case GDK_LEAVE_NOTIFY:
		    /* mouse out: back to light */
		    proximity = 0;
		    break;
#endif				/* ENABLE_CPU || ENABLE_MEMSCREEN */
		default:
		    break;
		}
	    }
	}
#ifndef PRO
	usleep(15000);
#else
	/* amazingly enough just calling this function takes insane
	 * amount of time.
	 usleep(0); */
#endif
	/* get system statistics */
	get_memory_load_percentage();
	/* update main rgb buffer: bm.rgb_buf */
	bubblemon_update(proximity);

/* *INDENT-OFF* */
#ifdef FPS
	/* render frames per second on bottom-right corner :)
	 * This is GCC-specific (functions inside functions)
	 * and very unoptimized. this is obfuscated 'cause its ugly */
    	f++;{int b;void q(int sx,int sy,int dx,int dy){int i,j;char *from,*to;
	for(j=0;j<8;j++){from=mem_screen+56*3*(sy+j)+sx*3;to=bm.rgb_buf+56*3*
	(dy+j)+dx*3;i=12;while(i--)*to++=*from++;}}b=o;if(b>=100){q((b/100)*4,
	60,43,46);b=b%100;}q((b/10)*4,60,47,46);q((b%10)*4,60,51,46);}if(time(
	NULL)!=y){o=f;f=0;y=time(NULL);}
#endif
/* *INDENT-ON* */

	/* actually draw the screen */
#ifndef BLACKBOX
	gdk_draw_rgb_image(bm.win, bm.gc, 4, 4, 56, 56,
			   GDK_RGB_DITHER_NONE, bm.rgb_buf, 56 * 3);
#endif
	gdk_draw_rgb_image(bm.iconwin, bm.gc, 4, 4, 56, 56,
			   GDK_RGB_DITHER_NONE, bm.rgb_buf, 56 * 3);
#ifdef ENABLE_MEMSCREEN
	/* update graph histories */
	if (memscreen_enabled)
	    roll_history();
#endif				/* ENABLE_MEMSCREEN */
    }
#endif
    return 0;
}				/* main */
Beispiel #10
0
/*********************************************
* OpenAsReferenceImage関数                   *
* 参考用画像を開く                           *
* 引数                                       *
* file_path	: ファイルのパス                 *
* reference	: 参考用画像表示ウィンドウの情報 *
*********************************************/
void OpenAsReferenceImage(char* file_path, REFERENCE_WINDOW* reference)
{
	// アプリケーションを管理する構造体のアドレス
	APPLICATION *app = reference->app;
	// ピクセルデータ取得用
	GdkPixbuf *pixbuf;
	// 拡張子判定用
	gchar *str;
	// ファイル名
	gchar *file_name;

	// 拡張子取得
	str = file_path + strlen(file_path) - 1;
	while(*str != '.' && str > file_path)
	{
		str--;
	}

	// ファイル名取得
	file_name = file_path + strlen(file_path) - 1;
	while(*file_name != '/' && *file_name != '\\' && file_name > file_path)
	{
		file_name--;
	}
	if(file_name != file_path)
	{
		file_name++;
	}

	if(StringCompareIgnoreCase(str, ".kab") == 0)
	{
		// システムの文字コードへ変換
		gchar *system_path = g_locale_from_utf8(file_path, -1, NULL, NULL, NULL);
		FILE *fp = fopen(system_path, "rb");
		// ファイルサイズ
		size_t data_size;
		// 読込中メッセージのID
		guint context_id, message_id;
		// 表示イベント処理用
		GdkEvent *queued_event;
		// 合成したレイヤー
		LAYER *mixed;

		g_free(system_path);

		if(fp == NULL)
		{
			return;
		}

		// 読込中のメッセージを表示
		context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(app->status_bar), "Loading");
		message_id = gtk_statusbar_push(GTK_STATUSBAR(app->status_bar),
			context_id, app->labels->window.loading);
		// イベントを回してメッセージを表示
#if GTK_MAJOR_VERSION <= 2
		gdk_window_process_updates(app->status_bar->window, TRUE);
#else
		gdk_window_process_updates(gtk_widget_get_window(app->status_bar), TRUE);
#endif

		while(gdk_events_pending() != FALSE)
		{
			queued_event = gdk_event_get();
			gtk_main_iteration();
			if(queued_event != NULL)
			{
#if GTK_MAJOR_VERSION <= 2
				if(queued_event->any.window == app->status_bar->window
#else
				if(queued_event->any.window == gtk_widget_get_window(app->status_bar)
#endif
					&& queued_event->any.type == GDK_EXPOSE)
				{
					gdk_event_free(queued_event);
					break;
				}
				else
				{
					gdk_event_free(queued_event);
				}
			}
		}

		(void)fseek(fp, 0, SEEK_END);
		data_size = (size_t)ftell(fp);
		rewind(fp);

		mixed = ReadOriginalFormatMixedData(fp, (stream_func_t)fread, data_size, app, file_name);
		if(mixed != NULL)
		{
			uint8 *pixels = (uint8*)MEM_ALLOC_FUNC(mixed->stride * mixed->height);
			(void)memcpy(pixels, mixed->pixels, mixed->stride * mixed->height);
			AddReferenceImage(reference, file_name, pixels,
				mixed->width, mixed->height, mixed->stride, mixed->channel);

			cairo_destroy(mixed->cairo_p);
			cairo_surface_destroy(mixed->surface_p);
			MEM_FREE_FUNC(mixed->name);

			MEM_FREE_FUNC(mixed->pixels);

			MEM_FREE_FUNC(mixed);
		}
	}
Beispiel #11
0
/**
 * input_sdl_get_key(): Get a key. (Used for controller configuration.)
 * @return Key value.
 */
uint16_t input_sdl_get_key(void)
{
	// TODO: Optimize this function.
	GdkEvent *event;
	
	// Update the UI.
	GensUI_update();
	
	// Save the current SDL joystick state.
	input_sdl_joystate_t prev_joystate[INPUT_SDL_MAX_JOYSTICKS];
	memcpy(prev_joystate, input_sdl_joystate, sizeof(prev_joystate));
	
	// Poll for keypresses.
	while (!input_sdl_update())
	{
		// Check if any joystick states have changed.
		int js;
		for (js = 0; js < input_sdl_num_joysticks; js++)
		{
			int i, num_items;
			input_sdl_joystate_t *cur_joy = &input_sdl_joystate[js];
			input_sdl_joystate_t *prev_joy = &prev_joystate[js];
			
			// Check buttons.
			num_items = SDL_JoystickNumButtons(input_sdl_joys[js]);
			if (num_items > INPUT_JOYSTICK_MAX_BUTTONS)
				num_items = INPUT_JOYSTICK_MAX_BUTTONS;
			
			for (i = 0; i < num_items; i++)
			{
				if (!prev_joy->buttons[i] && cur_joy->buttons[i])
				{
					// Button pressed.
					return INPUT_GETKEY_BUTTON(js, i);
				}
			}
			
			// Check axes.
			num_items = SDL_JoystickNumAxes(input_sdl_joys[js]);
			if (num_items > INPUT_JOYSTICK_MAX_AXES)
				num_items = INPUT_JOYSTICK_MAX_AXES;
			
			for (i = 0; i < num_items; i++)
			{
				if (prev_joy->axes[i] == INPUT_SDL_JOYSTATE_AXIS_CENTER &&
				    cur_joy->axes[i] != INPUT_SDL_JOYSTATE_AXIS_CENTER)
				{
					// Axis moved.
					// NOTE: Axis values are different!
					// * input_sdl axes: 0 == center; 1 == negative; 2 == positive
					// * Key values:     0 == negative, 1 == positive
					return INPUT_GETKEY_AXIS(js, i, (cur_joy->axes[i] - 1));
				}
			}
			
			// Check POV hats. (Needed on Ubuntu 9.04+; maybe 8.10, too.)
			num_items = SDL_JoystickNumHats(input_sdl_joys[js]);
			if (num_items > INPUT_JOYSTICK_MAX_POVHATS)
				num_items = INPUT_JOYSTICK_MAX_POVHATS;
			
			for (i = 0; i < num_items; i++)
			{
				if (prev_joy->povhats[i] == SDL_HAT_CENTERED &&
				    cur_joy->povhats[i] != SDL_HAT_CENTERED)
				{
					// POV hat moved.
					int povHatDirection;
					
					if (cur_joy->povhats[i] & SDL_HAT_UP)
						povHatDirection = INPUT_JOYSTICK_POVHAT_UP;
					else if (cur_joy->povhats[i] & SDL_HAT_RIGHT)
						povHatDirection = INPUT_JOYSTICK_POVHAT_RIGHT;
					else if (cur_joy->povhats[i] & SDL_HAT_DOWN)
						povHatDirection = INPUT_JOYSTICK_POVHAT_DOWN;
					else if (cur_joy->povhats[i] & SDL_HAT_LEFT)
						povHatDirection = INPUT_JOYSTICK_POVHAT_LEFT;
					else
						continue;
					
					return INPUT_GETKEY_POVHAT_DIRECTION(js, i, povHatDirection);
				}
			}
		}
		
		// Check if a GDK key press occurred.
		event = gdk_event_get();
		if (event && event->type == GDK_KEY_PRESS)
			return input_sdl_gdk_to_gens_keyval(event->key.keyval);
		
		// Save the current SDL joystick state.
		memcpy(prev_joystate, input_sdl_joystate, sizeof(prev_joystate));
		
		// Sleep for 1 ms.
		usleep(1000);
		
		// Make sure the "Controller Configuration" window is still configuring.
		if (!cc_window_is_configuring)
			break;
	}
	
	// No key returned.
	return 0;
}
Beispiel #12
0
static VALUE
gdkevent_s_get(G_GNUC_UNUSED VALUE self)
{
    return make_gdkevent(gdk_event_get());
}