示例#1
1
void
meta_cursor_tracker_get_pointer (MetaCursorTracker   *tracker,
                                 int                 *x,
                                 int                 *y,
                                 ClutterModifierType *mods)
{
  GdkDeviceManager *gmanager;
  GdkDevice *gdevice;
  GdkScreen *gscreen;

  gmanager = gdk_display_get_device_manager (gdk_display_get_default ());
  gdevice = gdk_device_manager_get_client_pointer (gmanager);

  gdk_device_get_position (gdevice, &gscreen, x, y);
  gdk_device_get_state (gdevice,
                        gdk_screen_get_root_window (gscreen),
                        NULL, (GdkModifierType*)mods);
}
示例#2
1
static void
get_pointer_position_gdk (int         *x,
                          int         *y,
                          int         *mods)
{
  GdkDeviceManager *gmanager;
  GdkDevice *gdevice;
  GdkScreen *gscreen;

  gmanager = gdk_display_get_device_manager (gdk_display_get_default ());
  gdevice = gdk_x11_device_manager_lookup (gmanager, META_VIRTUAL_CORE_POINTER_ID);

  gdk_device_get_position (gdevice, &gscreen, x, y);
  if (mods)
    gdk_device_get_state (gdevice,
                          gdk_screen_get_root_window (gscreen),
                          NULL, (GdkModifierType*)mods);
}
示例#3
0
void DragAndDropHandler::finishDrag(GdkDragContext* context)
{
#if GTK_CHECK_VERSION(3, 16, 0)
    // This can happen when attempting to call finish drag from webkitWebViewBaseDragEnd()
    // for a obsolete DnD operation that got previously cancelled in startDrag().
    if (m_dragContext.get() != context)
        return;

    if (!m_draggingSelectionData)
        return;

    m_dragContext = nullptr;
    m_draggingSelectionData = nullptr;
#else
    if (!m_draggingSelectionDataMap.remove(context))
        return;
#endif

    GdkDevice* device = gdk_drag_context_get_device(context);
    int x = 0, y = 0;
    gdk_device_get_window_at_position(device, &x, &y);
    int xRoot = 0, yRoot = 0;
    gdk_device_get_position(device, nullptr, &xRoot, &yRoot);
    m_page.dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
}
static void
move_locate_pointer_window (GsdLocatePointerData *data,
                            GdkScreen            *screen)
{
  cairo_region_t *region;
  gint cursor_x, cursor_y;

//
// gdk_window_get_pointer (gdk_screen_get_root_window (screen),
//                         &cursor_x, &cursor_y, NULL);
// use gdk_device_get_position instead of gdk_window_get_device_position
// 'coz we use root window here.
  GdkDisplay *display;
  GdkDeviceManager * device_manager;
  GdkDevice* pointer_device;

  display = gdk_window_get_display (data->window);
  device_manager = gdk_display_get_device_manager (display);
  pointer_device = gdk_device_manager_get_client_pointer (device_manager);
  gdk_device_get_position (pointer_device, NULL, &cursor_x, &cursor_y);
//

  gdk_window_move_resize (data->window,
                          cursor_x - WINDOW_SIZE / 2,
                          cursor_y - WINDOW_SIZE / 2,
                          WINDOW_SIZE, WINDOW_SIZE);

  /* allow events to happen through the window */
  region = cairo_region_create ();
  gdk_window_input_shape_combine_region (data->window, region, 0, 0);
  cairo_region_destroy (region);
}
示例#5
0
static gboolean
manager_maybe_grab_window (GSManager *manager,
                           GSWindow  *window)
{
        GdkDisplay *display;
        GdkScreen  *screen;
        int         monitor;
        int         x, y;
        gboolean    grabbed;

        display = gdk_display_get_default ();
#if GTK_CHECK_VERSION(3, 0, 0)
        GdkDeviceManager *device_manager = gdk_display_get_device_manager (display);
        GdkDevice *pointer = gdk_device_manager_get_client_pointer (device_manager);
        gdk_device_get_position (pointer, &screen, &x, &y);
#else
        gdk_display_get_pointer (display, &screen, &x, &y, NULL);
#endif
        monitor = gdk_screen_get_monitor_at_point (screen, x, y);

        gdk_flush ();
        grabbed = FALSE;
        if (gs_window_get_screen (window) == screen
            && gs_window_get_monitor (window) == monitor) {
                gs_debug ("Moving grab to %p", window);
                gs_grab_move_to_window (manager->priv->grab,
                                        gs_window_get_gdk_window (window),
                                        gs_window_get_screen (window),
                                        TRUE);
                grabbed = TRUE;
        }

        return grabbed;
}
示例#6
0
文件: pdfpres.c 项目: dwol/pdfPres
static void moveBeamerToMouseMonitor(void)
{
	GdkDisplay *dpy = NULL;
	GdkScreen *scr = NULL;
	GdkDeviceManager *dma = NULL;
	GdkDevice *cpo = NULL;
	GdkRectangle rect;
	int mx = -1, my = -1, mon = -1;

	/* Open default display. Then get the current position of the mouse
	 * cursor and the screen that cursor is on. */
	dpy = gdk_display_get_default();
	if (dpy == NULL)
	{
		/* Actually, this should not happen because we are already able
		 * to create windows on the default screen. */
		fprintf(stderr, "Could not get default display.\n");
		return;
	}
	dma = gdk_display_get_device_manager(dpy);
	cpo = gdk_device_manager_get_client_pointer(dma);
	gdk_device_get_position(cpo, &scr, &mx, &my);

	/* Get the number of the monitor at the current mouse position, as
	 * well as the geometry (offset, size) of that monitor. */
	mon = gdk_screen_get_monitor_at_point(scr, mx, my);
	gdk_screen_get_monitor_geometry(scr, mon, &rect);

	/* Move the beamer window to the upper left corner of the current
	 * monitor. */
	gtk_window_move(GTK_WINDOW(win_beamer), rect.x, rect.y);
}
示例#7
0
文件: util.c 项目: brassy/audacious
EXPORT void audgui_get_mouse_coords (GtkWidget * widget, int * x, int * y)
{
    if (widget)
    {
        int xwin, ywin;
        GdkRectangle alloc;

        GdkWindow * window = gtk_widget_get_window (widget);
        GdkDisplay * display = gdk_window_get_display (window);
        GdkDeviceManager * manager = gdk_display_get_device_manager (display);
        GdkDevice * device = gdk_device_manager_get_client_pointer (manager);

        gdk_window_get_device_position (window, device, & xwin, & ywin, NULL);
        gtk_widget_get_allocation (widget, & alloc);

        * x = xwin - alloc.x;
        * y = ywin - alloc.y;
    }
    else
    {
        GdkDisplay * display = gdk_display_get_default ();
        GdkDeviceManager * manager = gdk_display_get_device_manager (display);
        GdkDevice * device = gdk_device_manager_get_client_pointer (manager);
        gdk_device_get_position (device, NULL, x, y);
    }
}
示例#8
0
static gboolean
manager_maybe_grab_window (GSManager *manager,
                           GSWindow  *window)
{
	GdkDisplay *display;
	GdkDevice  *device;
	GdkMonitor *monitor;
	int         x, y;
	gboolean    grabbed;

	display = gdk_display_get_default ();
	device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
	gdk_device_get_position (device, NULL, &x, &y);
	monitor = gdk_display_get_monitor_at_point (display, x, y);

	gdk_display_flush (display);
	grabbed = FALSE;
	if (gs_window_get_display (window) == display &&
	    gs_window_get_monitor (window) == monitor)
	{
		gs_debug ("Initiate grab move to %p", window);
		gs_grab_move_to_window (manager->priv->grab,
		                        gs_window_get_gdk_window (window),
		                        gs_window_get_display (window),
		                        FALSE, FALSE);
		grabbed = TRUE;
	}

	return grabbed;
}
示例#9
0
static void
default_position_func (G_GNUC_UNUSED PopupContainer *container, gint *out_x, gint *out_y)
{
	GdkDeviceManager *manager;
	GdkDevice *pointer;
	GtkWidget *widget;
	widget = GTK_WIDGET (container);
	manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
	pointer = gdk_device_manager_get_client_pointer (manager);
	gdk_device_get_position (pointer, NULL, out_x, out_y);
}
示例#10
0
void DragAndDropHandler::finishDrag(GdkDragContext* context)
{
    if (!m_draggingDataObjects.remove(context))
        return;

    GdkDevice* device = gdk_drag_context_get_device(context);
    int x = 0, y = 0;
    gdk_device_get_window_at_position(device, &x, &y);
    int xRoot = 0, yRoot = 0;
    gdk_device_get_position(device, nullptr, &xRoot, &yRoot);
    m_page.dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
}
示例#11
0
static void
gstyle_eyedropper_event_get_root_coords (GstyleEyedropper *self,
                                         GdkEvent         *event,
                                         gint             *x_root,
                                         gint             *y_root)
{
  GdkSeat *seat;
  GdkDevice *pointer;

  seat = gdk_event_get_seat (event);
  pointer = gdk_seat_get_pointer (seat);
  gdk_device_get_position (pointer, NULL, x_root, y_root);
}
示例#12
0
int UScreen::GetMonitorWithMouse() const
{
  GdkDevice* device;
  GdkDisplay *display;
  int x;
  int y;

  display = gdk_display_get_default();
  device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(display));

  gdk_device_get_position(device, nullptr, &x, &y);

  return GetMonitorAtPosition(x, y);
}
示例#13
0
GdkMonitor *
gimp_get_monitor_at_pointer (void)
{
  GdkDisplay *display;
  GdkSeat    *seat;
  gint        x, y;

  display = gdk_display_get_default ();
  seat = gdk_display_get_default_seat (display);

  gdk_device_get_position (gdk_seat_get_pointer (seat),
                           NULL, &x, &y);

  return gdk_display_get_monitor_at_point (display, x, y);
}
示例#14
0
static void
get_pointer_position_gdk (int         *x,
                          int         *y,
                          int         *mods)
{
  GdkSeat *gseat;
  GdkDevice *gdevice;
  GdkScreen *gscreen;

  gseat = gdk_display_get_default_seat (gdk_display_get_default ());
  gdevice = gdk_seat_get_pointer (gseat);

  gdk_device_get_position (gdevice, &gscreen, x, y);
  if (mods)
    gdk_device_get_state (gdevice,
                          gdk_screen_get_root_window (gscreen),
                          NULL, (GdkModifierType*)mods);
}
示例#15
0
static void
gstyle_eyedropper_screen_size_changed_cb (GstyleEyedropper *self,
                                          GdkScreen        *screen)
{
  GdkDevice *pointer;
  gint x;
  gint y;

  g_assert (GSTYLE_IS_EYEDROPPER (self));
  g_assert (GDK_IS_SCREEN (screen));

  self->screen_width = gdk_screen_get_width (screen);
  self->screen_height = gdk_screen_get_height (screen);

  pointer = gdk_seat_get_pointer (self->seat);
  gdk_device_get_position (pointer, NULL, &x, &y);
  gstyle_eyedropper_draw_zoom_area (self, x, y);
}
示例#16
0
static GSWindow *
find_window_at_pointer (GSManager *manager)
{
	GdkDisplay *display;
	GdkDevice  *device;
	GdkMonitor *monitor;
	int         x, y;
	GSWindow   *window;
	GSList     *l;

	display = gdk_display_get_default ();

	device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
	gdk_device_get_position (device, NULL, &x, &y);
	monitor = gdk_display_get_monitor_at_point (display, x, y);

	/* Find the gs-window that is on that monitor */
	window = NULL;
	for (l = manager->priv->windows; l; l = l->next)
	{
		GSWindow *win = GS_WINDOW (l->data);
		if (gs_window_get_display (win) == display &&
		    gs_window_get_monitor (win) == monitor)
		{
			window = win;
		}
	}

	if (window == NULL)
	{
		gs_debug ("WARNING: Could not find the GSWindow for display %s",
		          gdk_display_get_name (display));
		/* take the first one */
		window = manager->priv->windows->data;
	}
	else
	{
		gs_debug ("Requesting unlock for display %s",
		          gdk_display_get_name (display));
	}

	return window;
}
示例#17
0
static void
draw_zoom_area_cursor (GstyleEyedropper *self,
                       cairo_t          *cr)
{
  GdkDevice *pointer;
  gint x;
  gint y;

  g_assert (GSTYLE_IS_EYEDROPPER (self));

  pointer = gdk_seat_get_pointer (self->seat);
  gdk_device_get_position (pointer, NULL, &x, &y);

  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_set_line_width(cr, 1.0);
  cairo_arc (cr, self->offset_x, self->offset_y, RETICLE_DIAMETER, 0, 2 * M_PI);
  cairo_stroke (cr);
  cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
  cairo_arc (cr, self->offset_x, self->offset_y, RETICLE_DIAMETER - 1, 0, 2 * M_PI);
  cairo_stroke (cr);
}
示例#18
0
void remmina_file_update_screen_resolution(RemminaFile *remminafile)
{
#if GTK_VERSION == 3
	GdkDisplay *display;
	GdkDeviceManager *device_manager;
	GdkDevice *device;
#endif
	GdkScreen *screen;
	gchar *pos;
	gchar *resolution;
	gint x, y;
	gint monitor;
	GdkRectangle rect;

	resolution = g_strdup(remmina_file_get_string(remminafile, "resolution"));
	if (resolution == NULL || strchr(resolution, 'x') == NULL)
	{
#if GTK_VERSION == 3
		display = gdk_display_get_default();
		device_manager = gdk_display_get_device_manager(display);
		device = gdk_device_manager_get_client_pointer(device_manager);
		gdk_device_get_position(device, &screen, &x, &y);
#elif GTK_VERSION == 2
		gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL);
#endif
		monitor = gdk_screen_get_monitor_at_point(screen, x, y);
		gdk_screen_get_monitor_geometry(screen, monitor, &rect);
		remmina_file_set_int(remminafile, "resolution_width", rect.width);
		remmina_file_set_int(remminafile, "resolution_height", rect.height);
	}
	else
	{
		pos = strchr(resolution, 'x');
		*pos++ = '\0';
		remmina_file_set_int(remminafile, "resolution_width", MAX(100, MIN(4096, atoi(resolution))));
		remmina_file_set_int(remminafile, "resolution_height", MAX(100, MIN(4096, atoi(pos))));
	}
	g_free(resolution);
}
static void
timeline_frame_cb (GsdTimeline *timeline,
                   gdouble      progress,
                   gpointer     user_data)
{
  GsdLocatePointerData *data = (GsdLocatePointerData *) user_data;
  gint cursor_x, cursor_y;

  if (gtk_widget_is_composited (data->widget))
    {
      gdk_window_invalidate_rect (data->window, NULL, FALSE);
      data->progress = progress;
    }
  else if (progress >= data->progress + CIRCLES_PROGRESS_INTERVAL)
    {
      /* only invalidate window each circle interval */
      update_shape (data);
      gdk_window_invalidate_rect (data->window, NULL, FALSE);
      data->progress += CIRCLES_PROGRESS_INTERVAL;
    }

//
// gdk_window_get_pointer (gdk_screen_get_root_window (screen),
//                         &cursor_x, &cursor_y, NULL);
// use gdk_device_get_position instead of gdk_window_get_device_position
// 'coz we use root window here.
  GdkDisplay *display;
  GdkDeviceManager * device_manager;
  GdkDevice* pointer_device;

  display = gdk_window_get_display (data->window);
  device_manager = gdk_display_get_device_manager (display);
  pointer_device = gdk_device_manager_get_client_pointer (device_manager);
  gdk_device_get_position (pointer_device, NULL, &cursor_x, &cursor_y);
//
  gdk_window_move (data->window,
                   cursor_x - WINDOW_SIZE / 2,
                   cursor_y - WINDOW_SIZE / 2);
}
示例#20
0
static gboolean
gstyle_eyedropper_key_pressed_cb (GstyleEyedropper *self,
                                  GdkEventKey      *event,
                                  GtkWindow        *window)
{
  GdkSeat *seat;
  GdkDevice *pointer;
  GdkDevice *keyboard;
  gint x, y;
  gint dx = 0;
  gint dy = 0;
  gint state;

  g_assert (GSTYLE_IS_EYEDROPPER (self));
  g_assert (event != NULL);
  g_assert (GTK_IS_WINDOW (window));

  state = (event->state & gtk_accelerator_get_default_mod_mask () & GDK_MOD1_MASK);
  switch (event->keyval)
    {
    case GDK_KEY_Escape:
      release_grab (self);
      return GDK_EVENT_STOP;
      break;

    case GDK_KEY_Up:
    case GDK_KEY_KP_Up:
      dy = (state == GDK_MOD1_MASK) ? -CURSOR_ALT_STEP : -1;
      break;

    case GDK_KEY_Down:
    case GDK_KEY_KP_Down:
      dy = (state == GDK_MOD1_MASK) ? CURSOR_ALT_STEP : 1;
      break;

    case GDK_KEY_Left:
    case GDK_KEY_KP_Left:
      dx = (state == GDK_MOD1_MASK) ? -CURSOR_ALT_STEP : -1;
      break;

    case GDK_KEY_Right:
    case GDK_KEY_KP_Right:
      dx = (state == GDK_MOD1_MASK) ? CURSOR_ALT_STEP : 1;
      break;

    case GDK_KEY_Page_Up:
    case GDK_KEY_KP_Page_Up:
      increase_zoom_factor (self);
      break;

    case GDK_KEY_Page_Down:
    case GDK_KEY_KP_Page_Down:
      decrease_zoom_factor (self);
      break;

    default:
      return GDK_EVENT_PROPAGATE;
    }

  keyboard = gdk_event_get_device ((GdkEvent *)event);
  seat = gdk_device_get_seat (keyboard);
  pointer = gdk_seat_get_pointer (seat);
  gdk_device_get_position (pointer, NULL, &x, &y);
  gdk_device_warp (pointer, self->screen, x + dx, y + dy);

  return GDK_EVENT_STOP;
}