Пример #1
0
static gboolean dt_iop_monochrome_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
  dt_iop_module_t *self = (dt_iop_module_t *)user_data;
  dt_iop_monochrome_gui_data_t *g = (dt_iop_monochrome_gui_data_t *)self->gui_data;
  dt_iop_monochrome_params_t *p = (dt_iop_monochrome_params_t *)self->params;
  if(g->dragging)
  {
    const int inset = DT_COLORCORRECTION_INSET;
    GtkAllocation allocation;
    gtk_widget_get_allocation(widget, &allocation);
    int width = allocation.width - 2 * inset, height = allocation.height - 2 * inset;
    const float mouse_x = CLAMP(event->x - inset, 0, width);
    const float mouse_y = CLAMP(height - 1 - event->y + inset, 0, height);
    p->a = PANEL_WIDTH * (mouse_x - width * 0.5f) / (float)width;
    p->b = PANEL_WIDTH * (mouse_y - height * 0.5f) / (float)height;
    gtk_widget_queue_draw(self->widget);
  }
  gint x, y;
#if GTK_CHECK_VERSION(3, 20, 0)
  gdk_window_get_device_position(event->window,
      gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(widget))),
      &x, &y, 0);
#else
  gdk_window_get_device_position(event->window,
                                 gdk_device_manager_get_client_pointer(
                                     gdk_display_get_device_manager(gdk_window_get_display(event->window))),
                                 &x, &y, NULL);
#endif
  return TRUE;
}
Пример #2
0
static gboolean _lib_filmstrip_size_handle_button_callback(GtkWidget *w, GdkEventButton *e, gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  dt_lib_filmstrip_t *d = (dt_lib_filmstrip_t *)self->data;

  if(e->button == 1)
  {
    if(e->type == GDK_BUTTON_PRESS)
    {
      /* store current  mousepointer position */
#if GTK_CHECK_VERSION(3, 20, 0)
      gdk_window_get_device_position(e->window,
                                     gdk_seat_get_pointer(gdk_display_get_default_seat(gdk_window_get_display(
                                         gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui))))),
                                     &d->size_handle_x, &d->size_handle_y, 0);
#else
      gdk_window_get_device_position(
          gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui)),
          gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(
              gdk_window_get_display(gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui))))),
          &d->size_handle_x, &d->size_handle_y, NULL);
#endif

      gtk_widget_get_size_request(d->filmstrip, NULL, &d->size_handle_height);
      d->size_handle_is_dragging = TRUE;
    }
    else if(e->type == GDK_BUTTON_RELEASE)
      d->size_handle_is_dragging = FALSE;
  }
  return TRUE;
}
Пример #3
0
static gboolean _lib_filmstrip_size_handle_motion_notify_callback(GtkWidget *w, GdkEventButton *e,
                                                                  gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  dt_lib_filmstrip_t *d = (dt_lib_filmstrip_t *)self->data;
  if(d->size_handle_is_dragging)
  {
    gint x, y, sx, sy;
#if GTK_CHECK_VERSION(3, 20, 0)
    gdk_window_get_device_position(e->window,
        gdk_seat_get_pointer(gdk_display_get_default_seat(
            gdk_window_get_display(gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui))))),
        &x, &y, 0);
#else
    gdk_window_get_device_position(
        gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui)),
        gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(
            gdk_window_get_display(gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui))))),
        &x, &y, NULL);
