Пример #1
0
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                       guint time, gpointer user_data, bool paste)
{
	DndTargets(context);
	g_object_ref(context); // make sure these always survive the action...
	g_object_ref(widget);
	dnd_context = context;
	dnd_widget = widget;
	dnd_time = time;
	PasteClip clip;
	clip.type = 1;
	clip.paste = paste;
	clip.accepted = false;
	clip.allowed = DND_MOVE|DND_COPY;
	gint dummy;
	GdkModifierType mod;
	gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod);
	clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE;
	Ctrl *w = DragWnd(user_data);
	if(w) {
		gint mx, my;
		GdkModifierType mod;
		gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod);
		CurrentState = mod;
		CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft();	
		w->DnD(CurrentMousePos, clip);
	}
	gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE
	                                                                          : GDK_ACTION_COPY
	                                           : GdkDragAction(0), time);
	return clip;
}
Пример #2
0
static gboolean
scribble_motion_notify_event (GtkWidget      *widget,
                              GdkEventMotion *event,
                              gpointer        data)
{
  int x, y;
  GdkModifierType state;

  if (pixmap == 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_pointer (event->window, &x, &y, &state);

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

  /* We've handled it, stop processing */
  return TRUE;
}
Пример #3
0
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
    if (g_isIdle) wxapp_install_idle_handler();

    if (!win->m_hasVMT) return FALSE;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    if (!win->m_isDragging) return TRUE;

    if (gdk_event->is_hint)
    {
       int x = 0;
       int y = 0;
       GdkModifierType state;
       gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
       gdk_event->x = x;
       gdk_event->y = y;
       gdk_event->state = state;
    }

    DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
    win->m_oldX = (int)gdk_event->x - win->m_diffX;
    win->m_oldY = (int)gdk_event->y - win->m_diffY;
    DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );

    return TRUE;
}
Пример #4
0
static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data)
{
	GdkModifierType state;
	gint x,y;
	s32 EmuX, EmuY;
	
	
	if(click)
	{
		if(e->is_hint)
			gdk_window_get_pointer(w->window, &x, &y, &state);
		else
		{
			x= (gint)e->x;
			y= (gint)e->y;
			state=(GdkModifierType)e->state;
		}
		
	//	fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK);
	
		if(y >= 192 && (state & GDK_BUTTON1_MASK))
		{
			EmuX = x;
			EmuY = y - 192;
			if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255;
			if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192;
			NDS_setTouchPos(EmuX, EmuY);
		}
	}
	
	return TRUE;
}
Пример #5
0
gboolean DrawFunc(gpointer user) {
    ENGD *engd = user;
    GdkGLDrawable *pGLD = 0;
    GdkRectangle rect = {};
    GdkModifierType gmod;
    gint xptr, yptr;
    GdkRegion *creg;
    GdkWindow *hwnd;
    intptr_t *data;
    uint32_t attr;

    cEngineCallback(engd, ECB_GUSR, (intptr_t)&data);
    if (!(hwnd = gtk_widget_get_window(GTK_WIDGET(data[0]))))
        return TRUE;

    gdk_window_get_pointer(hwnd, &xptr, &yptr, &gmod);
    attr = ((gmod & GDK_BUTTON1_MASK)? UFR_LBTN : 0)
         | ((gmod & GDK_BUTTON2_MASK)? UFR_MBTN : 0)
         | ((gmod & GDK_BUTTON3_MASK)? UFR_RBTN : 0)
         | ((gtk_window_is_active(GTK_WINDOW(data[0])))? UFR_MOUS : 0);
    attr = cPrepareFrame(engd, xptr, yptr, attr);
    if (attr & PFR_SKIP)
        usleep(1000);
    if (attr & PFR_HALT)
        return TRUE;
    if (attr & PFR_PICK) {
        rect.width  = (int16_t)(data[2]);
        rect.height = (int16_t)(data[2] >> 16);
    }
Пример #6
0
static void
gamine_on_key (GtkWidget *pWidget,
    GdkEventKey* pKey,
    gamine_t *cb)
{
    gint mx, my;
    if (pKey->type == GDK_KEY_PRESS)
    {
        switch (pKey->keyval)
        {
            case GDK_Escape :
                gtk_main_quit ();
            break;
            case GDK_space :
                gtk_widget_queue_draw(pWidget);
            break;
            case GDK_Print:
                save_picture(cb);
            break;
            default:
                gdk_window_get_pointer(pWidget->window, &mx, &my, NULL);
                draw_string(cb, mx, my, pKey->string);
            break;
        }
    };
}
Пример #7
0
void
menu_calc_popup_position (GtkMenu *menu, gint *x_ret, gint *y_ret,
                          gboolean *push_in,
                          gpointer data)
{
   GdkWindow *window = data;
   gint x = 0, y = 0, w = 0, h = 0, cursor_x = 0, cursor_y = 0;
   GdkModifierType mask;

   g_return_if_fail (x_ret && y_ret);
   g_return_if_fail (window);

   gdk_window_get_pointer (window, &cursor_x, &cursor_y, &mask);

   gdk_window_get_origin (window, &x, &y);
   gdk_window_get_size (window, &w, &h);

   if (cursor_x < 0 || cursor_x > w || cursor_y < 0 || cursor_y > h)
   {
      *x_ret = x + w / 2;
      *y_ret = y + h / 2;
   } else {
      *x_ret = x + cursor_x;
      *y_ret = y + cursor_y;
   }
}
static void
timeline_frame_cb (GsdTimeline *timeline,
		   gdouble      progress,
		   gpointer     user_data)
{
  GsdLocatePointerData *data = (GsdLocatePointerData *) user_data;
  GdkScreen *screen;
  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;
    }

  screen = gdk_drawable_get_screen (data->window);
  gdk_window_get_pointer (gdk_screen_get_root_window (screen),
			  &cursor_x, &cursor_y, NULL);
  gdk_window_move (data->window,
                   cursor_x - WINDOW_SIZE / 2,
                   cursor_y - WINDOW_SIZE / 2);
}
static void
move_locate_pointer_window (GsdLocatePointerData *data,
			    GdkScreen            *screen)
{
  gint cursor_x, cursor_y;
  GdkBitmap *mask;
  GdkColor col;
  GdkGC *gc;

  gdk_window_get_pointer (gdk_screen_get_root_window (screen), &cursor_x, &cursor_y, NULL);

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

  col.pixel = 0;
  mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);

  gc = gdk_gc_new (mask);
  gdk_gc_set_foreground (gc, &col);
  gdk_draw_rectangle (mask, gc, TRUE, 0, 0, WINDOW_SIZE, WINDOW_SIZE);

  /* allow events to happen through the window */
  gdk_window_input_shape_combine_mask (data->window, mask, 0, 0);

  g_object_unref (mask);
  g_object_unref (gc);
}
Пример #10
0
/* Zpracování událostí - tato funkce pøidává popis události do seznamu
 * zachycených událostí, ale vrací FALSE, proto¾e chceme, aby se události dál
 * normálnì zpracovávaly. */
static gint gtk_ev_event(GtkWidget *widget, GdkEvent *event)
{
    GtkEv *ev;

    g_return_val_if_fail(widget, FALSE);
    g_return_val_if_fail(GTK_IS_EV(widget), FALSE);
    g_return_val_if_fail(event, FALSE);

    ev = GTK_EV(widget);

    if(event->any.window == widget->window) {
        if(GTK_WIDGET_CLASS(parent_class)->event)
            return GTK_WIDGET_CLASS(parent_class)->event(widget, event);
    } else {
        /* Událost je buï urèena pro ev->ev_win, nebo je to klávesnicová
         * událost poslaná z toplevel GtkWindow */
        gchar *text;

        text = event_to_text(event);
        gtk_ev_push_text(ev, text);
        g_free(text);

        /* Zajistit pøeètení dal¹í motion event */
        if(event->type == GDK_MOTION_NOTIFY)
            gdk_window_get_pointer(ev->ev_win, NULL, NULL, NULL);
    }
    
    gtk_signal_emit(GTK_OBJECT(widget), ev_signals[EVENT_RECEIVED],
                    event->type);

    return FALSE;
}
Пример #11
0
static void
setupConnections(GtkWidget *widget, GtkWidget *parent)
{
    GtkWidgetProps props(widget);
    if (widget && !props->scrolledWindowHacked) {
        props->scrolledWindowHacked = true;
        gtk_widget_add_events(widget, GDK_LEAVE_NOTIFY_MASK |
                              GDK_ENTER_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK);
        props->scrolledWindowDestroy.conn("destroy-event", destroy, parent);
        props->scrolledWindowUnrealize.conn("unrealize", destroy, parent);
        props->scrolledWindowStyleSet.conn("style-set", styleSet, parent);
        if (opts.unifyCombo && opts.unifySpin) {
            props->scrolledWindowEnter.conn("enter-notify-event",
                                            enter, parent);
            props->scrolledWindowLeave.conn("leave-notify-event",
                                            leave, parent);
        }
        props->scrolledWindowFocusIn.conn("focus-in-event", focusIn, parent);
        props->scrolledWindowFocusOut.conn("focus-out-event", focusOut, parent);
        if (parent && opts.unifyCombo && opts.unifySpin) {
            QtcRect alloc = Widget::getAllocation(parent);
            int x;
            int y;
            gdk_window_get_pointer(gtk_widget_get_window(parent),
                                   &x, &y, nullptr);
            if (x >= 0 && x <alloc.width && y >= 0 && y < alloc.height) {
                hoverWidget = parent;
            }
        }
    }
}
Пример #12
0
static void qtcScrolledWindowSetupConnections(GtkWidget *widget, GtkWidget *parent)
{
    if (widget && !g_object_get_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET"))
    {
        gtk_widget_add_events(widget, GDK_LEAVE_NOTIFY_MASK|GDK_ENTER_NOTIFY_MASK|GDK_FOCUS_CHANGE_MASK);
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET", (gpointer)1);
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_DESTROY_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "destroy-event", G_CALLBACK(qtcScrolledWindowDestroy), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_UNREALIZE_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "unrealize", G_CALLBACK(qtcScrolledWindowDestroy), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_STYLE_SET_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "style-set", G_CALLBACK(qtcScrolledWindowStyleSet), parent));
        if(ENTRY_MO)
        {
            g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_ENTER_ID",
                              (gpointer)g_signal_connect(G_OBJECT(widget), "enter-notify-event", G_CALLBACK(qtcScrolledWindowEnter), parent));
            g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_LEAVE_ID",
                             (gpointer)g_signal_connect(G_OBJECT(widget), "leave-notify-event", G_CALLBACK(qtcScrolledWindowLeave), parent));
        }
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_FOCUS_IN_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "focus-in-event", G_CALLBACK(qtcScrolledWindowFocusIn), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_FOCUS_OUT_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "focus-out-event", G_CALLBACK(qtcScrolledWindowFocusOut), parent));

        if(parent && ENTRY_MO)
        {
            gint          x, y;
            GtkAllocation alloc=qtcWidgetGetAllocation(parent);

            gdk_window_get_pointer(qtcWidgetGetWindow(parent), &x, &y, 0L);
            if(x>=0 && x<alloc.width && y>=0 && y<alloc.height)
                qtcScrolledWindowHover=parent;
        }
    }
}
static void
move_locate_pointer_window (MsdLocatePointerData *data,
			    GdkScreen            *screen)
{
  gint cursor_x, cursor_y;
  GdkBitmap *mask;
  cairo_t *cr;

  gdk_window_get_pointer (gdk_screen_get_root_window (screen), &cursor_x, &cursor_y, NULL);

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

  mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);

  cr = gdk_cairo_create (mask);
  cairo_set_source_rgb (cr, 0., 0., 0.);
  cairo_rectangle (cr, 0., 0., WINDOW_SIZE, WINDOW_SIZE);
  cairo_fill (cr);
  cairo_destroy (cr);

  /* allow events to happen through the window */
  gdk_window_input_shape_combine_mask (data->window, mask, 0, 0);

  g_object_unref (mask);
}
Пример #14
0
gboolean
ghid_note_event_location (GdkEventButton * ev)
{
  gint x, y;
  gboolean moved;

  if (!ev)
    {
      gdk_window_get_pointer (ghid_port.drawing_area->window, &x, &y, NULL);
      event_x = x;
      event_y = y;
    }
  else
    {
      event_x = ev->x;
      event_y = ev->y;
    }
  gport->view_x = event_x * gport->zoom + gport->view_x0;
  gport->view_y = event_y * gport->zoom + gport->view_y0;

  moved = MoveCrosshairAbsolute (SIDE_X (gport->view_x), 
				 SIDE_Y (gport->view_y));
  if (moved)
    {
      AdjustAttachedObjects ();
      RestoreCrosshair (false);
    }
  ghid_set_cursor_position_labels ();
  return moved;
}
Пример #15
0
static gboolean
motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer data) {
    gui_world *world = (gui_world *)data;

    int x, y;
    GdkModifierType state;

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

    int space_height = 50, space_width = 50;

    /* convert into cp values */
    int window_height = gtk_widget_get_allocated_height(world -> graphics -> drawing_screen);
    int window_width = gtk_widget_get_allocated_width(world -> graphics -> drawing_screen);

    float screen_height_ratio = (float) window_height / space_height;
    float screen_width_ratio = (float) window_width / space_width;

    cpFloat x1 = (x - window_width / 2) / screen_width_ratio;
    cpFloat y1 = (-y + window_height / 2) / screen_height_ratio;


    if (state & GDK_BUTTON1_MASK) {
        add_user_point (x1, y1, world);
    }

    return TRUE;

}
Пример #16
0
void Gcwkeyaction(GtkWidget * w, GdkEventKey * event, gpointer data)
{
    Gwidget_t *widget;
    Gevent_t gev;
    int xtype, bn, wi, state;
    PIXpoint_t pp;
    unsigned int mask;
    char c;

    widget = findwidget((unsigned long) canvas->w, G_CANVASWIDGET);
    switch ((xtype = event->type)) {
    case GDK_KEY_PRESS:
    case GDK_KEY_RELEASE:
	gdk_window_get_pointer(event->window, &pp.x, &pp.y, &state);
	gev.type = G_KEYBD;
	gev.code = (xtype == GDK_KEY_PRESS) ? G_DOWN : G_UP;
	gev.data = event->keyval;
	gev.p = Gppixtodraw(widget, pp);
	break;
    default:
	return;
    }
    gev.wi = widget - &Gwidgets[0];
    Gpopdownflag = FALSE;
    if (WCU->func)
	(*WCU->func) (&gev);
    if (Gpopdownflag)
	Gpopdownflag = FALSE;

}
Пример #17
0
static gint
gtk_vruler_motion_notify (GtkWidget      *widget,
			  GdkEventMotion *event)
{
  GtkRuler *ruler;
  gint y;

  g_return_val_if_fail (widget != NULL, FALSE);
  g_return_val_if_fail (GTK_IS_VRULER (widget), FALSE);
  g_return_val_if_fail (event != NULL, FALSE);

  ruler = GTK_RULER (widget);

  if (event->is_hint)
    gdk_window_get_pointer (widget->window, NULL, &y, NULL);
  else
    y = event->y;

  ruler->position = ruler->lower + ((ruler->upper - ruler->lower) * y) / widget->allocation.height;

  /*  Make sure the ruler has been allocated already  */
  if (ruler->backing_store != NULL)
    gtk_ruler_draw_pos (ruler);

  return FALSE;
}
Пример #18
0
gint	handle_map_button_release(
	GtkWidget *widget, GdkEventMotion *event
)
{
	gint x = 0;
	gint y = 0;
	GdkModifierType state = (GdkModifierType)0;

	if( event->is_hint ){
		gdk_window_get_pointer( event->window, &x, &y, &state );
	} else {
		x = (gint)(event->x);
		y = (gint)(event->y);
		state = (GdkModifierType)(event->state);
	}

	if( !(state & GDK_BUTTON1_MASK) )
		gMouseMotion.end( MouseMotion::nMouseButton0, x, y );
	if( !(state & GDK_BUTTON2_MASK) )
		gMouseMotion.end( MouseMotion::nMouseButton1, x, y );
	if( !(state & GDK_BUTTON3_MASK) )
		gMouseMotion.end( MouseMotion::nMouseButton2, x, y );
	if( !(state & GDK_BUTTON4_MASK) )
		gMouseMotion.end( MouseMotion::nMouseButton3, x, y );
	if( !(state & GDK_BUTTON5_MASK) )
		gMouseMotion.end( MouseMotion::nMouseButton4, x, y );

	gMapDragBgnX = -1;
	gMapDragBgnY = -1;

	return TRUE;
}
Пример #19
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);
}
static void
expose_event_cb (GtkDrawingArea *drawing_area,
		 GdkEventExpose *eev,
		 gpointer  user_data)
{
	GtkWidget *widget;
	EomPrintPreviewPrivate *priv;
	cairo_t *cr;

	widget = GTK_WIDGET (drawing_area);
	priv = EOM_PRINT_PREVIEW (user_data)->priv;

	update_relative_sizes (EOM_PRINT_PREVIEW (user_data));

	cr = gdk_cairo_create (gtk_widget_get_window (widget));

	eom_print_preview_draw (EOM_PRINT_PREVIEW (user_data), cr);

	if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
		fprintf (stderr, "Cairo is unhappy: %s\n",
			 cairo_status_to_string (cairo_status (cr)));
	}

	cairo_destroy (cr);

	gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, NULL);
}
Пример #21
0
static void wxFillOtherKeyEventFields(wxKeyEvent& event,
                                      wxWindowGTK *win,
                                      GdkEventKey *gdk_event)
{
    int x = 0;
    int y = 0;
    GdkModifierType state;
    if (gdk_event->window)
        gdk_window_get_pointer(gdk_event->window, &x, &y, &state);

    event.SetTimestamp( gdk_event->time );
    event.SetId(win->GetId());
    event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0;
    event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0;
    event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
    event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK) != 0;
    event.m_scanCode = gdk_event->keyval;
    event.m_rawCode = (wxUint32) gdk_event->keyval;
    event.m_rawFlags = 0;
#if wxUSE_UNICODE
    event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval);
#endif
    wxGetMousePosition( &x, &y );
    win->ScreenToClient( &x, &y );
    event.m_x = x;
    event.m_y = y;
    event.SetEventObject( win );
}
Пример #22
0
static int
uni_nav_motion_notify (GtkWidget * widget, GdkEventMotion * ev)
{
    UniNav *nav = UNI_NAV (widget);
    int mx, my;
    gdk_window_get_pointer (gtk_widget_get_window (widget), &mx, &my, NULL);

    /* Make coordinates relative to window. */
    mx -= 4;
    my -= 4;

    /* Convert Nav space to Zoom space coordinates. */
    gdouble zoom2nav_factor = uni_nav_get_zoom2nav_factor (nav);
    GdkRectangle rect;
    uni_image_view_get_viewport (nav->view, &rect);

    /* Convert Zoom space to Nav space coordinates. */
    rect.width = (gdouble) rect.width / zoom2nav_factor;
    rect.height = (gdouble) rect.height / zoom2nav_factor;

    /* Subtract half of the XOR rectangles size from the coordinates. */
    mx -= (rect.width / 2);
    my -= (rect.height / 2);

    /* Do the adjusted coordinate conversion. */
    int zoom_x_ofs = mx * zoom2nav_factor;
    int zoom_y_ofs = my * zoom2nav_factor;

    uni_image_view_set_offset (nav->view, zoom_x_ofs, zoom_y_ofs, TRUE);
    uni_nav_draw_rectangle (nav, TRUE);

    return TRUE;
}
Пример #23
0
void tree_tips_show(TreeTips *tips)
{
  GtkWidget *label;
  gint x,y;
  gchar *pstr;

  if (!tips) return;  
  if (!tips->enabled) return;
  if (tips->window) return; 
 
  pstr = ((* tips->func)(tips->bfwin,tips->tree, tips->posx,tips->posy));
  if (pstr)
  {
     tips->window = gtk_window_new (GTK_WINDOW_POPUP);
     gtk_widget_set_app_paintable (tips->window, TRUE);
     gtk_window_set_resizable (GTK_WINDOW(tips->window), FALSE);
     gtk_widget_set_name (tips->window, "tree-tooltips");
     gtk_container_set_border_width (GTK_CONTAINER (tips->window), 4); 
     g_signal_connect_swapped(GTK_WINDOW(tips->window),"expose-event",G_CALLBACK(tree_tips_paint),tips);
     label = gtk_label_new (NULL);  
     gtk_label_set_markup(GTK_LABEL(label),pstr);
     gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
     gtk_container_add (GTK_CONTAINER (tips->window), GTK_WIDGET (label));  
     gtk_window_set_position (GTK_WINDOW(tips->window), GTK_WIN_POS_MOUSE);  
     gdk_window_get_pointer (NULL, &x, &y, NULL);
     gtk_window_move (GTK_WINDOW(tips->window), x + 8, y + 16);  
     gtk_widget_show_all(tips->window);       
     g_free(pstr);
     tips->hide_tout = g_timeout_add (tips->hide_interval, (GSourceFunc) tree_tips_hide, tips);         
  }  
}
Пример #24
0
static gboolean
hand_display_motion (GtkWidget *hand, GdkEventMotion *event)
{
	HandDisplay *handdisp = HAND_DISPLAY(hand);
	int card = which_card(handdisp, event->x, event->y);
	if (handdisp->drag && handdisp->cur_click >= 0 && handdisp->cur_click < 52 &&
		gtk_drag_check_threshold (hand, handdisp->drag_x, handdisp->drag_y, event->x, event->y))
	{
		if (! target_list)
			target_list = gtk_target_list_new (target_entry, 1);
		handdisp->cur_drag = handdisp->cur_click;
		gtk_drag_begin (hand, target_list, GDK_ACTION_COPY, 1, (GdkEvent *) event);
	}
	if (handdisp->cur_focus != card) {
		if (handdisp->cur_focus != -1) {
			redraw_card (hand, handdisp->cur_focus);
			g_signal_emit_by_name (handdisp, "card-leave", handdisp->cur_focus);
		}
		handdisp->cur_focus = card;
		if (card != -1) {
			redraw_card (hand, card);
			g_signal_emit_by_name (handdisp, "card-enter", card);
		}
	}
	gdk_window_get_pointer(gtk_widget_get_window (hand), NULL, NULL, NULL); /* request more pointer hints */
	return FALSE;
}
Пример #25
0
/* *****************************************************************************
 * create a new POI of type "waypoint.route"
 * and append it to the current route
 */
void add_quickpoint_to_route ()
{
	gchar t_name[100], t_cmt[100];
	gdouble t_lat, t_lon;
	glong t_id;
	gint t_x, t_y;
	GdkModifierType state;

	g_snprintf (t_name, sizeof (t_name), "%s %d", _("Routepoint"), route.items+1);
	g_snprintf (t_cmt, sizeof (t_cmt), _("Quicksaved Routepoint"));
	gdk_window_get_pointer (GTK_LAYOUT (map_drawingarea)->bin_window, &t_x, &t_y, &state);
	calcxytopos (t_x, t_y, &t_lat, &t_lon, current.zoom);
	if ( mydebug > 0 )
		printf ("Add Routepoint: %s lat:%f,lon:%f (x:%d,y:%d)\n",
			t_name, t_lat, t_lon, t_x, t_y);

	t_id = addwaypoint (t_name,
		"waypoint.route", t_cmt, t_lat, t_lon, TRUE);

	add_routepoint
		(t_id, t_name, t_cmt, "waypoint.route", t_lon, t_lat);

	gtk_statusbar_push (GTK_STATUSBAR (frame_statusbar),
		current.statusbar_id,
		_("Routepoint added."));

	gtk_widget_set_sensitive (menuitem_saveroute, TRUE);
}
Пример #26
0
void mainWindow_press( GtkWidget* widget, 
		       GdkEventButton* event, gpointer callback_data )
{
    if ( event->button == 1 )
    {
	gdk_window_raise(widget->window );
	gdk_pointer_grab(widget->window, FALSE, (GdkEventMask)
	    ( GDK_BUTTON_MOTION_MASK | 
	    GDK_BUTTON_RELEASE_MASK ), GDK_NONE, GDK_NONE, GDK_CURRENT_TIME);
	offset_x = (int)event->x;
	offset_y = (int)event->y;
	indrag=1;
    }

    else if ( event->button == 3 )
    {
	int x,y;
	gdk_window_get_pointer( NULL, &x, &y, NULL );

	gtk_item_factory_popup( GTK_ITEM_FACTORY( mainMenu ), 
				x, 
				y, 
				3, 
				GDK_CURRENT_TIME );
    }
}
Пример #27
0
static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data)
{
	GdkModifierType state;
	gint x,y;
	s32 EmuX, EmuY;
	
	if(desmume_running()) 
	{
		if(e->button == 1) 
		{
			click = TRUE;
			
			gdk_window_get_pointer(w->window, &x, &y, &state);
			if(y >= 192 && (state & GDK_BUTTON1_MASK))
			{
				EmuX = x;
				EmuY = y - 192;
				if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255;
				if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192;
				NDS_setTouchPos(EmuX, EmuY);
			}
		}
	}
	
	return TRUE;
}
Пример #28
0
static void reload_clicked_cb (GtkButton *button, WebBrowserObject *browser)
{
    gint x, y;
    GdkModifierType state = (GdkModifierType)0;
    gdk_window_get_pointer(NULL, &x, &y, &state);
    gtk_moz_embed_reload(GTK_MOZ_EMBED(browser->mozilla), (state & GDK_SHIFT_MASK) ? GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE : GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
}
Пример #29
0
gboolean
ghid_note_event_location (GdkEventButton * ev)
{
  gint event_x, event_y;
  gboolean moved;

  if (!ev)
    {
      gdk_window_get_pointer (gtk_widget_get_window (ghid_port.drawing_area),
                              &event_x, &event_y, NULL);
    }
  else
    {
      event_x = ev->x;
      event_y = ev->y;
    }

  ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y);

  moved = MoveCrosshairAbsolute (gport->pcb_x, gport->pcb_y);
  if (moved)
    {
      AdjustAttachedObjects ();
      notify_crosshair_change (true);
    }
  ghid_set_cursor_position_labels ();
  return moved;
}
Пример #30
0
void structGraphicsScreen :: v_getMouseLocation (double *xWC, double *yWC) {
	#if cairo
		GdkEvent *gevent = gdk_display_get_event (d_display);
		if (gevent != NULL) {
			if (gevent -> type == GDK_BUTTON_RELEASE) {
				theMouseDown = false;
			}
			gdk_event_free (gevent);
		}
		gint xDC, yDC;
		gdk_window_get_pointer (d_window, & xDC, & yDC, NULL);
		Graphics_DCtoWC (this, xDC, yDC, xWC, yWC);
	#elif cocoa
	#elif win
		POINT pos;
		if (! GetCursorPos (& pos)) { Melder_warning (L"Cannot get cursor position."); return; }
		ScreenToClient (d_winWindow, & pos);
		Graphics_DCtoWC (this, pos. x, pos. y, xWC, yWC);
	#elif mac
		if (HIGetMousePosition != NULL && false) {   // AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
			//Melder_casual ("HIGetMousePosition exists");
			HIPoint mouseLoc;
			HIGetMousePosition (kHICoordSpaceWindow, GetWindowFromPort (d_macPort), & mouseLoc);
			Graphics_DCtoWC (this, mouseLoc. x, mouseLoc. y, xWC, yWC);
		} else {
			Point mouseLoc;
			GetMouse (& mouseLoc);   // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
			Graphics_DCtoWC (this, mouseLoc. h, mouseLoc. v, xWC, yWC);
		}
	#endif
}