207
199
case GDK_WINDOW_STATE:
209
GdkEventWindowState *sevent = (GdkEventWindowState *) event;
201
GdkEventWindowState *sevent = (GdkEventWindowState *) event;
210
202
GimpDisplayOptions *options;
211
203
gboolean fullscreen;
212
204
GimpActionGroup *group;
214
shell->window_state = sevent->new_window_state;
206
shell->window_state = sevent->new_window_state;
216
208
if (! (sevent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN))
219
211
fullscreen = gimp_display_shell_get_fullscreen (shell);
213
gtk_widget_set_name (GTK_WIDGET (shell->menubar),
214
fullscreen ? "gimp-menubar-fullscreen" : NULL);
221
216
options = fullscreen ? shell->fullscreen_options : shell->options;
223
gimp_display_shell_set_show_menubar (shell,
224
options->show_menubar);
225
gimp_display_shell_set_show_rulers (shell,
226
options->show_rulers);
227
gimp_display_shell_set_show_scrollbars (shell,
228
options->show_scrollbars);
229
gimp_display_shell_set_show_statusbar (shell,
230
options->show_statusbar);
231
gimp_display_shell_set_show_selection (shell,
232
options->show_selection);
233
gimp_display_shell_set_show_layer (shell,
234
options->show_layer_boundary);
235
gimp_display_shell_set_show_guides (shell,
236
options->show_guides);
237
gimp_display_shell_set_show_grid (shell,
239
gimp_display_shell_set_padding (shell,
240
options->padding_mode,
241
&options->padding_color);
218
gimp_display_shell_set_show_menubar (shell,
219
options->show_menubar);
220
gimp_display_shell_set_show_rulers (shell,
221
options->show_rulers);
222
gimp_display_shell_set_show_scrollbars (shell,
223
options->show_scrollbars);
224
gimp_display_shell_set_show_statusbar (shell,
225
options->show_statusbar);
226
gimp_display_shell_set_show_selection (shell,
227
options->show_selection);
228
gimp_display_shell_set_show_layer (shell,
229
options->show_layer_boundary);
230
gimp_display_shell_set_show_guides (shell,
231
options->show_guides);
232
gimp_display_shell_set_show_grid (shell,
234
gimp_display_shell_set_show_sample_points (shell,
235
options->show_sample_points);
236
gimp_display_shell_set_padding (shell,
237
options->padding_mode,
238
&options->padding_color);
243
240
group = gimp_ui_manager_get_action_group (shell->menubar_manager,
245
242
gimp_action_group_set_action_active (group, "view-fullscreen",
245
if (shell->display ==
249
246
gimp_context_get_display (gimp_get_user_context (gimp)))
251
248
group = gimp_ui_manager_get_action_group (shell->popup_manager,
445
446
GdkDevice *current_device;
447
current_device = gimp_devices_get_current (shell->gdisp->gimage->gimp);
448
current_device = gimp_devices_get_current (shell->display->image->gimp);
449
450
shell->draw_cursor = ! current_device->has_cursor;
454
gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
458
g_return_if_fail (! shell->scrolling);
460
shell->scrolling = TRUE;
461
shell->scroll_start_x = x + shell->offset_x;
462
shell->scroll_start_y = y + shell->offset_y;
464
gimp_display_shell_set_override_cursor (shell, GDK_FLEUR);
466
gtk_grab_add (shell->canvas);
470
gimp_display_shell_stop_scrolling (GimpDisplayShell *shell)
472
g_return_if_fail (shell->scrolling);
474
shell->scrolling = FALSE;
475
shell->scroll_start_x = 0;
476
shell->scroll_start_y = 0;
478
gimp_display_shell_unset_override_cursor (shell);
480
gtk_grab_remove (shell->canvas);
484
gimp_display_shell_space_pressed (GimpDisplayShell *shell,
485
GdkModifierType state,
488
Gimp *gimp = shell->display->image->gimp;
490
if (shell->space_pressed)
493
switch (GIMP_DISPLAY_CONFIG (gimp->config)->space_bar_action)
495
case GIMP_SPACE_BAR_ACTION_NONE:
498
case GIMP_SPACE_BAR_ACTION_PAN:
502
gimp_display_shell_get_device_coords (shell,
503
gimp_devices_get_current (gimp),
506
gimp_display_shell_start_scrolling (shell, coords.x, coords.y);
508
gdk_pointer_grab (shell->canvas->window, FALSE,
509
GDK_POINTER_MOTION_MASK |
510
GDK_POINTER_MOTION_HINT_MASK,
515
case GIMP_SPACE_BAR_ACTION_MOVE:
517
GimpTool *active_tool = tool_manager_get_active (gimp);
519
if (! active_tool || GIMP_IS_MOVE_TOOL (active_tool))
522
shell->space_shaded_tool =
523
gimp_object_get_name (GIMP_OBJECT (active_tool->tool_info));
525
gimp_context_set_tool (gimp_get_user_context (gimp),
526
gimp_get_tool_info (gimp, "gimp-move-tool"));
528
tool_manager_focus_display_active (gimp, shell->display);
529
tool_manager_modifier_state_active (gimp, state, shell->display);
534
gdk_keyboard_grab (shell->canvas->window, FALSE, time);
536
shell->space_pressed = TRUE;
540
gimp_display_shell_space_released (GimpDisplayShell *shell,
541
GdkModifierType state,
544
Gimp *gimp = shell->display->image->gimp;
546
if (! shell->space_pressed && ! shell->space_release_pending)
549
switch (GIMP_DISPLAY_CONFIG (gimp->config)->space_bar_action)
551
case GIMP_SPACE_BAR_ACTION_NONE:
554
case GIMP_SPACE_BAR_ACTION_PAN:
555
gimp_display_shell_stop_scrolling (shell);
556
gdk_display_pointer_ungrab (gtk_widget_get_display (shell->canvas), time);
559
case GIMP_SPACE_BAR_ACTION_MOVE:
560
gimp_context_set_tool (gimp_get_user_context (gimp),
561
gimp_get_tool_info (gimp,
562
shell->space_shaded_tool));
563
shell->space_shaded_tool = NULL;
565
tool_manager_focus_display_active (gimp, shell->display);
566
tool_manager_modifier_state_active (gimp, state, shell->display);
570
gdk_display_keyboard_ungrab (gtk_widget_get_display (shell->canvas), time);
572
shell->space_pressed = FALSE;
573
shell->space_release_pending = FALSE;
453
577
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
455
579
GimpDisplayShell *shell)
460
GdkDisplay *gdk_display;
461
GimpTool *active_tool;
462
GimpCoords display_coords;
463
GimpCoords image_coords;
464
GdkModifierType state;
466
gboolean return_val = FALSE;
467
gboolean update_cursor = FALSE;
469
static GimpToolInfo *space_shaded_tool = NULL;
471
if (! canvas->window)
473
g_warning ("%s: called unrealized", G_STRFUNC);
581
GimpDisplay *display;
584
GdkDisplay *gdk_display;
585
GimpTool *active_tool;
586
GimpCoords display_coords;
587
GimpCoords image_coords;
588
GdkModifierType state;
590
gboolean return_val = FALSE;
591
gboolean update_sw_cursor = FALSE;
593
g_return_val_if_fail (GTK_WIDGET_REALIZED (canvas), FALSE);
477
595
/* are we in destruction? */
478
if (! shell->gdisp || ! shell->gdisp->shell)
596
if (! shell->display || ! shell->display->shell)
481
599
/* set the active display before doing any other canvas event processing */
482
600
if (gimp_display_shell_events (canvas, event, shell))
485
gdisp = shell->gdisp;
486
gimage = gdisp->gimage;
603
display = shell->display;
604
image = display->image;
489
607
gdk_display = gtk_widget_get_display (canvas);
630
754
/* in "click to focus" mode, the BUTTON_PRESS arrives before
631
755
* FOCUS_IN, so we have to update the tool's modifier state here
633
tool_manager_focus_display_active (gimp, gdisp);
634
tool_manager_modifier_state_active (gimp, state, gdisp);
757
tool_manager_focus_display_active (gimp, display);
758
tool_manager_modifier_state_active (gimp, state, display);
636
760
tool_manager_oper_update_active (gimp,
637
761
&image_coords, state,
640
765
active_tool = tool_manager_get_active (gimp);
644
if ((! gimp_image_is_empty (gimage) ||
645
gimp_tool_control_handles_empty_image (active_tool->control)) &&
769
if ((! gimp_image_is_empty (image) ||
770
gimp_tool_control_get_handle_empty_image (active_tool->control)) &&
646
771
(bevent->button == 1 ||
647
772
bevent->button == 2 ||
648
773
bevent->button == 3))
650
775
tool_manager_cursor_update_active (gimp,
651
776
&image_coords, state,
654
else if (gimp_image_is_empty (gimage))
779
else if (gimp_image_is_empty (image) &&
780
! gimp_tool_control_get_handle_empty_image (active_tool->control))
656
782
gimp_display_shell_set_cursor (shell,
658
784
gimp_tool_control_get_tool_cursor (active_tool->control),
659
GIMP_CURSOR_MODIFIER_NONE);
785
GIMP_CURSOR_MODIFIER_BAD);
664
790
gimp_display_shell_set_cursor (shell,
666
792
GIMP_TOOL_CURSOR_NONE,
667
GIMP_CURSOR_MODIFIER_NONE);
793
GIMP_CURSOR_MODIFIER_BAD);
670
796
shell->button_press_before_focus = TRUE;
793
915
gtk_grab_add (canvas);
795
917
if (active_tool &&
796
(! gimp_image_is_empty (gimage) ||
797
gimp_tool_control_handles_empty_image (active_tool->control)))
918
(! gimp_image_is_empty (image) ||
919
gimp_tool_control_get_handle_empty_image (active_tool->control)))
799
921
if (gimp_tool_control_is_active (active_tool->control))
801
923
tool_manager_button_release_active (gimp,
808
930
/* update the tool's modifier state because it didn't get
809
931
* key events while BUTTON1 was down
811
tool_manager_focus_display_active (gimp, gdisp);
812
tool_manager_modifier_state_active (gimp, state, gdisp);
933
tool_manager_focus_display_active (gimp, display);
934
tool_manager_modifier_state_active (gimp, state, display);
814
936
tool_manager_oper_update_active (gimp,
815
937
&image_coords, state,
818
941
gtk_grab_remove (canvas);
820
943
if (shell->space_release_pending)
822
#ifdef DEBUG_MOVE_PUSH
823
g_printerr ("%s: popping move tool\n", G_STRFUNC);
826
gimp_context_set_tool (gimp_get_user_context (gimp),
828
space_shaded_tool = NULL;
830
tool_manager_focus_display_active (gimp, gdisp);
831
tool_manager_modifier_state_active (gimp, state, gdisp);
833
tool_manager_oper_update_active (gimp,
834
&image_coords, state,
837
shell->space_release_pending = FALSE;
839
gdk_display_keyboard_ungrab (gdk_display, time);
944
gimp_display_shell_space_released (shell, state, time);
844
948
state &= ~GDK_BUTTON2_MASK;
846
shell->scrolling = FALSE;
847
shell->scroll_start_x = 0;
848
shell->scroll_start_y = 0;
850
gtk_grab_remove (canvas);
852
gimp_display_shell_unset_override_cursor (shell);
949
gimp_display_shell_stop_scrolling (shell);
1043
1151
mevent->y < 0 ||
1044
1152
mevent->x > shell->disp_width ||
1045
1153
mevent->y > shell->disp_height) &&
1046
! gimp_tool_control_scroll_lock (active_tool->control))
1154
! gimp_tool_control_get_scroll_lock (active_tool->control))
1051
/* The cases for scrolling */
1054
else if (mevent->x > shell->disp_width)
1055
off_x = mevent->x - shell->disp_width;
1059
else if (mevent->y > shell->disp_height)
1060
off_y = mevent->y - shell->disp_height;
1062
if (gimp_display_shell_scroll (shell, off_x, off_y))
1064
GimpCoords device_coords;
1066
gimp_display_shell_get_device_coords (shell,
1070
if (device_coords.x == mevent->x &&
1071
device_coords.y == mevent->y
1073
/* The Win32 backend for GDK just returns the
1074
* coordinates from the last motion/button event
1075
* for extended input devices, so if the event is
1076
* put back in the queue, this will keep scrolling
1077
* until the edge of the image is reached (bug
1079
&& mevent->device == gdk_display_get_core_pointer (
1080
gdk_display_get_default ())
1081
#endif /* G_OS_WIN32 */
1084
/* Put this event back on the queue
1085
* so it keeps scrolling
1087
gdk_event_put ((GdkEvent *) mevent);
1156
gimp_display_shell_autoscroll_start (shell, state, mevent);
1092
if (gimp_tool_control_motion_mode (active_tool->control) ==
1159
if (gimp_tool_control_get_motion_mode (active_tool->control) ==
1093
1160
GIMP_MOTION_MODE_EXACT &&
1094
1161
gdk_device_get_history (mevent->device, mevent->window,
1095
1162
shell->last_motion_time,
1140
1207
tool_manager_motion_active (gimp,
1141
1208
&image_coords, time, state,
1145
1212
shell->last_motion_time = mevent->time;
1148
else if (state & GDK_BUTTON2_MASK)
1150
if (shell->scrolling)
1152
gimp_display_shell_scroll (shell,
1153
(shell->scroll_start_x - mevent->x -
1155
(shell->scroll_start_y - mevent->y -
1161
1217
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
1163
1219
tool_manager_oper_update_active (gimp,
1164
1220
&image_coords, state,
1170
1227
case GDK_KEY_PRESS:
1172
GdkEventKey *kevent = (GdkEventKey *) event;
1174
tool_manager_focus_display_active (gimp, gdisp);
1176
switch (kevent->keyval)
1187
if (gimp_image_is_empty (gimage) ||
1188
! tool_manager_key_press_active (gimp,
1228
if (state & GDK_BUTTON1_MASK)
1230
GdkEventKey *kevent = (GdkEventKey *) event;
1232
switch (kevent->keyval)
1234
case GDK_Alt_L: case GDK_Alt_R:
1235
case GDK_Shift_L: case GDK_Shift_R:
1236
case GDK_Control_L: case GDK_Control_R:
1192
GimpController *keyboard;
1194
keyboard = gimp_controllers_get_keyboard (gimp);
1197
gimp_controller_keyboard_key_press (GIMP_CONTROLLER_KEYBOARD (keyboard),
1238
GdkModifierType key;
1240
key = gimp_display_shell_key_to_state (kevent->keyval);
1244
gimp_tool_control_is_active (active_tool->control) &&
1245
! gimp_image_is_empty (image))
1247
tool_manager_active_modifier_state_active (gimp, state,
1256
GdkEventKey *kevent = (GdkEventKey *) event;
1258
tool_manager_focus_display_active (gimp, display);
1260
switch (kevent->keyval)
1206
active_tool = tool_manager_get_active (gimp);
1209
! shell->space_pressed && ! GIMP_IS_MOVE_TOOL (active_tool))
1211
GimpToolInfo *move_tool_info;
1213
move_tool_info = (GimpToolInfo *)
1214
gimp_container_get_child_by_name (gimp->tool_info_list,
1217
if (GIMP_IS_TOOL_INFO (move_tool_info))
1271
if (gimp_image_is_empty (image) ||
1272
! tool_manager_key_press_active (gimp,
1276
GimpController *keyboard = gimp_controllers_get_keyboard (gimp);
1279
gimp_controller_keyboard_key_press (GIMP_CONTROLLER_KEYBOARD (keyboard),
1287
gimp_display_shell_space_pressed (shell, state, time);
1292
case GDK_ISO_Left_Tab:
1293
if (state & GDK_CONTROL_MASK)
1295
if (! gimp_image_is_empty (image))
1219
#ifdef DEBUG_MOVE_PUSH
1220
g_printerr ("%s: pushing move tool\n", G_STRFUNC);
1223
space_shaded_tool = active_tool->tool_info;
1225
gdk_keyboard_grab (canvas->window, FALSE, time);
1227
gimp_context_set_tool (gimp_get_user_context (gimp),
1230
tool_manager_focus_display_active (gimp, gdisp);
1231
tool_manager_modifier_state_active (gimp, state, gdisp);
1233
shell->space_pressed = TRUE;
1297
if (kevent->keyval == GDK_Tab)
1298
gimp_display_shell_layer_select_init (shell,
1301
gimp_display_shell_layer_select_init (shell,
1307
gimp_dialog_factories_toggle ();
1313
/* Update the state based on modifiers being pressed */
1314
case GDK_Alt_L: case GDK_Alt_R:
1315
case GDK_Shift_L: case GDK_Shift_R:
1316
case GDK_Control_L: case GDK_Control_R:
1318
GdkModifierType key;
1320
key = gimp_display_shell_key_to_state (kevent->keyval);
1323
if (! gimp_image_is_empty (image))
1324
tool_manager_modifier_state_active (gimp, state, display);
1242
case GDK_ISO_Left_Tab:
1243
if (state & GDK_CONTROL_MASK)
1330
tool_manager_oper_update_active (gimp,
1331
&image_coords, state,
1337
case GDK_KEY_RELEASE:
1338
if (state & GDK_BUTTON1_MASK)
1340
GdkEventKey *kevent = (GdkEventKey *) event;
1342
switch (kevent->keyval)
1344
case GDK_Alt_L: case GDK_Alt_R:
1345
case GDK_Shift_L: case GDK_Shift_R:
1346
case GDK_Control_L: case GDK_Control_R:
1245
if (! gimp_image_is_empty (gimage))
1348
GdkModifierType key;
1350
key = gimp_display_shell_key_to_state (kevent->keyval);
1354
gimp_tool_control_is_active (active_tool->control) &&
1355
! gimp_image_is_empty (image))
1247
if (kevent->keyval == GDK_Tab)
1248
gimp_display_shell_layer_select_init (shell,
1251
gimp_display_shell_layer_select_init (shell,
1357
tool_manager_active_modifier_state_active (gimp, state,
1366
GdkEventKey *kevent = (GdkEventKey *) event;
1368
tool_manager_focus_display_active (gimp, display);
1370
switch (kevent->keyval)
1373
gimp_display_shell_space_released (shell, state, time);
1377
/* Update the state based on modifiers being pressed */
1378
case GDK_Alt_L: case GDK_Alt_R:
1379
case GDK_Shift_L: case GDK_Shift_R:
1380
case GDK_Control_L: case GDK_Control_R:
1257
GimpDialogFactory *dialog_factory;
1259
dialog_factory = gimp_dialog_factory_from_name ("toolbox");
1261
/* Hide or show all dialogs */
1262
gimp_dialog_factories_toggle (dialog_factory, FALSE);
1382
GdkModifierType key;
1384
key = gimp_display_shell_key_to_state (kevent->keyval);
1387
/* For all modifier keys: call the tools modifier_state *and*
1388
* oper_update method so tools can choose if they are interested
1389
* in the press itself or only in the resulting state
1391
if (! gimp_image_is_empty (image))
1392
tool_manager_modifier_state_active (gimp, state, display);
1268
/* Update the state based on modifiers being pressed */
1269
case GDK_Alt_L: case GDK_Alt_R:
1270
case GDK_Shift_L: case GDK_Shift_R:
1271
case GDK_Control_L: case GDK_Control_R:
1273
GdkModifierType key;
1275
key = gimp_display_shell_key_to_state (kevent->keyval);
1278
/* For all modifier keys: call the tools modifier_state *and*
1279
* oper_update method so tools can choose if they are interested
1280
* in the release itself or only in the resulting state
1282
if (! gimp_image_is_empty (gimage))
1283
tool_manager_modifier_state_active (gimp, state, gdisp);
1289
tool_manager_oper_update_active (gimp,
1290
&image_coords, state,
1295
case GDK_KEY_RELEASE:
1297
GdkEventKey *kevent = (GdkEventKey *) event;
1299
tool_manager_focus_display_active (gimp, gdisp);
1301
switch (kevent->keyval)
1304
if (shell->space_pressed)
1306
#ifdef DEBUG_MOVE_PUSH
1307
g_printerr ("%s: popping move tool\n", G_STRFUNC);
1310
gimp_context_set_tool (gimp_get_user_context (gimp),
1312
space_shaded_tool = NULL;
1314
tool_manager_focus_display_active (gimp, gdisp);
1315
tool_manager_modifier_state_active (gimp, state, gdisp);
1317
shell->space_pressed = FALSE;
1319
gdk_display_keyboard_ungrab (gdk_display, time);
1325
/* Update the state based on modifiers being pressed */
1326
case GDK_Alt_L: case GDK_Alt_R:
1327
case GDK_Shift_L: case GDK_Shift_R:
1328
case GDK_Control_L: case GDK_Control_R:
1330
GdkModifierType key;
1332
key = gimp_display_shell_key_to_state (kevent->keyval);
1335
/* For all modifier keys: call the tools modifier_state *and*
1336
* oper_update method so tools can choose if they are interested
1337
* in the press itself or only in the resulting state
1339
if (! gimp_image_is_empty (gimage))
1340
tool_manager_modifier_state_active (gimp, state, gdisp);
1346
tool_manager_oper_update_active (gimp,
1347
&image_coords, state,
1398
tool_manager_oper_update_active (gimp,
1399
&image_coords, state,
1402
1456
return return_val;
1460
gimp_display_shell_ruler_button_press (GtkWidget *widget,
1461
GdkEventButton *event,
1462
GimpDisplayShell *shell,
1463
gboolean horizontal)
1465
GimpDisplay *display = shell->display;
1467
if (display->image->gimp->busy)
1470
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
1472
GimpTool *active_tool;
1473
gboolean sample_point;
1475
active_tool = tool_manager_get_active (display->image->gimp);
1476
sample_point = (event->state & GDK_CONTROL_MASK);
1478
if (! ((sample_point && (GIMP_IS_COLOR_TOOL (active_tool) &&
1479
! (GIMP_IS_PAINT_TOOL (active_tool) &&
1480
! GIMP_PAINT_TOOL (active_tool)->pick_colors)))
1484
(! sample_point && GIMP_IS_MOVE_TOOL (active_tool))))
1486
GimpToolInfo *tool_info;
1488
tool_info = gimp_get_tool_info (display->image->gimp,
1490
"gimp-color-picker-tool" :
1494
gimp_context_set_tool (gimp_get_user_context (display->image->gimp),
1498
active_tool = tool_manager_get_active (display->image->gimp);
1502
gdk_pointer_grab (shell->canvas->window, FALSE,
1503
GDK_POINTER_MOTION_HINT_MASK |
1504
GDK_BUTTON1_MOTION_MASK |
1505
GDK_BUTTON_RELEASE_MASK,
1506
NULL, NULL, event->time);
1508
gdk_keyboard_grab (shell->canvas->window, FALSE, event->time);
1511
gimp_color_tool_start_sample_point (active_tool, display);
1512
else if (horizontal)
1513
gimp_move_tool_start_hguide (active_tool, display);
1515
gimp_move_tool_start_vguide (active_tool, display);
1406
1523
gimp_display_shell_hruler_button_press (GtkWidget *widget,
1407
1524
GdkEventButton *event,
1408
1525
GimpDisplayShell *shell)
1410
GimpDisplay *gdisp = shell->gdisp;
1412
if (gdisp->gimage->gimp->busy)
1415
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
1417
GimpToolInfo *tool_info;
1419
tool_info = (GimpToolInfo *)
1420
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
1425
GimpTool *active_tool;
1427
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
1430
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
1434
gdk_pointer_grab (shell->canvas->window, FALSE,
1435
GDK_POINTER_MOTION_HINT_MASK |
1436
GDK_BUTTON1_MOTION_MASK |
1437
GDK_BUTTON_RELEASE_MASK,
1438
NULL, NULL, event->time);
1440
gdk_keyboard_grab (shell->canvas->window, FALSE, event->time);
1442
gimp_move_tool_start_hguide (active_tool, gdisp);
1527
return gimp_display_shell_ruler_button_press (widget, event, shell, TRUE);
1574
1617
gimp_display_shell_scroll (shell, (adjustment->value - shell->offset_x), 0);
1578
gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
1583
if (gdk_event_get_axis (event, GDK_AXIS_X, &coords->x))
1585
gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y);
1587
/* CLAMP() the return value of each *_get_axis() call to be safe
1588
* against buggy XInput drivers. Provide default values if the
1589
* requested axis does not exist.
1592
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure))
1593
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
1594
GIMP_COORDS_MAX_PRESSURE);
1596
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
1598
if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt))
1599
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
1600
GIMP_COORDS_MAX_TILT);
1602
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
1604
if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt))
1605
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
1606
GIMP_COORDS_MAX_TILT);
1608
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
1610
if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel))
1611
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
1612
GIMP_COORDS_MAX_WHEEL);
1614
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
1619
gimp_display_shell_get_device_coords (shell, device, coords);
1625
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
1629
gdouble axes[GDK_AXIS_LAST];
1631
gdk_device_get_state (device, shell->canvas->window, axes, NULL);
1633
gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
1634
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
1636
/* CLAMP() the return value of each *_get_axis() call to be safe
1637
* against buggy XInput drivers. Provide default values if the
1638
* requested axis does not exist.
1641
if (gdk_device_get_axis (device, axes, GDK_AXIS_PRESSURE, &coords->pressure))
1642
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
1643
GIMP_COORDS_MAX_PRESSURE);
1645
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
1647
if (gdk_device_get_axis (device, axes, GDK_AXIS_XTILT, &coords->xtilt))
1648
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
1649
GIMP_COORDS_MAX_TILT);
1651
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
1653
if (gdk_device_get_axis (device, axes, GDK_AXIS_YTILT, &coords->ytilt))
1654
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
1655
GIMP_COORDS_MAX_TILT);
1657
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
1659
if (gdk_device_get_axis (device, axes, GDK_AXIS_WHEEL, &coords->wheel))
1660
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
1661
GIMP_COORDS_MAX_WHEEL);
1663
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
1667
gimp_display_shell_get_time_coords (GimpDisplayShell *shell,
1669
GdkTimeCoord *event,
1672
gdk_device_get_axis (device, event->axes, GDK_AXIS_X, &coords->x);
1673
gdk_device_get_axis (device, event->axes, GDK_AXIS_Y, &coords->y);
1675
/* CLAMP() the return value of each *_get_axis() call to be safe
1676
* against buggy XInput drivers. Provide default values if the
1677
* requested axis does not exist.
1680
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_PRESSURE, &coords->pressure))
1681
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
1682
GIMP_COORDS_MAX_PRESSURE);
1684
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
1686
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_XTILT, &coords->xtilt))
1687
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
1688
GIMP_COORDS_MAX_TILT);
1690
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
1692
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_YTILT, &coords->ytilt))
1693
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
1694
GIMP_COORDS_MAX_TILT);
1696
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
1698
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_WHEEL, &coords->wheel))
1699
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
1700
GIMP_COORDS_MAX_WHEEL);
1702
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
1706
gimp_display_shell_get_event_state (GimpDisplayShell *shell,
1709
GdkModifierType *state)
1711
if (gdk_event_get_state (event, state))
1714
gimp_display_shell_get_device_state (shell, device, state);
1720
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
1722
GdkModifierType *state)
1724
gdk_device_get_state (device, shell->canvas->window, NULL, state);
1727
1620
static GdkModifierType
1728
1621
gimp_display_shell_key_to_state (gint key)