#endif

    gtk_widget_get_size_request(d->filmstrip, &sx, &sy);
    sy = CLAMP(d->size_handle_height + (d->size_handle_y - y), DT_PIXEL_APPLY_DPI(64),
               DT_PIXEL_APPLY_DPI(400));

    dt_conf_set_int("plugins/lighttable/filmstrip/height", sy);

    gtk_widget_set_size_request(d->filmstrip, -1, sy);

    return TRUE;
  }

  return FALSE;
}
Пример #4
0
static gboolean dt_iop_levels_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
  dt_iop_module_t *self = (dt_iop_module_t *)user_data;
  dt_iop_levels_gui_data_t *c = (dt_iop_levels_gui_data_t *)self->gui_data;
  dt_iop_levels_params_t *p = (dt_iop_levels_params_t *)self->params;
  const int inset = DT_GUI_CURVE_EDITOR_INSET;
  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);
  int height = allocation.height - 2 * inset, width = allocation.width - 2 * inset;
  if(!c->dragging)
  {
    c->mouse_x = CLAMP(event->x - inset, 0, width);
    c->drag_start_percentage = (p->levels[1] - p->levels[0]) / (p->levels[2] - p->levels[0]);
  }
  c->mouse_y = CLAMP(event->y - inset, 0, height);

  if(c->dragging)
  {
    if(c->handle_move >= 0 && c->handle_move < 3)
    {
      const float mx = (CLAMP(event->x - inset, 0, width)) / (float)width;

      dt_iop_levels_move_handle(self, c->handle_move, mx, p->levels, c->drag_start_percentage);
    }
    dt_dev_add_history_item(darktable.develop, self, TRUE);
  }
  else
  {
    c->handle_move = 0;
    const float mx = CLAMP(event->x - inset, 0, width) / (float)width;
    float dist = fabsf(p->levels[0] - mx);
    for(int k = 1; k < 3; k++)
    {
      float d2 = fabsf(p->levels[k] - mx);
      if(d2 < dist)
      {
        c->handle_move = k;
        dist = d2;
      }
    }
  }
  gtk_widget_queue_draw(widget);

  gint x, y;
#if GTK_CHECK_VERSION(3, 20, 0)
  gdk_window_get_device_position(event->window,
      gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(widget))),
      &x, &y, 0);
#else
  gdk_window_get_device_position(event->window,
                                 gdk_device_manager_get_client_pointer(
                                     gdk_display_get_device_manager(gdk_window_get_display(event->window))),
                                 &x, &y, NULL);
#endif
  return TRUE;
}
Пример #5
0
static cairo_region_t *
byzanz_layer_cursor_snapshot (ByzanzLayer *layer)
{
  ByzanzLayerCursor *clayer = BYZANZ_LAYER_CURSOR (layer);
  cairo_region_t *region, *area;
  int x, y;
  GdkDevice *device;
  GdkDeviceManager *device_manager;
  GdkDisplay *display;
  GdkWindow *window;

  window = layer->recorder->window;
  display = gdk_window_get_display (window);
  device_manager = gdk_display_get_device_manager (display);
  device = gdk_device_manager_get_client_pointer (device_manager);
  gdk_window_get_device_position (window, device, &x, &y, NULL);
  if (x == clayer->cursor_x &&
      y == clayer->cursor_y &&
      clayer->cursor_next == clayer->cursor)
    return NULL;

  region = cairo_region_create ();
  byzanz_recorder_invalidate_cursor (region, clayer->cursor, clayer->cursor_x, clayer->cursor_y);
  byzanz_recorder_invalidate_cursor (region, clayer->cursor_next, x, y);
  area = cairo_region_create_rectangle (&layer->recorder->area);
  cairo_region_intersect (region, area);
  cairo_region_destroy (area);

  clayer->cursor = clayer->cursor_next;
  clayer->cursor_x = x;
  clayer->cursor_y = y;
  byzanz_layer_cursor_setup_poll (clayer);

  return region;
}
Пример #6
0
static gboolean
pointer_on_link (TTXWindow *self, GtkWidget *w, GdkEvent *event,
	 unsigned *page, unsigned *subpage)
{
	GSList *cur;
	GdkWindow *win;
	GdkDevice *dev;
	guint x, y;

	dev = gdk_event_get_device (event);
	win = gtk_widget_get_window (w);

	gdk_window_get_device_position (win, dev, (int*)&x, (int*)&y, NULL);

	for (cur = self->priv->links; cur; cur = g_slist_next (cur)) {

		TTXLink *link;
		link = (TTXLink*)cur->data;

		if (link->left <= x && x <= link->right &&
		    link->top  <= y && y <= link-> bottom) {
			*page	 = link->page;
			*subpage = link->subpage;
			return TRUE;
		}
	}

	return FALSE;
}
Пример #7
0
void
ev_document_misc_get_pointer_position (GtkWidget *widget,
                                       gint      *x,
                                       gint      *y)
{
    GdkDeviceManager *device_manager;
    GdkDevice        *device_pointer;
    GdkRectangle      allocation;

    if (x)
        *x = -1;
    if (y)
        *y = -1;

    if (!gtk_widget_get_realized (widget))
        return;

    device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
    device_pointer = gdk_device_manager_get_client_pointer (device_manager);
    gdk_window_get_device_position (gtk_widget_get_window (widget),
                                    device_pointer,
                                    x, y, NULL);

    if (gtk_widget_get_has_window (widget))
        return;

    gtk_widget_get_allocation (widget, &allocation);
    if (x)
        *x -= allocation.x;
    if (y)
        *y -= allocation.y;
}
Пример #8
0
static void
gcal_event_widget_drag_begin (GtkWidget      *widget,
                              GdkDragContext *context)
{
  GcalEventWidget *self;
  cairo_surface_t *surface;
  GdkWindow *window;
  GdkDevice *device;
  gint x, y;
  GtkAllocation allocation;

  self = GCAL_EVENT_WIDGET (widget);
  window = gtk_widget_get_window (widget);
  device = gdk_drag_context_get_device (context);

  if (self->read_only)
    {
      gtk_drag_cancel (context);
      return;
    }

  /* Setup the drag n' drop icon */
  surface = get_dnd_icon (widget);

  gtk_drag_set_icon_surface (context, surface);

  /* reposition drag surface to the point the GCalEvent was */
  gtk_widget_get_allocation (widget, &allocation);
  gdk_window_get_device_position (window, device, &x, &y, NULL);
  gdk_drag_context_set_hotspot (context, x - allocation.x, y - allocation.y);

  g_clear_pointer (&surface, cairo_surface_destroy);
}
Пример #9
0
void
gw_spellcheck_record_mouse_cordinates (GwSpellcheck *spellcheck, 
                                       GdkEvent     *event)
{
    GwSpellcheckPrivate *priv;
    GtkWidget *toplevel;
    gint toplevel_x, toplevel_y;

    priv = spellcheck->priv;
    toplevel = GTK_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (priv->entry), GTK_TYPE_WINDOW));

    gdk_window_get_device_position (
      gtk_widget_get_window (GTK_WIDGET (priv->entry)),
      gdk_event_get_device (event),
      &toplevel_x, 
      &toplevel_y, 
      NULL
    );

    gtk_widget_translate_coordinates (
      toplevel, 
      GTK_WIDGET (priv->entry), 
      toplevel_x, 
      toplevel_y, 
      &priv->x, 
      &priv->y
    );
}
Пример #10
0
static void
menu_loaded_cb (GtkWidget   *widget,
                PanelWidget *panel_widget)
{
	GdkWindow *window;
	GdkRectangle rect;
	GdkDisplay *display;
	GdkSeat *seat;
	GdkDevice *device;

	g_signal_connect (widget, "destroy", G_CALLBACK (menu_destroy_cb), panel_widget);
	panel_toplevel_push_autohide_disabler (panel_widget->toplevel);

	window = gtk_widget_get_window (GTK_WIDGET (panel_widget));

	rect.x = 0;
	rect.y = 0;
	rect.width = 1;
	rect.height = 1;

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

	gdk_window_get_device_position (window, device,
	                                &rect.x, &rect.y,
	                                NULL);

	gtk_menu_popup_at_rect (GTK_MENU (widget), window, &rect,
	                        GDK_GRAVITY_SOUTH_EAST,
	                        GDK_GRAVITY_NORTH_WEST,
	                        NULL);
}
Пример #11
0
static gint 
timer_cb (EyesApplet *eyes_applet)
{
        GdkDisplay *display;
        GdkDeviceManager *device_manager;
        GdkDevice *device;
        gint x, y;
        gint pupil_x, pupil_y;
        gint i;

        display = gtk_widget_get_display (GTK_WIDGET (eyes_applet->applet));
        device_manager = gdk_display_get_device_manager (display);
        device = gdk_device_manager_get_client_pointer (device_manager);

        for (i = 0; i < eyes_applet->num_eyes; i++) {
		if (gtk_widget_get_realized (eyes_applet->eyes[i])) {
			gdk_window_get_device_position (gtk_widget_get_window (eyes_applet->eyes[i]), device, &x, &y, NULL);
			if ((x != eyes_applet->pointer_last_x[i]) || (y != eyes_applet->pointer_last_y[i])) { 

				calculate_pupil_xy (eyes_applet, x, y, &pupil_x, &pupil_y, eyes_applet->eyes[i]);
				draw_eye (eyes_applet, i, pupil_x, pupil_y);
	    	        
			        eyes_applet->pointer_last_x[i] = x;
			        eyes_applet->pointer_last_y[i] = y;
			}
		}
        }
        return TRUE;
}
Пример #12
0
void
populate_popup_cb(WebKitWebView *v, GtkMenu *m, void *c) {
    (void) c;
    gint context;

    if(!uzbl.gui.menu_items)
        return;

    /* check context */
    if((context = get_click_context()) == -1)
        return;

    WebKitHitTestResult *hit_test_result;
    GdkEventButton ev;
    gint x, y;
#if GTK_CHECK_VERSION (3, 0, 0)
    gdk_window_get_device_position (gtk_widget_get_window(GTK_WIDGET(v)),
        gdk_device_manager_get_client_pointer (
            gdk_display_get_device_manager (
                gtk_widget_get_display (GTK_WIDGET (v)))),
        &x, &y, NULL);
#else
    gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(v)), &x, &y, NULL);
#endif
    ev.x = x;
    ev.y = y;
    hit_test_result = webkit_web_view_get_hit_test_result(v, &ev);

    populate_context_menu(m, hit_test_result, context);

    g_object_unref(hit_test_result);
}
Пример #13
0
static gboolean
scribble_motion_notify_event (GtkWidget      *widget,
                              GdkEventMotion *event,
                              gpointer        data)
{
  int x, y;
  GdkModifierType state;

  if (surface == NULL)
    return FALSE; /* paranoia check, in case we haven't gotten a configure event */

  /* This call is very important; it requests the next motion event.
   * If you don't call gdk_window_get_pointer() you'll only get
   * a single motion event. The reason is that we specified
   * GDK_POINTER_MOTION_HINT_MASK to gtk_widget_set_events().
   * If we hadn't specified that, we could just use event->x, event->y
   * as the pointer location. But we'd also get deluged in events.
   * By requesting the next event as we handle the current one,
   * we avoid getting a huge number of events faster than we
   * can cope.
   */

  gdk_window_get_device_position (event->window, event->device, &x, &y, &state);

  if (state & GDK_BUTTON1_MASK)
    draw_brush (widget, x, y);

  /* We've handled it, stop processing */
  return TRUE;
}
Пример #14
0
/**
 * position within the sheet in pixel coordinates
 *
 * coordinates are clamped to grid if grid is enabled
 * see snap_to_grid
 * zero point : top left corner of the window (not widget!)
 *
 * @param x horizontal, left to right
 * @param y vertical, top to bottom
 * @returns wether the position could be detected properly
 *
 * @attention never call in event handlers!
 */
gboolean sheet_get_pointer_pixel (Sheet *sheet, gdouble *x, gdouble *y)
{
	GtkAdjustment *hadj = NULL, *vadj = NULL;
	gdouble x1, y1;
	gint _x, _y;
	GdkDeviceManager *device_manager;
	GdkDevice *device_pointer;
	GdkRectangle allocation;
	GdkDisplay *display;
	GdkWindow *window;

	// deprecated gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
	// replaced by a code copied from evince

	if (G_UNLIKELY (!sheet || !gtk_widget_get_realized (GTK_WIDGET (sheet)))) {
		NG_DEBUG ("Widget is not realized.");
		return FALSE;
	}

	display = gtk_widget_get_display (GTK_WIDGET (sheet));
	device_manager = gdk_display_get_device_manager (display);
	// gdk_device_manager_get_client_pointer
	// shall not be used within events
	device_pointer = gdk_device_manager_get_client_pointer (device_manager);
	window = gtk_widget_get_window (GTK_WIDGET (sheet));

	if (!window) {
		NG_DEBUG ("Window is not realized.");
		return FALSE;
	}
	// even though above is all defined the below will always return NUL for
	// unknown reason and _x and _y are populated as expected
	gdk_window_get_device_position (window, device_pointer, &_x, &_y, NULL);
#if 0
	if (!window) { //fails always
		NG_DEBUG ("Window does not seem to be realized yet?");
		return FALSE;
	}
#else
	NG_DEBUG ("\n%p %p %p %p %i %i\n\n", display, device_manager, device_pointer, window, _x, _y);
#endif

	gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);

	_x -= allocation.x;
	_y -= allocation.y;

	x1 = (gdouble)_x;
	y1 = (gdouble)_y;

	if (!sheet_get_adjustments (sheet, &hadj, &vadj))
		return FALSE;

	x1 += gtk_adjustment_get_value (hadj);
	y1 += gtk_adjustment_get_value (vadj);

	*x = x1;
	*y = y1;
	return TRUE;
}
Пример #15
0
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);
    }
}
Пример #16
0
static gboolean lowlight_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
  dt_iop_module_t *self = (dt_iop_module_t *)user_data;
  dt_iop_lowlight_gui_data_t *c = (dt_iop_lowlight_gui_data_t *)self->gui_data;
  dt_iop_lowlight_params_t *p = (dt_iop_lowlight_params_t *)self->params;
  const int inset = DT_IOP_LOWLIGHT_INSET;
  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);
  int height = allocation.height - 2 * inset, width = allocation.width - 2 * inset;
  if(!c->dragging) c->mouse_x = CLAMP(event->x - inset, 0, width) / (float)width;
  c->mouse_y = 1.0 - CLAMP(event->y - inset, 0, height) / (float)height;
  if(c->dragging)
  {
    *p = c->drag_params;
    if(c->x_move >= 0)
    {
      const float mx = CLAMP(event->x - inset, 0, width) / (float)width;
      if(c->x_move > 0 && c->x_move < DT_IOP_LOWLIGHT_BANDS - 1)
      {
        const float minx = p->transition_x[c->x_move - 1] + 0.001f;
        const float maxx = p->transition_x[c->x_move + 1] - 0.001f;
        p->transition_x[c->x_move] = fminf(maxx, fmaxf(minx, mx));
      }
    }
    else
    {
      dt_iop_lowlight_get_params(p, c->mouse_x, c->mouse_y + c->mouse_pick, c->mouse_radius);
    }
    dt_dev_add_history_item(darktable.develop, self, TRUE);
  }
  else if(event->y > height)
  {
    c->x_move = 0;
    float dist = fabs(p->transition_x[0] - c->mouse_x);
    for(int k = 1; k < DT_IOP_LOWLIGHT_BANDS; k++)
    {
      float d2 = fabs(p->transition_x[k] - c->mouse_x);
      if(d2 < dist)
      {
        c->x_move = k;
        dist = d2;
      }
    }
  }
  else
  {
    c->x_move = -1;
  }
  gtk_widget_queue_draw(widget);
  gint x, y;
  gdk_window_get_device_position(event->window,
                                 gdk_device_manager_get_client_pointer(
                                     gdk_display_get_device_manager(gdk_window_get_display(event->window))),
                                 &x, &y, NULL);
  return TRUE;
}
Пример #17
0
static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    int x = int(gdk_event->x);
    int y = int(gdk_event->y);

    if (gdk_event->is_hint)
    {
#ifdef __WXGTK3__
       gdk_window_get_device_position(gdk_event->window, gdk_event->device, &x, &y, NULL);
#else
       gdk_window_get_pointer(gdk_event->window, &x, &y, NULL);
#endif
    }

    if (!win->m_isDragging)
    {
        if (win->GetWindowStyle() & wxRESIZE_BORDER)
        {
            GdkCursor* cursor = NULL;
            GdkWindow* window = gtk_widget_get_window(widget);
            if ((x > win->m_width-14) && (y > win->m_height-14))
            {
                GdkDisplay* display = gdk_window_get_display(window);
                cursor = gdk_cursor_new_for_display(display, GDK_BOTTOM_RIGHT_CORNER);
            }
            gdk_window_set_cursor(window, cursor);
            if (cursor)
            {
#ifdef __WXGTK3__
                g_object_unref(cursor);
#else
                gdk_cursor_unref(cursor);
#endif
            }
        }
        return TRUE;
    }

    win->m_oldX = x - win->m_diffX;
    win->m_oldY = y - win->m_diffY;

    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
Пример #18
0
static gint 
timer_cb (EyesApplet *eyes_applet)
{
        GdkDisplay *display;
#if GTK_CHECK_VERSION (3, 20, 0)
        GdkSeat *seat;
#else
        GdkDeviceManager *device_manager;
        GdkDevice *device;
#endif
        gint x, y;
        gint pupil_x, pupil_y;
        gint i;

        display = gtk_widget_get_display (GTK_WIDGET (eyes_applet->applet));
#if GTK_CHECK_VERSION (3, 20, 0)
        seat = gdk_display_get_default_seat (display);
#else
        device_manager = gdk_display_get_device_manager (display);
        device = gdk_device_manager_get_client_pointer (device_manager);
#endif

        for (i = 0; i < eyes_applet->num_eyes; i++) {
		if (gtk_widget_get_realized (eyes_applet->eyes[i])) {
#if GTK_CHECK_VERSION (3, 20, 0)
            gdk_window_get_device_position (gtk_widget_get_window (eyes_applet->eyes[i]),
                                            gdk_seat_get_pointer (seat),
                                            &x, &y, NULL);
#else
			gdk_window_get_device_position (gtk_widget_get_window (eyes_applet->eyes[i]), device, &x, &y, NULL);
#endif
			if ((x != eyes_applet->pointer_last_x[i]) || (y != eyes_applet->pointer_last_y[i])) { 

				calculate_pupil_xy (eyes_applet, x, y, &pupil_x, &pupil_y, eyes_applet->eyes[i]);
				draw_eye (eyes_applet, i, pupil_x, pupil_y);
	    	        
			        eyes_applet->pointer_last_x[i] = x;
			        eyes_applet->pointer_last_y[i] = y;
			}
		}
        }
        return TRUE;
}
Пример #19
0
G_MODULE_EXPORT
gboolean chart_da_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
	gint x, y;  
	gdk_window_get_device_position (event->window, event->device, &x, &y, NULL);	
	      
	if (chart_set_end_scale (x, y))
		gtk_widget_queue_draw (chart_da);
  
	return TRUE;
}
Пример #20
0
void
_gtk_tooltip_focus_in (GtkWidget *widget)
{
  gint x, y;
  gboolean return_value = FALSE;
  GdkDisplay *display;
  GtkTooltip *tooltip;
  GdkDevice *device;

  /* Get current tooltip for this display */
  display = gtk_widget_get_display (widget);
  tooltip = g_object_get_data (G_OBJECT (display),
			       "gdk-display-current-tooltip");

  /* Check if keyboard mode is enabled at this moment */
  if (!tooltip || !tooltip->keyboard_mode_enabled)
    return;

  device = gtk_get_current_event_device ();

  if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
    device = gdk_device_get_associated_device (device);

  /* This function should be called by either a focus in event,
   * or a key binding. In either case there should be a device.
   */
  if (!device)
    return;

  if (tooltip->keyboard_widget)
    g_object_unref (tooltip->keyboard_widget);

  tooltip->keyboard_widget = g_object_ref (widget);

  gdk_window_get_device_position (gtk_widget_get_window (widget),
                                  device, &x, &y, NULL);

  return_value = gtk_tooltip_run_requery (&widget, tooltip, &x, &y);
  if (!return_value)
    {
      gtk_tooltip_hide_tooltip (tooltip);
      return;
    }

  if (!tooltip->current_window)
    {
      if (gtk_widget_get_tooltip_window (widget))
	tooltip->current_window = gtk_widget_get_tooltip_window (widget);
      else
	tooltip->current_window = GTK_WINDOW (GTK_TOOLTIP (tooltip)->window);
    }

  gtk_tooltip_show_tooltip (display);
}
Пример #21
0
static gboolean _lib_ratings_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event,
                                                    gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  dt_lib_ratings_t *d = (dt_lib_ratings_t *)self->data;
  gdk_window_get_device_position(event->window,
                                 gdk_device_manager_get_client_pointer(
                                     gdk_display_get_device_manager(gdk_window_get_display(event->window))),
                                 &d->pointerx, &d->pointery, NULL);
  gtk_widget_queue_draw(self->widget);
  return TRUE;
}
Пример #22
0
static gboolean
chat_text_view_event_cb (EmpathyChatTextView *view,
			 GdkEventMotion      *event,
			 GtkTextTag          *tag)
{
	static GdkCursor  *hand = NULL;
	static GdkCursor  *beam = NULL;
	GtkTextWindowType  type;
	GtkTextIter        iter;
	GdkWindow         *win;
	gint               x, y, buf_x, buf_y;

	type = gtk_text_view_get_window_type (GTK_TEXT_VIEW (view),
					      event->window);

	if (type != GTK_TEXT_WINDOW_TEXT) {
		return FALSE;
	}

	/* Get where the pointer really is. */
	win = gtk_text_view_get_window (GTK_TEXT_VIEW (view), type);
	if (!win) {
		return FALSE;
	}

	gdk_window_get_device_position (win, event->device, &x, &y, NULL);

	/* Get the iter where the cursor is at */
	gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), type,
					       x, y,
					       &buf_x, &buf_y);

	gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view),
					    &iter,
					    buf_x, buf_y);

	if (gtk_text_iter_has_tag (&iter, tag)) {
		if (!hand) {
			hand = gdk_cursor_new (GDK_HAND2);
			beam = gdk_cursor_new (GDK_XTERM);
		}
		gdk_window_set_cursor (win, hand);
	} else {
		if (!beam) {
			beam = gdk_cursor_new (GDK_XTERM);
		}
		gdk_window_set_cursor (win, beam);
	}

	return FALSE;
}
Пример #23
0
void		
sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y)
{
	GtkWidget        *widget;
	GtkAdjustment    *hadjustment;
	GtkAdjustment    *vadjustment;
	gdouble           value, x1, y1;
	gint              _x, _y;
	GdkDeviceManager *device_manager;
    GdkDevice        *device_pointer;
    GdkRectangle      allocation;


	// gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
	// replaced by a code copied from evince
	
    if (!gtk_widget_get_realized (GTK_WIDGET (sheet)))
    	return;
	
	device_manager = gdk_display_get_device_manager (
	                gtk_widget_get_display (GTK_WIDGET (sheet)));
    device_pointer = gdk_device_manager_get_client_pointer (device_manager);
    gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (sheet)),
                    device_pointer,
                    &_x, &_y, NULL);
	if (!gtk_widget_get_has_window (GTK_WIDGET (sheet)))
    	return;
	
	gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);
	
	_x -= allocation.x;
	_y -= allocation.y;

	x1 = (gdouble) _x;
	y1 = (gdouble) _y;
	
	widget = gtk_widget_get_parent (GTK_WIDGET (sheet));
	hadjustment =  gtk_scrolled_window_get_hadjustment (
	                 GTK_SCROLLED_WINDOW (widget));
	value = gtk_adjustment_get_value (hadjustment);

	x1 += value;
	vadjustment =  gtk_scrolled_window_get_vadjustment (
	                 GTK_SCROLLED_WINDOW (widget));
	value = gtk_adjustment_get_value (vadjustment);
	y1 += value;
	*x = x1;
	*y = y1;
	goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), x, y);
	snap_to_grid (sheet->grid, x, y);
}
Пример #24
0
/*
 * position within the sheet in pixel coordinates
 * coordinates are clamped to grid if grid is enabled
 * see snap_to_grid
 * zero point : top left corner of the window (not widget!)
 * x : horizontal, left to right
 * y : vertical, top to bottom
 * returns wether the position could be detected properly
 */
