⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkinput-win32.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 3 页
字号:
		       * we convert to x and y tilt in the -1000..1000 range		       */		      gdkdev->axes[k].xresolution =			gdkdev->axes[k].resolution = 1000;		      gdkdev->axes[k].xmin_value =			gdkdev->axes[k].min_value = -1000;		      gdkdev->axes[k].xmax_value =			gdkdev->axes[k].max_value = 1000;		      gdkdev->info.axes[k].use = axis;		      gdkdev->info.axes[k].min = -1000;		      gdkdev->info.axes[k].max = 1000;		      k++;		    }		}	      gdkdev->info.num_keys = 0;	      gdkdev->info.keys = NULL;	      GDK_NOTE (INPUT,			g_print ("device: (%d) %s axes: %d\n",				 cursorix,				 gdkdev->info.name,				 gdkdev->info.num_axes));	      for (i = 0; i < gdkdev->info.num_axes; i++)		GDK_NOTE (INPUT,			  g_print ("...axis %d: %d--%d@%d (%d--%d@%d)\n",				   i,				   gdkdev->axes[i].xmin_value, 				   gdkdev->axes[i].xmax_value, 				   gdkdev->axes[i].xresolution, 				   gdkdev->axes[i].min_value, 				   gdkdev->axes[i].max_value, 				   gdkdev->axes[i].resolution));	      _gdk_input_devices = g_list_append (_gdk_input_devices,						 gdkdev);	    }	}    }}static voiddecode_tilt (gint   *axis_data,	     AXIS   *axes,	     PACKET *packet){  /* As I don't have a tilt-sensing tablet,   * I cannot test this code.   */    double az, el;  az = TWOPI * packet->pkOrientation.orAzimuth /    (axes[0].axResolution / 65536.);  el = TWOPI * packet->pkOrientation.orAltitude /    (axes[1].axResolution / 65536.);    /* X tilt */  axis_data[0] = cos (az) * cos (el) * 1000;  /* Y tilt */  axis_data[1] = sin (az) * cos (el) * 1000;}#endif /* HAVE_WINTAB */static voidgdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,				 GdkInputWindow   *input_window,				 gint             *axis_data,				 gdouble          *axis_out,				 gdouble          *x_out,				 gdouble          *y_out){  GdkWindowImplWin32 *impl, *root_impl;  int i;  int x_axis = 0;  int y_axis = 0;  double device_width, device_height;  double x_offset, y_offset, x_scale, y_scale;  impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (input_window->window)->impl);  for (i=0; i<gdkdev->info.num_axes; i++)    {      switch (gdkdev->info.axes[i].use)	{	case GDK_AXIS_X:	  x_axis = i;	  break;	case GDK_AXIS_Y:	  y_axis = i;	  break;	default:	  break;	}    }    device_width = gdkdev->axes[x_axis].max_value - 		   gdkdev->axes[x_axis].min_value;  device_height = gdkdev->axes[y_axis].max_value -                     gdkdev->axes[y_axis].min_value;  if (gdkdev->info.mode == GDK_MODE_SCREEN)     {      root_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl);      x_scale = root_impl->width / device_width;      y_scale = root_impl->height / device_height;      x_offset = - input_window->root_x;      y_offset = - input_window->root_y;    }  else				/* GDK_MODE_WINDOW */    {      double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /	(device_width*gdkdev->axes[x_axis].resolution);      if (device_aspect * impl->width >= impl->height)	{	  /* device taller than window */	  x_scale = impl->width / device_width;	  y_scale = (x_scale * gdkdev->axes[x_axis].resolution)	    / gdkdev->axes[y_axis].resolution;	  x_offset = 0;	  y_offset = -(device_height * y_scale - 			       impl->height)/2;	}      else	{	  /* window taller than device */	  y_scale = impl->height / device_height;	  x_scale = (y_scale * gdkdev->axes[y_axis].resolution)	    / gdkdev->axes[x_axis].resolution;	  y_offset = 0;	  x_offset = - (device_width * x_scale - impl->width)/2;	}    }  for (i=0; i<gdkdev->info.num_axes; i++)    {      switch (gdkdev->info.axes[i].use)	{	case GDK_AXIS_X:	  axis_out[i] = x_offset + x_scale*axis_data[x_axis];	  if (x_out)	    *x_out = axis_out[i];	  break;	case GDK_AXIS_Y:	  axis_out[i] = y_offset + y_scale*axis_data[y_axis];	  if (y_out)	    *y_out = axis_out[i];	  break;	default:	  axis_out[i] =	    (gdkdev->info.axes[i].max * (axis_data[i] - gdkdev->axes[i].min_value) +	     gdkdev->info.axes[i].min * (gdkdev->axes[i].max_value - axis_data[i])) /	    (gdkdev->axes[i].max_value - gdkdev->axes[i].min_value);	  break;	}    }}static voidgdk_input_get_root_relative_geometry (HWND w,				      int  *x_ret,				      int  *y_ret){  RECT rect;  GetWindowRect (w, &rect);  if (x_ret)    *x_ret = rect.left + _gdk_offset_x;  if (y_ret)    *y_ret = rect.top + _gdk_offset_y;}void_gdk_input_configure_event (GdkWindow         *window){  GdkInputWindow *input_window;  int root_x, root_y;  input_window = _gdk_input_window_find (window);  g_return_if_fail (window != NULL);  gdk_input_get_root_relative_geometry (GDK_WINDOW_HWND (window),					&root_x, &root_y);  input_window->root_x = root_x;  input_window->root_y = root_y;}void _gdk_input_enter_event (GdkWindow        *window){  GdkInputWindow *input_window;  int root_x, root_y;  input_window = _gdk_input_window_find (window);  g_return_if_fail (window != NULL);  gdk_input_get_root_relative_geometry (GDK_WINDOW_HWND (window), &root_x, &root_y);  input_window->root_x = root_x;  input_window->root_y = root_y;}/* * Get the currently active keyboard modifiers (ignoring the mouse buttons) * We could use gdk_window_get_pointer but that function does a lot of other * expensive things besides getting the modifiers. This code is somewhat based * on build_pointer_event_state from gdkevents-win32.c */static guintget_modifier_key_state (void){  guint state;    state = 0;  /* High-order bit is up/down, low order bit is toggled/untoggled */  if (GetKeyState (VK_CONTROL) < 0)    state |= GDK_CONTROL_MASK;  if (GetKeyState (VK_SHIFT) < 0)    state |= GDK_SHIFT_MASK;  if (GetKeyState (VK_MENU) < 0)    state |= GDK_MOD1_MASK;  if (GetKeyState (VK_CAPITAL) & 0x1)    state |= GDK_LOCK_MASK;  return state;}#ifdef HAVE_WINTABstatic guint ignore_core_timer = 0;static gbooleanignore_core_timefunc (gpointer data){  /* The delay has passed */  _gdk_input_ignore_core = FALSE;  ignore_core_timer = 0;  return FALSE; /* remove timeout */}/* * Set or unset the _gdk_input_ignore_core variable that tells GDK * to ignore events for the core pointer when the tablet is in proximity * The unsetting is delayed slightly so that if a tablet event arrives * just after proximity out, it does not cause a core pointer event * which e.g. causes GIMP to switch tools. */static voidset_ignore_core (gboolean ignore){  if (ignore)    {      _gdk_input_ignore_core = TRUE;      /* Remove any pending clear */      if (ignore_core_timer)        {	  g_source_remove (ignore_core_timer);	  ignore_core_timer = 0;	}    }  else    if (!ignore_core_timer)      ignore_core_timer = g_timeout_add (PROXIMITY_OUT_DELAY,					 ignore_core_timefunc, NULL);}#endif /* HAVE_WINTAB */gboolean _gdk_input_other_event (GdkEvent  *event,			MSG       *msg,			GdkWindow *window){#ifdef HAVE_WINTAB  GdkDisplay *display;  GdkWindowObject *obj, *grab_obj;  GdkInputWindow *input_window;  GdkDevicePrivate *gdkdev = NULL;  GdkEventMask masktest;  guint key_state;  POINT pt;  PACKET packet;  gint k;  gint x, y;  if (event->any.window != wintab_window)    {      g_warning ("_gdk_input_other_event: not wintab_window?");      return FALSE;    }  window = gdk_window_at_pointer (&x, &y);  if (window == NULL)    window = _gdk_parent_root;  g_object_ref (window);  display = gdk_drawable_get_display (window);  GDK_NOTE (EVENTS_OR_INPUT,	    g_print ("gdk_input_win32_other_event: window=%p (%d,%d)\n",		     GDK_WINDOW_HWND (window), x, y));    if (msg->message == WT_PACKET)    {      if (!WTPacket ((HCTX) msg->lParam, msg->wParam, &packet))	return FALSE;    }  obj = GDK_WINDOW_OBJECT (window);  switch (msg->message)    {    case WT_PACKET:      /* Don't produce any button or motion events while a window is being       * moved or resized, see bug #151090. */      if (_sizemove_in_progress)	{	  GDK_NOTE (EVENTS_OR_INPUT, g_print ("...ignored when moving/sizing\n"));	  return FALSE;	}      if (window == _gdk_parent_root && x_grab_window == NULL)	{	  GDK_NOTE (EVENTS_OR_INPUT, g_print ("...is root\n"));	  return FALSE;	}      if ((gdkdev = gdk_input_find_dev_from_ctx ((HCTX) msg->lParam,						 packet.pkCursor)) == NULL)	return FALSE;      if (gdkdev->info.mode == GDK_MODE_DISABLED)	return FALSE;            k = 0;      if (gdkdev->pktdata & PK_X)	gdkdev->last_axis_data[k++] = packet.pkX;      if (gdkdev->pktdata & PK_Y)	gdkdev->last_axis_data[k++] = packet.pkY;      if (gdkdev->pktdata & PK_NORMAL_PRESSURE)	gdkdev->last_axis_data[k++] = packet.pkNormalPressure;      if (gdkdev->pktdata & PK_ORIENTATION)	{	  decode_tilt (gdkdev->last_axis_data + k,		       gdkdev->orientation_axes, &packet);	  k += 2;	}      g_assert (k == gdkdev->info.num_axes);      if (HIWORD (packet.pkButtons) != TBN_NONE)	{	  /* Gdk buttons are numbered 1.. */	  event->button.button = 1 + LOWORD (packet.pkButtons);	  if (HIWORD (packet.pkButtons) == TBN_UP)	    {	      event->any.type = GDK_BUTTON_RELEASE;	      masktest = GDK_BUTTON_RELEASE_MASK;	      gdkdev->button_state &= ~(1 << LOWORD (packet.pkButtons));	    }	  else	    {	      event->any.type = GDK_BUTTON_PRESS;	      masktest = GDK_BUTTON_PRESS_MASK;	      gdkdev->button_state |= 1 << LOWORD (packet.pkButtons);	    }	}      else	{	  event->any.type = GDK_MOTION_NOTIFY;	  masktest = GDK_POINTER_MOTION_MASK;	  if (gdkdev->button_state & (1 << 0))	    masktest |= GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK;	  if (gdkdev->button_state & (1 << 1))	    masktest |= GDK_BUTTON_MOTION_MASK | GDK_BUTTON2_MOTION_MASK;	  if (gdkdev->button_state & (1 << 2))	    masktest |= GDK_BUTTON_MOTION_MASK | GDK_BUTTON3_MOTION_MASK;	}      /* See if input is grabbed */      /* FIXME: x_grab_owner_events should probably be handled somehow */      if (x_grab_window != NULL)	{	  grab_obj = GDK_WINDOW_OBJECT (x_grab_window);	  if (!GDK_WINDOW_IMPL_WIN32 (grab_obj->impl)->extension_events_selected	      || !(grab_obj->extension_events & masktest)	      || !(x_grab_mask && masktest))	    {	      GDK_NOTE (EVENTS_OR_INPUT, 			g_print ("...grabber doesn't want it\n"));	      return FALSE;	    }	  GDK_NOTE (EVENTS_OR_INPUT, g_print ("...to grabber\n"));	  g_object_ref(x_grab_window);	  g_object_unref(window);	  window = x_grab_window;	  obj = grab_obj;	}      /* Now we can check if the window wants the event, and       * propagate if necessary.       */    dijkstra:      if (!GDK_WINDOW_IMPL_WIN32 (obj->impl)->extension_events_selected	  || !(obj->extension_events & masktest))	{	  GDK_NOTE (EVENTS_OR_INPUT, g_print ("...not selected\n"));	  if (obj->parent == GDK_WINDOW_OBJECT (_gdk_parent_root))	    return FALSE;	  /* It is not good to propagate the extended events up to the parent	   * if this window wants normal (not extended) motion/button events */	  if (obj->event_mask & masktest)	    {	      GDK_NOTE (EVENTS_OR_INPUT, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -