desktop-events.cpp revision cedead99dd5eab3aea7d8f23cc2dd97b041c1793
5488N/A#ifdef HAVE_CONFIG_H
5488N/A#include "desktop-handles.h"
5488N/A#include "dialogs/dialog-events.h"
5488N/A#include "display/canvas-axonomgrid.h"
5488N/A#include "display/canvas-grid.h"
5488N/A#include "display/guideline.h"
5488N/A#include "display/snap-indicator.h"
5488N/A#include "document.h"
5488N/A#include "event-context.h"
5488N/A#include "helper/unit-menu.h"
5488N/A#include "message-context.h"
5488N/A#include "preferences.h"
5488N/A#include "sp-guide.h"
5488N/A#include "sp-metrics.h"
5488N/A#include "sp-namedview.h"
5488N/A#include "tools-switch.h"
5488N/A#include "widgets/desktop-widget.h"
5488N/Astatic void init_extended();
5488N/Astatic gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw, bool horiz)
5488N/A static bool snap_window_temporarily_open = false;
5488N/A gdk_window_get_geometry(GTK_WIDGET(dtw->canvas)->window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
5488N/A case GDK_BUTTON_PRESS:
5488N/A // FIXME: The snap delay mechanism won't work here, because it has been implemented for the event context. Dragging
5488N/A // guides off the ruler will send event to the ruler and not to the context, which bypasses sp_event_context_snap_delay_handler
5488N/A // The snap manager will not notice the difference, so it'll check if the snap delay has been activated (This check
5488N/A // is only needed for catching coding errors, i.e. to warn if the snap window has not been implemented properly
5488N/A // A dt_ruler_event might be emitted when dragging a guide off the rulers while drawing a Bezier curve
5488N/A // In such a situation, we're already in that specific context and the snap delay is already active. We should
5488N/A // not set the snap delay to active again, because that will trigger a similar warning to the one above
5488N/A snap_window_temporarily_open = true;
if (horiz) {
case GDK_MOTION_NOTIFY:
if (dragging) {
// We only have a temporary guide which is not stored in our document yet. Because the guide snapper only looks
// in the document for guides to snap to, we don't have to worry about a guide snapping to itself here
case GDK_BUTTON_RELEASE:
// We only have a temporary guide which is not stored in our document yet. Because the guide snapper only looks
// in the document for guides to snap to, we don't have to worry about a guide snapping to itself here
dragging = false;
if (snap_window_temporarily_open) {
snap_window_temporarily_open = false;
// A dt_ruler_event might be emitted when dragging a guide of the rulers while drawing a Bezier curve
// In such a situation, we're already in that specific context and the snap delay is already active. We should
// interfere with that context and we should therefore leave the snap delay status as it is. So although it might
// have been set to active above on GDK_BUTTON_PRESS, we should not set it back to inactive here. That must be
return FALSE;
enum SPGuideDragType {
static bool moved = false;
SPDesktop *desktop = static_cast<SPDesktop*>(gtk_object_get_data(GTK_OBJECT(item->canvas), "SPDesktop"));
case GDK_2BUTTON_PRESS:
case GDK_BUTTON_PRESS:
NULL,
case GDK_MOTION_NOTIFY:
switch (drag_type) {
case SP_DRAG_TRANSLATE:
case SP_DRAG_ROTATE:
case SP_DRAG_MOVE_ORIGIN:
case SP_DRAG_NONE:
moved = true;
case GDK_BUTTON_RELEASE:
if (moved) {
switch (drag_type) {
case SP_DRAG_TRANSLATE:
case SP_DRAG_ROTATE:
case SP_DRAG_MOVE_ORIGIN:
case SP_DRAG_NONE:
moved = false;
case GDK_ENTER_NOTIFY:
desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description);
case GDK_LEAVE_NOTIFY:
return ret;
static void init_extended()
if ( devices ) {
case GDK_SOURCE_PEN:
case GDK_SOURCE_ERASER:
case GDK_SOURCE_CURSOR:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_SCROLL:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
//g_message("Changed device %s -> %s", lastName.c_str(), name.c_str());