app/widgets/gimpgradienteditor.c use gdk_event_request_motions() to handle
2007-11-04 Sven Neumann <sven@gimp.org> * app/widgets/gimpgradienteditor.c * app/widgets/gimpnavigationview.c: use gdk_event_request_motions() to handle motion hint events. svn path=/trunk/; revision=24052
This commit is contained in:

committed by
Sven Neumann

parent
ae1f2eb2bc
commit
8f377f2748
@ -1,3 +1,9 @@
|
|||||||
|
2007-11-04 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/widgets/gimpgradienteditor.c
|
||||||
|
* app/widgets/gimpnavigationview.c: use
|
||||||
|
gdk_event_request_motions() to handle motion hint events.
|
||||||
|
|
||||||
2007-11-04 Michael Natterer <mitch@gimp.org>
|
2007-11-04 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/widgets/Makefile.am
|
* app/widgets/Makefile.am
|
||||||
|
@ -844,7 +844,6 @@ view_events (GtkWidget *widget,
|
|||||||
GimpGradientEditor *editor)
|
GimpGradientEditor *editor)
|
||||||
{
|
{
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
||||||
gint x, y;
|
|
||||||
|
|
||||||
if (! data_editor->data)
|
if (! data_editor->data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -859,11 +858,9 @@ view_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GdkEventMotion *mevent = (GdkEventMotion *) event;
|
GdkEventMotion *mevent = (GdkEventMotion *) event;
|
||||||
|
|
||||||
gtk_widget_get_pointer (data_editor->view, &x, &y);
|
if (mevent->x != editor->view_last_x)
|
||||||
|
|
||||||
if (x != editor->view_last_x)
|
|
||||||
{
|
{
|
||||||
editor->view_last_x = x;
|
editor->view_last_x = mevent->x;
|
||||||
|
|
||||||
if (editor->view_button_down)
|
if (editor->view_button_down)
|
||||||
{
|
{
|
||||||
@ -871,13 +868,15 @@ view_events (GtkWidget *widget,
|
|||||||
(mevent->state & GDK_CONTROL_MASK) ?
|
(mevent->state & GDK_CONTROL_MASK) ?
|
||||||
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
||||||
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
||||||
x);
|
mevent->x);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
view_set_hint (editor, x);
|
view_set_hint (editor, mevent->x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_event_request_motions (mevent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -885,19 +884,17 @@ view_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GdkEventButton *bevent = (GdkEventButton *) event;
|
GdkEventButton *bevent = (GdkEventButton *) event;
|
||||||
|
|
||||||
gtk_widget_get_pointer (data_editor->view, &x, &y);
|
|
||||||
|
|
||||||
switch (bevent->button)
|
switch (bevent->button)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
editor->view_last_x = x;
|
editor->view_last_x = bevent->x;
|
||||||
editor->view_button_down = TRUE;
|
editor->view_button_down = TRUE;
|
||||||
|
|
||||||
view_pick_color (editor,
|
view_pick_color (editor,
|
||||||
(bevent->state & GDK_CONTROL_MASK) ?
|
(bevent->state & GDK_CONTROL_MASK) ?
|
||||||
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
||||||
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
||||||
x);
|
bevent->x);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -961,16 +958,14 @@ view_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GdkEventButton *bevent = (GdkEventButton *) event;
|
GdkEventButton *bevent = (GdkEventButton *) event;
|
||||||
|
|
||||||
gtk_widget_get_pointer (data_editor->view, &x, &y);
|
editor->view_last_x = bevent->x;
|
||||||
|
|
||||||
editor->view_last_x = x;
|
|
||||||
editor->view_button_down = FALSE;
|
editor->view_button_down = FALSE;
|
||||||
|
|
||||||
view_pick_color (editor,
|
view_pick_color (editor,
|
||||||
(bevent->state & GDK_CONTROL_MASK) ?
|
(bevent->state & GDK_CONTROL_MASK) ?
|
||||||
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
GIMP_COLOR_PICK_MODE_BACKGROUND :
|
||||||
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
||||||
x);
|
bevent->x);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1069,14 +1064,6 @@ view_pick_color (GimpGradientEditor *editor,
|
|||||||
|
|
||||||
/***** Gradient control functions *****/
|
/***** Gradient control functions *****/
|
||||||
|
|
||||||
/* *** WARNING *** WARNING *** WARNING ***
|
|
||||||
*
|
|
||||||
* All the event-handling code for the gradient control widget is
|
|
||||||
* extremely hairy. You are not expected to understand it. If you
|
|
||||||
* find bugs, mail me unless you are very brave and you want to fix
|
|
||||||
* them yourself ;-)
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
control_events (GtkWidget *widget,
|
control_events (GtkWidget *widget,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
@ -1084,8 +1071,6 @@ control_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
GimpGradientSegment *seg;
|
GimpGradientSegment *seg;
|
||||||
gint x, y;
|
|
||||||
guint32 time;
|
|
||||||
|
|
||||||
if (! GIMP_DATA_EDITOR (editor)->data)
|
if (! GIMP_DATA_EDITOR (editor)->data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1107,13 +1092,12 @@ control_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GdkEventButton *bevent = (GdkEventButton *) event;
|
GdkEventButton *bevent = (GdkEventButton *) event;
|
||||||
|
|
||||||
gtk_widget_get_pointer (editor->control, &x, &y);
|
editor->control_last_x = bevent->x;
|
||||||
|
|
||||||
editor->control_last_x = x;
|
|
||||||
editor->control_click_time = bevent->time;
|
editor->control_click_time = bevent->time;
|
||||||
|
|
||||||
control_button_press (editor,
|
control_button_press (editor,
|
||||||
x, y, bevent->button, bevent->state);
|
bevent->x, bevent->y,
|
||||||
|
bevent->button, bevent->state);
|
||||||
|
|
||||||
if (editor->control_drag_mode != GRAD_DRAG_NONE)
|
if (editor->control_drag_mode != GRAD_DRAG_NONE)
|
||||||
{
|
{
|
||||||
@ -1159,6 +1143,9 @@ control_events (GtkWidget *widget,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
|
{
|
||||||
|
GdkEventButton *bevent = (GdkEventButton *) event;
|
||||||
|
|
||||||
gradient_editor_set_hint (editor, NULL, NULL, NULL, NULL);
|
gradient_editor_set_hint (editor, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (editor->control_drag_mode != GRAD_DRAG_NONE)
|
if (editor->control_drag_mode != GRAD_DRAG_NONE)
|
||||||
@ -1175,11 +1162,7 @@ control_events (GtkWidget *widget,
|
|||||||
|
|
||||||
gtk_grab_remove (widget);
|
gtk_grab_remove (widget);
|
||||||
|
|
||||||
gtk_widget_get_pointer (editor->control, &x, &y);
|
if ((bevent->time - editor->control_click_time) >= GRAD_MOVE_TIME)
|
||||||
|
|
||||||
time = ((GdkEventButton *) event)->time;
|
|
||||||
|
|
||||||
if ((time - editor->control_click_time) >= GRAD_MOVE_TIME)
|
|
||||||
{
|
{
|
||||||
/* stuff was done in motion */
|
/* stuff was done in motion */
|
||||||
}
|
}
|
||||||
@ -1190,11 +1173,15 @@ control_events (GtkWidget *widget,
|
|||||||
|
|
||||||
if ((editor->control_drag_mode == GRAD_DRAG_ALL) &&
|
if ((editor->control_drag_mode == GRAD_DRAG_ALL) &&
|
||||||
editor->control_compress)
|
editor->control_compress)
|
||||||
|
{
|
||||||
control_extend_selection (editor, seg,
|
control_extend_selection (editor, seg,
|
||||||
control_calc_g_pos (editor,
|
control_calc_g_pos (editor,
|
||||||
x));
|
bevent->x));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
control_select_single_segment (editor, seg);
|
control_select_single_segment (editor, seg);
|
||||||
|
}
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
@ -1202,32 +1189,36 @@ control_events (GtkWidget *widget,
|
|||||||
editor->control_drag_mode = GRAD_DRAG_NONE;
|
editor->control_drag_mode = GRAD_DRAG_NONE;
|
||||||
editor->control_compress = FALSE;
|
editor->control_compress = FALSE;
|
||||||
|
|
||||||
control_do_hint (editor, x, y);
|
control_do_hint (editor, bevent->x, bevent->y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MOTION_NOTIFY:
|
case GDK_MOTION_NOTIFY:
|
||||||
gtk_widget_get_pointer (editor->control, &x, &y);
|
|
||||||
|
|
||||||
if (x != editor->control_last_x)
|
|
||||||
{
|
{
|
||||||
editor->control_last_x = x;
|
GdkEventMotion *mevent = (GdkEventMotion *) event;
|
||||||
|
|
||||||
|
if (mevent->x != editor->control_last_x)
|
||||||
|
{
|
||||||
|
editor->control_last_x = mevent->x;
|
||||||
|
|
||||||
if (GIMP_DATA_EDITOR (editor)->data_editable &&
|
if (GIMP_DATA_EDITOR (editor)->data_editable &&
|
||||||
editor->control_drag_mode != GRAD_DRAG_NONE)
|
editor->control_drag_mode != GRAD_DRAG_NONE)
|
||||||
{
|
{
|
||||||
time = ((GdkEventButton *) event)->time;
|
|
||||||
|
|
||||||
if ((time - editor->control_click_time) >= GRAD_MOVE_TIME)
|
if ((mevent->time - editor->control_click_time) >= GRAD_MOVE_TIME)
|
||||||
control_motion (editor, gradient, x);
|
control_motion (editor, gradient, mevent->x);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_gradient_editor_update (editor);
|
gimp_gradient_editor_update (editor);
|
||||||
|
|
||||||
control_do_hint (editor, x, y);
|
control_do_hint (editor, mevent->x, mevent->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_event_request_motions (mevent);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -387,15 +387,11 @@ gimp_navigation_view_motion_notify (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
|
||||||
GimpView *view = GIMP_VIEW (widget);
|
GimpView *view = GIMP_VIEW (widget);
|
||||||
gint tx, ty;
|
|
||||||
GdkModifierType mask;
|
|
||||||
|
|
||||||
if (! nav_view->has_grab)
|
if (! nav_view->has_grab)
|
||||||
{
|
{
|
||||||
|
GdkDisplay *display = gtk_widget_get_display (widget);
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
GdkDisplay *display;
|
|
||||||
|
|
||||||
display = gtk_widget_get_display (widget);
|
|
||||||
|
|
||||||
if (nav_view->p_x == 0 &&
|
if (nav_view->p_x == 0 &&
|
||||||
nav_view->p_y == 0 &&
|
nav_view->p_y == 0 &&
|
||||||
@ -423,12 +419,11 @@ gimp_navigation_view_motion_notify (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_window_get_pointer (view->event_window, &tx, &ty, &mask);
|
gimp_navigation_view_move_to (nav_view,
|
||||||
|
mevent->x - nav_view->motion_offset_x,
|
||||||
|
mevent->y - nav_view->motion_offset_y);
|
||||||
|
|
||||||
tx -= nav_view->motion_offset_x;
|
gdk_event_request_motions (mevent);
|
||||||
ty -= nav_view->motion_offset_y;
|
|
||||||
|
|
||||||
gimp_navigation_view_move_to (nav_view, tx, ty);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user