gboolean
sheet_get_pointer_pixel (Sheet *sheet, gdouble *x, gdouble *y)
{
	GtkAdjustment *hadj, *vadj;
	gdouble x1, y1;
	gint _x, _y;
	GdkDeviceManager *device_manager;
	GdkDevice *device_pointer;
	GdkRectangle allocation;


	// deprecated gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
	// replaced by a code copied from evince

	if (G_UNLIKELY (!sheet || !gtk_widget_get_realized (GTK_WIDGET (sheet)))) {
		NG_DEBUG ("widget not realized");
		return FALSE;
	}

	device_manager = gdk_display_get_device_manager (
			gtk_widget_get_display (GTK_WIDGET (sheet)));
	device_pointer = gdk_device_manager_get_client_pointer (device_manager);
	//FIXME add another check based on the following functions return val
	//FIXME gtkdoc says this shall not be used in event handlers
	gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (sheet)),
					device_pointer,
					&_x, &_y, NULL);

	if (!gtk_widget_get_has_window (GTK_WIDGET (sheet))) {
		NG_DEBUG ("some weird gtk window shit failed");
		return FALSE;
	}
	
	gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);

	_x -= allocation.x;
	_y -= allocation.y;

	x1 = (gdouble) _x;
	y1 = (gdouble) _y;

	if (!sheet_get_adjustments (sheet, &hadj, &vadj))
	      return FALSE;

	x1 += gtk_adjustment_get_value (hadj);
	y1 += gtk_adjustment_get_value (vadj);

	*x = x1;
	*y = y1;
	return TRUE;
}
Пример #25
0
static gboolean _lib_navigation_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event,
                                                       gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);
  _lib_navigation_set_position(self, event->x, event->y, allocation.width, allocation.height);
  gint x, y; // notify gtk for motion_hint.
  gdk_window_get_device_position(event->window,
                                 gdk_device_manager_get_client_pointer(
                                     gdk_display_get_device_manager(gdk_window_get_display(event->window))),
                                 &x, &y, NULL);
  return TRUE;
}
Пример #26
0
static gboolean on_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, struct UgtkScheduleForm* sform)
{
	gint        x, y;
	gchar*      string;
	cairo_t*    cr;
	GdkWindow*  gdkwin;
	GdkModifierType  mod;
	UgtkScheduleState  state;

	gdkwin = gtk_widget_get_window (widget);
	gdk_window_get_device_position (gdkwin, event->device, &x, &y, &mod);
	x -= sform->drawing_offset;
	x /= GRID_WIDTH_LINE;
	y /= GRID_HEIGHT_LINE;
	if (x < 0 || y < 0 || x >= 24 || y >= 7) {
		// clear time_tips
		gtk_label_set_text (sform->time_tips, "");
		return FALSE;
	}
	// update time_tips
	string = g_strdup_printf ("%s, %.2d:00 - %.2d:59",
			gettext (week_days[y]), x, x);
	gtk_label_set_text (sform->time_tips, string);
	g_free (string);
	// if no button press
	if ((mod & GDK_BUTTON1_MASK) == 0)
		return FALSE;

	state = sform->last_state;
	sform->state[y][x] = state;
	// cairo
	cr = gdk_cairo_create (gdkwin);
	cairo_rectangle (cr,
			sform->drawing_offset, 0,
			GRID_WIDTH_ALL, GRID_HEIGHT_ALL);
	cairo_clip (cr);
	cairo_set_source_rgb (cr,
			colors [state][0],
			colors [state][1],
			colors [state][2]);
	cairo_rectangle (cr,
			(gdouble)x * GRID_WIDTH_LINE  + 1.0 + 0.5 + sform->drawing_offset,
			(gdouble)y * GRID_HEIGHT_LINE + 1.0 + 0.5,
			GRID_WIDTH  - 0.5,
			GRID_HEIGHT - 0.5);
	cairo_fill (cr);
	cairo_destroy (cr);

	return TRUE;
}
Пример #27
0
static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    int x = int(gdk_event->x);
    int y = int(gdk_event->y);

    if (gdk_event->is_hint)
    {
#ifdef __WXGTK3__
       gdk_window_get_device_position(gdk_event->window, gdk_event->device, &x, &y, NULL);
#else
       gdk_window_get_pointer(gdk_event->window, &x, &y, NULL);
#endif
    }

    if (!win->m_isDragging)
    {
#ifndef __WXGTK3__
        if (win->GetWindowStyle() & wxRESIZE_BORDER)
        {
            if ((x > win->m_width-14) && (y > win->m_height-14))
               gdk_window_set_cursor(gtk_widget_get_window(widget), gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
            else
               gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
            win->GTKUpdateCursor(false);
        }
#endif
        return TRUE;
    }

    win->m_oldX = x - win->m_diffX;
    win->m_oldY = y - win->m_diffY;

    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    win->m_x = x;
    win->m_y = y;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
Пример #28
0
static gboolean
on_widget_motion_notify (GtkWidget *widget,
			 GdkEventMotion *event,
			 char *item_id)
{
  GdkDevice *device = gdk_event_get_device ((GdkEvent*) event);

  g_print ("%s received 'motion-notify' signal (window: %p)\n", item_id,
	   event->window);

  if (event->is_hint && device)
    gdk_window_get_device_position (event->window, device, NULL, NULL, NULL);

  return TRUE;
}
Пример #29
0
static void
gdk_device_win32_get_state (GdkDevice       *device,
                            GdkWindow       *window,
                            gdouble         *axes,
                            GdkModifierType *mask)
{
  gint x_int, y_int;

  gdk_window_get_device_position (window, device, &x_int, &y_int, mask);

  if (axes)
    {
      axes[0] = x_int;
      axes[1] = y_int;
    }
}
Пример #30
0
static Bool
motion_notify_event(GtkWidget *widget, GdkEventMotion *event) {
 GdkModifierType state;

 if (event->is_hint) {
  gdk_window_get_device_position (event->window, event->device, &VGUI.lastx, &VGUI.lasty, &state);
 } else {
  VGUI.lastx = event->x;
  VGUI.lasty = event->y;
  state = event->state;
 }

 notify_input();
 //printf("motion_notify_event: %d %d %d\n", VGUI.lastbutton, VGUI.lastx, VGUI.lasty);

 return FALSE;
}