1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools/tools-types.h"
|
2001-04-07 23:58:26 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-11-30 00:44:51 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-11-30 22:41:56 +08:00
|
|
|
#include "core/gimpimage-qmask.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-04-21 15:31:12 +08:00
|
|
|
#include "libgimptool/gimptoolcontrol.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tools/gimpmovetool.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "widgets/gimpcursor.h"
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2001-07-20 18:07:51 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2001-11-30 22:41:56 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
#include "gui/dialogs.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-cursor.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "gimpdisplayshell-layer-select.h"
|
2002-11-24 06:22:21 +08:00
|
|
|
#include "gimpdisplayshell-render.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-title.h"
|
|
|
|
#include "gimpdisplayshell-transform.h"
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "gimpnavigationview.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
static void gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
2003-02-03 23:03:11 +08:00
|
|
|
static gboolean gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
|
2001-12-01 00:39:40 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords);
|
|
|
|
static void gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords);
|
2003-02-03 23:03:11 +08:00
|
|
|
static gboolean gimp_display_shell_get_event_state (GimpDisplayShell *shell,
|
2002-05-16 00:28:41 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state);
|
|
|
|
static void gimp_display_shell_get_device_state (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state);
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static GdkModifierType
|
2001-12-01 00:39:40 +08:00
|
|
|
gimp_display_shell_key_to_state (gint key);
|
1999-05-05 17:10:35 +08:00
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
static void gimp_display_shell_update_tool_modifiers (GimpDisplayShell *shell,
|
|
|
|
GdkModifierType old_state,
|
|
|
|
GdkModifierType current_state);
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void gimp_display_shell_origin_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gpointer data);
|
2002-05-24 10:20:20 +08:00
|
|
|
static void gimp_display_shell_origin_menu_popup (GimpDisplayShell *shell,
|
|
|
|
guint button,
|
|
|
|
guint32 time);
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2002-03-19 21:14:25 +08:00
|
|
|
GdkEvent * gimp_display_shell_compress_motion (GimpDisplayShell *shell);
|
|
|
|
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* public functions */
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDisplayShell *shell)
|
1999-06-04 02:28:39 +08:00
|
|
|
{
|
2003-02-26 03:12:11 +08:00
|
|
|
Gimp *gimp = shell->gdisp->gimage->gimp;
|
|
|
|
gboolean set_display = FALSE;
|
|
|
|
GdkEventKey *kevent;
|
2002-05-16 00:28:41 +08:00
|
|
|
|
1999-06-04 02:28:39 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_KEY_PRESS:
|
2002-05-16 00:28:41 +08:00
|
|
|
case GDK_KEY_RELEASE:
|
|
|
|
if (gimp->busy)
|
|
|
|
return TRUE;
|
|
|
|
|
2003-02-26 03:12:11 +08:00
|
|
|
kevent = (GdkEventKey *) event;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
/* do not process any key events while BUTTON1 is down. We do this
|
|
|
|
* so tools keep the modifier state they were in when BUTTON1 was
|
|
|
|
* pressed and to prevent accelerators from being invoked.
|
|
|
|
*/
|
|
|
|
if (kevent->state & GDK_BUTTON1_MASK)
|
|
|
|
{
|
|
|
|
if (event->type == GDK_KEY_PRESS)
|
|
|
|
{
|
|
|
|
if (kevent->keyval == GDK_space && shell->space_release_pending)
|
|
|
|
{
|
|
|
|
shell->space_pressed = TRUE;
|
|
|
|
shell->space_release_pending = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (kevent->keyval == GDK_space && shell->space_pressed)
|
|
|
|
{
|
|
|
|
shell->space_pressed = FALSE;
|
|
|
|
shell->space_release_pending = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
2003-02-26 03:12:11 +08:00
|
|
|
case GDK_Left: case GDK_Right:
|
|
|
|
case GDK_Up: case GDK_Down:
|
2002-05-16 00:28:41 +08:00
|
|
|
case GDK_space:
|
|
|
|
case GDK_Tab:
|
2003-02-26 03:12:11 +08:00
|
|
|
case GDK_Alt_L: case GDK_Alt_R:
|
|
|
|
case GDK_Shift_L: case GDK_Shift_R:
|
2002-05-16 00:28:41 +08:00
|
|
|
case GDK_Control_L: case GDK_Control_R:
|
|
|
|
break;
|
|
|
|
|
2003-03-11 09:22:57 +08:00
|
|
|
case GDK_Escape:
|
|
|
|
if (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
gimp_display_shell_toggle_fullscreen (shell);
|
|
|
|
break;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
default:
|
|
|
|
if (shell->space_pressed)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_display = TRUE;
|
|
|
|
break;
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_SCROLL:
|
2002-05-16 00:28:41 +08:00
|
|
|
set_display = TRUE;
|
1999-06-04 02:28:39 +08:00
|
|
|
break;
|
2002-05-16 00:28:41 +08:00
|
|
|
|
2003-03-11 09:22:57 +08:00
|
|
|
case GDK_WINDOW_STATE:
|
|
|
|
{
|
|
|
|
GdkEventWindowState *sevent;
|
|
|
|
gboolean fullscreen;
|
|
|
|
|
|
|
|
sevent = (GdkEventWindowState *) event;
|
|
|
|
|
|
|
|
shell->window_state = sevent->new_window_state;
|
|
|
|
|
|
|
|
fullscreen = shell->window_state & GDK_WINDOW_STATE_FULLSCREEN;
|
|
|
|
|
|
|
|
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->menubar_factory),
|
|
|
|
"/View/Fullscreen",
|
|
|
|
fullscreen);
|
|
|
|
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->popup_factory),
|
|
|
|
"/View/Fullscreen",
|
|
|
|
fullscreen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-06-04 02:28:39 +08:00
|
|
|
default:
|
|
|
|
break;
|
1999-06-20 21:53:15 +08:00
|
|
|
}
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
if (set_display)
|
|
|
|
{
|
2003-02-27 03:03:06 +08:00
|
|
|
Gimp *gimp = shell->gdisp->gimage->gimp;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
/* Setting the context's display automatically sets the image, too */
|
2003-02-27 03:03:06 +08:00
|
|
|
gimp_context_set_display (gimp_get_user_context (gimp), shell->gdisp);
|
2002-05-16 00:28:41 +08:00
|
|
|
}
|
|
|
|
|
1999-06-04 02:28:39 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_realize (GtkWidget *canvas,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2002-11-24 06:22:21 +08:00
|
|
|
GimpDisplayConfig *config;
|
|
|
|
GimpDisplay *gdisp;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gdisp = shell->gdisp;
|
|
|
|
config = GIMP_DISPLAY_CONFIG (gdisp->gimage->gimp->config);
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gtk_widget_grab_focus (shell->canvas);
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
shell->padding_gc = gdk_gc_new (canvas->window);
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_display_shell_set_padding (shell,
|
|
|
|
shell->padding_mode,
|
|
|
|
&shell->padding_color);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gdk_window_set_back_pixmap (shell->canvas->window, NULL, FALSE);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
|
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gimp_display_shell_update_title (shell);
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
/* create the selection object */
|
2001-11-11 07:03:22 +08:00
|
|
|
shell->select = gimp_display_shell_selection_create (canvas->window,
|
|
|
|
shell,
|
|
|
|
gdisp->gimage->height,
|
2002-11-24 08:03:42 +08:00
|
|
|
gdisp->gimage->width);
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
shell->disp_width = canvas->allocation.width;
|
|
|
|
shell->disp_height = canvas->allocation.height;
|
|
|
|
|
2001-12-01 02:23:49 +08:00
|
|
|
/* create GC for rendering */
|
|
|
|
shell->render_gc = gdk_gc_new (shell->canvas->window);
|
|
|
|
gdk_gc_set_exposures (shell->render_gc, TRUE);
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
/* set up the scrollbar observers */
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->hsbdata, "value_changed",
|
2001-11-02 17:31:21 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_hscrollbar_update),
|
|
|
|
shell);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->vsbdata, "value_changed",
|
2001-11-02 17:31:21 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_vscrollbar_update),
|
|
|
|
shell);
|
|
|
|
|
|
|
|
/* setup scale properly */
|
|
|
|
gimp_display_shell_scale_setup (shell);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
|
|
|
/* set the initial cursor */
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_display_shell_set_cursor (shell,
|
|
|
|
GDK_TOP_LEFT_ARROW,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2002-01-26 02:34:33 +08:00
|
|
|
|
|
|
|
/* allow shrinking */
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
|
2001-11-02 17:31:21 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_configure (GtkWidget *widget,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2001-12-01 00:39:40 +08:00
|
|
|
if ((shell->disp_width != shell->canvas->allocation.width) ||
|
|
|
|
(shell->disp_height != shell->canvas->allocation.height))
|
|
|
|
{
|
|
|
|
shell->disp_width = shell->canvas->allocation.width;
|
|
|
|
shell->disp_height = shell->canvas->allocation.height;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-01-08 02:57:58 +08:00
|
|
|
gimp_display_shell_scroll_clamp_offsets (shell);
|
|
|
|
gimp_display_shell_scale_setup (shell);
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
return TRUE;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2003-02-21 20:16:43 +08:00
|
|
|
GdkRectangle *rects;
|
|
|
|
gint n_rects;
|
|
|
|
gint i;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
/* pause the currently active tool */
|
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
|
|
|
|
shell->gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gdk_region_get_rectangles (eevent->region, &rects, &n_rects);
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
gimp_display_shell_draw_area (shell,
|
|
|
|
rects[i].x,
|
|
|
|
rects[i].y,
|
|
|
|
rects[i].width,
|
|
|
|
rects[i].height);
|
|
|
|
|
|
|
|
g_free (rects);
|
|
|
|
|
|
|
|
/* draw the guides */
|
|
|
|
gimp_display_shell_draw_guides (shell);
|
|
|
|
|
|
|
|
/* and the cursor (if we have a software cursor) */
|
|
|
|
if (shell->have_cursor)
|
|
|
|
gimp_display_shell_draw_cursor (shell);
|
|
|
|
|
|
|
|
/* restart (and recalculate) the selection boundaries */
|
|
|
|
gimp_display_shell_selection_start (shell->select, TRUE);
|
|
|
|
|
|
|
|
/* start the currently active tool */
|
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
|
|
|
|
shell->gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
GdkDevice *current_device;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
current_device = gimp_devices_get_current (shell->gdisp->gimage->gimp);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
shell->draw_cursor = ! current_device->has_cursor;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2003-02-26 03:12:11 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_popup_menu (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
gimp_display_shell_origin_menu_popup (GIMP_DISPLAY_SHELL (widget), 0, 0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-12-01 00:39:40 +08:00
|
|
|
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-11-30 22:41:56 +08:00
|
|
|
GimpImage *gimage;
|
2002-11-19 04:50:31 +08:00
|
|
|
Gimp *gimp;
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords display_coords;
|
|
|
|
GimpCoords image_coords;
|
|
|
|
GdkModifierType state;
|
|
|
|
guint32 time;
|
2001-11-02 17:31:21 +08:00
|
|
|
gboolean return_val = FALSE;
|
|
|
|
gboolean update_cursor = FALSE;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
static GdkModifierType button_press_state = 0;
|
|
|
|
static GdkModifierType space_press_state = 0;
|
|
|
|
|
|
|
|
static GimpToolInfo *space_shaded_tool = NULL;
|
2001-11-30 22:41:56 +08:00
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
static gboolean scrolling = FALSE;
|
|
|
|
static gint scroll_start_x = 0;
|
|
|
|
static gint scroll_start_y = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-20 05:19:49 +08:00
|
|
|
static gboolean button_press_before_focus = FALSE;
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
if (! canvas->window)
|
2001-11-02 17:31:21 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
g_warning ("%s: called unrealized", G_STRLOC);
|
2001-11-02 17:31:21 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1998-02-05 08:07:31 +08:00
|
|
|
|
2002-06-20 05:19:49 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-11-30 22:41:56 +08:00
|
|
|
gimage = gdisp->gimage;
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp = gimage->gimp;
|
2001-11-30 22:41:56 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
/* Find out what device the event occurred upon */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (! gimp->busy && gimp_devices_check_change (gimp, event))
|
2001-12-02 05:02:34 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_check_device_cursor (shell);
|
|
|
|
}
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2003-02-03 23:03:11 +08:00
|
|
|
gimp_display_shell_get_event_coords (shell, event,
|
|
|
|
gimp_devices_get_current (gimp),
|
|
|
|
&display_coords);
|
|
|
|
gimp_display_shell_get_event_state (shell, event,
|
|
|
|
gimp_devices_get_current (gimp),
|
|
|
|
&state);
|
2001-11-09 03:14:51 +08:00
|
|
|
time = gdk_event_get_time (event);
|
|
|
|
|
|
|
|
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_ENTER_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventCrossing *cevent;
|
|
|
|
|
|
|
|
cevent = (GdkEventCrossing *) event;
|
|
|
|
|
|
|
|
if (cevent->mode != GDK_CROSSING_NORMAL)
|
|
|
|
return TRUE;
|
|
|
|
}
|
1998-06-06 11:49:01 +08:00
|
|
|
break;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventCrossing *cevent;
|
|
|
|
|
|
|
|
cevent = (GdkEventCrossing *) event;
|
|
|
|
|
|
|
|
if (cevent->mode != GDK_CROSSING_NORMAL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
gimp_display_shell_update_cursor (shell, -1, -1);
|
|
|
|
|
|
|
|
shell->proximity = FALSE;
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_PROXIMITY_IN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_PROXIMITY_OUT:
|
|
|
|
shell->proximity = FALSE;
|
1998-06-06 11:49:01 +08:00
|
|
|
break;
|
|
|
|
|
2002-06-20 05:19:49 +08:00
|
|
|
case GDK_FOCUS_CHANGE:
|
|
|
|
{
|
|
|
|
GdkEventFocus *fevent;
|
|
|
|
|
|
|
|
fevent = (GdkEventFocus *) event;
|
|
|
|
|
|
|
|
if (fevent->in)
|
|
|
|
{
|
|
|
|
GTK_WIDGET_SET_FLAGS (canvas, GTK_HAS_FOCUS);
|
|
|
|
|
|
|
|
/* press modifier keys when the canvas gets the focus
|
|
|
|
*
|
|
|
|
* in "click to focus" mode, we did this on BUTTON_PRESS, so
|
|
|
|
* do it here only if button_press_before_focus is FALSE
|
|
|
|
*/
|
|
|
|
if (state && ! button_press_before_focus)
|
|
|
|
{
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, 0, state);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2002-06-20 05:19:49 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (canvas, GTK_HAS_FOCUS);
|
|
|
|
|
|
|
|
/* reset it here to be prepared for the next
|
|
|
|
* FOCUS_IN / BUTTON_PRESS confusion
|
|
|
|
*/
|
|
|
|
button_press_before_focus = FALSE;
|
|
|
|
|
|
|
|
/* release modifier keys when the canvas loses the focus */
|
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, state, 0);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2002-06-20 05:19:49 +08:00
|
|
|
&image_coords, 0,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stop the signal because otherwise gtk+ exposes the whole
|
|
|
|
* canvas to get the non-existant focus indicator drawn
|
|
|
|
*/
|
|
|
|
return_val = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
2002-06-20 05:19:49 +08:00
|
|
|
/* in "click to focus" mode, the BUTTON_PRESS arrives before
|
|
|
|
* FOCUS_IN, so we have to update the tool's modifier state here
|
|
|
|
*/
|
|
|
|
if (state && ! GTK_WIDGET_HAS_FOCUS (canvas))
|
|
|
|
{
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, 0, state);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2002-06-20 05:19:49 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
|
|
|
|
button_press_before_focus = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
/* ignore new mouse events */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2001-11-15 01:12:51 +08:00
|
|
|
|
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
state |= GDK_BUTTON1_MASK;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
if (((gimp_tool_control_motion_mode (active_tool->control) ==
|
|
|
|
GIMP_MOTION_MODE_EXACT) &&
|
2002-11-19 04:50:31 +08:00
|
|
|
GIMP_DISPLAY_CONFIG (gimp->config)->perfect_mouse) ||
|
2002-03-19 21:14:25 +08:00
|
|
|
|
|
|
|
/* don't request motion hins for XInput devices because
|
|
|
|
* the wacom driver is known to report crappy hints
|
|
|
|
* (#6901) --mitch
|
|
|
|
*/
|
2002-11-19 04:50:31 +08:00
|
|
|
(gimp_devices_get_current (gimp) !=
|
2002-03-19 21:14:25 +08:00
|
|
|
gdk_device_get_core_pointer ()))
|
2002-02-05 19:35:03 +08:00
|
|
|
{
|
|
|
|
gdk_pointer_grab (canvas->window, FALSE,
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, time);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_pointer_grab (canvas->window, FALSE,
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, time);
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* save the current modifier state because tools don't get
|
|
|
|
* key events while BUTTON1 is down
|
2001-11-15 01:12:51 +08:00
|
|
|
*/
|
2002-05-16 00:28:41 +08:00
|
|
|
button_press_state = state;
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
if (active_tool &&
|
|
|
|
(! gimp_image_is_empty (gimage) ||
|
|
|
|
gimp_tool_control_handles_empty_image (active_tool->control)))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-05-16 00:28:41 +08:00
|
|
|
if (gimp_tool_control_auto_snap_to (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize the current tool if it has no drawable
|
|
|
|
*/
|
|
|
|
if (! active_tool->drawable)
|
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_initialize_active (gimp, gdisp);
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
2001-11-30 00:44:51 +08:00
|
|
|
else if ((active_tool->drawable !=
|
2001-11-30 22:41:56 +08:00
|
|
|
gimp_image_active_drawable (gimage)) &&
|
2002-05-16 00:28:41 +08:00
|
|
|
! gimp_tool_control_preserve (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
/* create a new one, deleting the current
|
|
|
|
*/
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp_context_tool_changed (gimp_get_user_context (gimp));
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_initialize_active (gimp, gdisp);
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_button_press_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, time, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
state |= GDK_BUTTON2_MASK;
|
|
|
|
|
|
|
|
scrolling = TRUE;
|
|
|
|
|
|
|
|
scroll_start_x = bevent->x + shell->offset_x;
|
|
|
|
scroll_start_y = bevent->y + shell->offset_y;
|
|
|
|
|
|
|
|
gtk_grab_add (canvas);
|
|
|
|
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_display_shell_set_override_cursor (shell, GDK_FLEUR);
|
2001-11-15 01:12:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
state |= GDK_BUTTON3_MASK;
|
2002-12-14 22:13:54 +08:00
|
|
|
gimp_item_factory_popup_with_data (shell->popup_factory,
|
2003-01-12 20:35:00 +08:00
|
|
|
gdisp,
|
2002-12-14 22:13:54 +08:00
|
|
|
NULL);
|
2001-11-15 01:12:51 +08:00
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
state &= ~GDK_BUTTON1_MASK;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
if (active_tool &&
|
|
|
|
(! gimp_image_is_empty (gimage) ||
|
|
|
|
gimp_tool_control_handles_empty_image (active_tool->control)))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-05-16 00:28:41 +08:00
|
|
|
if (gimp_tool_control_is_active (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-05-16 00:28:41 +08:00
|
|
|
if (gimp_tool_control_auto_snap_to (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_button_release_active (gimp,
|
2003-02-27 03:03:06 +08:00
|
|
|
&image_coords,
|
|
|
|
time, state,
|
2001-11-15 01:12:51 +08:00
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
|
2002-02-05 19:35:03 +08:00
|
|
|
gdk_pointer_ungrab (time);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* restore the tool's modifier state because it didn't get
|
|
|
|
* key events while BUTTON1 was down
|
|
|
|
*/
|
2002-05-16 00:28:41 +08:00
|
|
|
gimp_display_shell_update_tool_modifiers (shell,
|
|
|
|
button_press_state,
|
|
|
|
state);
|
2001-11-30 22:41:56 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2001-11-30 22:41:56 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2002-05-16 00:28:41 +08:00
|
|
|
|
|
|
|
if (shell->space_release_pending)
|
|
|
|
{
|
|
|
|
gdk_keyboard_ungrab (time);
|
|
|
|
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, state, 0);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp_context_set_tool (gimp_get_user_context (gimp),
|
2002-05-16 00:28:41 +08:00
|
|
|
space_shaded_tool);
|
|
|
|
space_shaded_tool = NULL;
|
|
|
|
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell,
|
|
|
|
space_press_state,
|
|
|
|
state);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2002-05-16 00:28:41 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
|
|
|
|
shell->space_release_pending = FALSE;
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
state &= ~GDK_BUTTON2_MASK;
|
|
|
|
|
|
|
|
scrolling = FALSE;
|
|
|
|
|
|
|
|
scroll_start_x = 0;
|
|
|
|
scroll_start_y = 0;
|
|
|
|
|
|
|
|
gtk_grab_remove (canvas);
|
|
|
|
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_display_shell_unset_override_cursor (shell);
|
2001-11-15 01:12:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
state &= ~GDK_BUTTON3_MASK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:39:08 +08:00
|
|
|
break;
|
1999-07-10 07:03:11 +08:00
|
|
|
|
2001-08-10 00:39:08 +08:00
|
|
|
case GDK_SCROLL:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventScroll *sevent;
|
|
|
|
|
|
|
|
sevent = (GdkEventScroll *) event;
|
|
|
|
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
if (sevent->direction == GDK_SCROLL_UP)
|
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_IN);
|
|
|
|
else
|
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
|
|
|
adj = shell->hsbdata;
|
|
|
|
else
|
|
|
|
adj = shell->vsbdata;
|
|
|
|
|
|
|
|
value = adj->value + ((sevent->direction == GDK_SCROLL_UP) ?
|
|
|
|
-adj->page_increment / 2 :
|
|
|
|
adj->page_increment / 2);
|
|
|
|
value = CLAMP (value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
return_val = TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventMotion *mevent;
|
2002-03-19 21:14:25 +08:00
|
|
|
GdkEvent *compressed_motion = NULL;
|
2001-11-15 01:12:51 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2002-04-21 15:31:12 +08:00
|
|
|
|
|
|
|
switch (gimp_tool_control_motion_mode (active_tool->control))
|
2002-03-19 21:14:25 +08:00
|
|
|
{
|
|
|
|
case GIMP_MOTION_MODE_EXACT:
|
|
|
|
case GIMP_MOTION_MODE_HINT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_MOTION_MODE_COMPRESS:
|
|
|
|
compressed_motion = gimp_display_shell_compress_motion (shell);
|
|
|
|
break;
|
|
|
|
}
|
2002-06-27 06:16:59 +08:00
|
|
|
|
2002-03-19 21:14:25 +08:00
|
|
|
if (compressed_motion)
|
|
|
|
{
|
2003-02-27 03:03:06 +08:00
|
|
|
GdkDevice *device = gimp_devices_get_current (gimp);
|
2002-03-19 21:14:25 +08:00
|
|
|
|
2003-02-03 23:03:11 +08:00
|
|
|
gimp_display_shell_get_event_coords (shell, compressed_motion,
|
2003-02-27 03:03:06 +08:00
|
|
|
device, &display_coords);
|
2003-02-03 23:03:11 +08:00
|
|
|
gimp_display_shell_get_event_state (shell, compressed_motion,
|
2003-02-27 03:03:06 +08:00
|
|
|
device, &state);
|
2002-03-19 21:14:25 +08:00
|
|
|
time = gdk_event_get_time (event);
|
|
|
|
|
|
|
|
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
}
|
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
/* Ask for the pointer position, but ignore it except for cursor
|
|
|
|
* handling, so motion events sync with the button press/release events
|
|
|
|
*/
|
|
|
|
if (mevent->is_hint)
|
|
|
|
{
|
|
|
|
gimp_display_shell_get_device_coords (shell,
|
|
|
|
mevent->device,
|
|
|
|
&display_coords);
|
|
|
|
}
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
|
|
|
|
if (! shell->proximity)
|
|
|
|
{
|
|
|
|
shell->proximity = TRUE;
|
|
|
|
gimp_display_shell_check_device_cursor (shell);
|
|
|
|
}
|
|
|
|
|
2002-02-07 19:33:01 +08:00
|
|
|
if (state & GDK_BUTTON1_MASK)
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-05-16 00:28:41 +08:00
|
|
|
if (active_tool &&
|
|
|
|
gimp_tool_control_is_active (active_tool->control) &&
|
2002-02-07 19:33:01 +08:00
|
|
|
(! gimp_image_is_empty (gimage) ||
|
2002-05-16 00:28:41 +08:00
|
|
|
gimp_tool_control_handles_empty_image (active_tool->control)))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
/* if the first mouse button is down, check for automatic
|
|
|
|
* scrolling...
|
|
|
|
*/
|
|
|
|
if ((mevent->x < 0 ||
|
|
|
|
mevent->y < 0 ||
|
|
|
|
mevent->x > shell->disp_width ||
|
|
|
|
mevent->y > shell->disp_height) &&
|
2002-05-16 00:28:41 +08:00
|
|
|
! gimp_tool_control_scroll_lock (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
off_x = off_y = 0;
|
|
|
|
|
|
|
|
/* The cases for scrolling */
|
|
|
|
if (mevent->x < 0)
|
|
|
|
off_x = mevent->x;
|
|
|
|
else if (mevent->x > shell->disp_width)
|
|
|
|
off_x = mevent->x - shell->disp_width;
|
|
|
|
|
|
|
|
if (mevent->y < 0)
|
|
|
|
off_y = mevent->y;
|
|
|
|
else if (mevent->y > shell->disp_height)
|
|
|
|
off_y = mevent->y - shell->disp_height;
|
|
|
|
|
|
|
|
if (gimp_display_shell_scroll (shell, off_x, off_y))
|
|
|
|
{
|
|
|
|
GimpCoords device_coords;
|
|
|
|
|
|
|
|
gimp_display_shell_get_device_coords (shell,
|
|
|
|
mevent->device,
|
|
|
|
&device_coords);
|
|
|
|
|
|
|
|
if (device_coords.x == mevent->x &&
|
|
|
|
device_coords.y == mevent->y)
|
|
|
|
{
|
|
|
|
/* Put this event back on the queue
|
|
|
|
* so it keeps scrolling
|
|
|
|
*/
|
|
|
|
gdk_event_put ((GdkEvent *) mevent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
if (gimp_tool_control_auto_snap_to (active_tool->control))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_motion_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, time, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2002-02-07 19:33:01 +08:00
|
|
|
else if (state & GDK_BUTTON2_MASK)
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-02-07 19:33:01 +08:00
|
|
|
if (scrolling)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
(scroll_start_x - mevent->x -
|
|
|
|
shell->offset_x),
|
|
|
|
(scroll_start_y - mevent->y -
|
|
|
|
shell->offset_y));
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
|
|
|
|
2003-02-27 03:03:06 +08:00
|
|
|
if (! (state &
|
|
|
|
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KEY_PRESS:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventKey *kevent;
|
|
|
|
|
|
|
|
kevent = (GdkEventKey *) event;
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_Left: case GDK_Right:
|
|
|
|
case GDK_Up: case GDK_Down:
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_arrow_key_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
kevent,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
case GDK_space:
|
|
|
|
{
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2002-05-16 00:28:41 +08:00
|
|
|
|
|
|
|
if (! shell->space_pressed && ! GIMP_IS_MOVE_TOOL (active_tool))
|
|
|
|
{
|
|
|
|
GimpToolInfo *move_tool_info;
|
|
|
|
|
|
|
|
space_shaded_tool = active_tool->tool_info;
|
|
|
|
space_press_state = state;
|
|
|
|
|
|
|
|
g_print ("%s: pushing move tool\n", G_GNUC_FUNCTION);
|
|
|
|
|
|
|
|
gdk_keyboard_grab (canvas->window, FALSE, time);
|
|
|
|
|
|
|
|
move_tool_info =
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_get_info_by_type (gimp,
|
2002-05-16 00:28:41 +08:00
|
|
|
GIMP_TYPE_MOVE_TOOL);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp_context_set_tool (gimp_get_user_context (gimp),
|
2002-05-16 00:28:41 +08:00
|
|
|
move_tool_info);
|
|
|
|
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, 0, state);
|
|
|
|
|
|
|
|
shell->space_pressed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
case GDK_Tab:
|
2003-02-03 23:03:11 +08:00
|
|
|
if (! state)
|
|
|
|
{
|
|
|
|
/* Hide or show all dialogs */
|
|
|
|
|
|
|
|
gimp_dialog_factories_toggle (global_toolbox_factory);
|
|
|
|
}
|
|
|
|
else if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
gimp_display_shell_layer_select_init (gdisp->gimage,
|
|
|
|
1, kevent->time);
|
|
|
|
}
|
|
|
|
else if (state & GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
gimp_display_shell_layer_select_init (gdisp->gimage,
|
|
|
|
-1, kevent->time);
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Update the state based on modifiers being pressed */
|
|
|
|
case GDK_Alt_L: case GDK_Alt_R:
|
|
|
|
case GDK_Shift_L: case GDK_Shift_R:
|
|
|
|
case GDK_Control_L: case GDK_Control_R:
|
2002-05-16 00:28:41 +08:00
|
|
|
{
|
|
|
|
GdkModifierType key;
|
|
|
|
|
|
|
|
key = gimp_display_shell_key_to_state (kevent->keyval);
|
|
|
|
state |= key;
|
|
|
|
|
|
|
|
/* For all modifier keys: call the tools modifier_key *and*
|
|
|
|
* oper_update method so tools can choose if they are interested
|
|
|
|
* in the release itself or only in the resulting state
|
|
|
|
*/
|
|
|
|
if (! gimp_image_is_empty (gimage))
|
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_modifier_key_active (gimp,
|
2002-05-16 00:28:41 +08:00
|
|
|
key, TRUE, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KEY_RELEASE:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventKey *kevent;
|
|
|
|
|
|
|
|
kevent = (GdkEventKey *) event;
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
2002-05-16 00:28:41 +08:00
|
|
|
case GDK_space:
|
|
|
|
if (shell->space_pressed)
|
|
|
|
{
|
|
|
|
g_print ("%s: popping move tool\n", G_GNUC_FUNCTION);
|
|
|
|
|
|
|
|
gdk_keyboard_ungrab (time);
|
|
|
|
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell, state, 0);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp_context_set_tool (gimp_get_user_context (gimp),
|
2002-05-16 00:28:41 +08:00
|
|
|
space_shaded_tool);
|
|
|
|
space_shaded_tool = NULL;
|
|
|
|
|
|
|
|
gimp_display_shell_update_tool_modifiers (shell,
|
|
|
|
space_press_state,
|
|
|
|
state);
|
|
|
|
|
|
|
|
shell->space_pressed = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
2001-11-15 01:12:51 +08:00
|
|
|
|
|
|
|
/* Update the state based on modifiers being pressed */
|
|
|
|
case GDK_Alt_L: case GDK_Alt_R:
|
|
|
|
case GDK_Shift_L: case GDK_Shift_R:
|
|
|
|
case GDK_Control_L: case GDK_Control_R:
|
2002-05-16 00:28:41 +08:00
|
|
|
{
|
|
|
|
GdkModifierType key;
|
|
|
|
|
|
|
|
key = gimp_display_shell_key_to_state (kevent->keyval);
|
|
|
|
state &= ~key;
|
|
|
|
|
|
|
|
/* For all modifier keys: call the tools modifier_key *and*
|
|
|
|
* oper_update method so tools can choose if they are interested
|
|
|
|
* in the press itself or only in the resulting state
|
|
|
|
*/
|
|
|
|
if (! gimp_image_is_empty (gimage))
|
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_modifier_key_active (gimp,
|
2002-05-16 00:28:41 +08:00
|
|
|
key, FALSE, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_oper_update_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-03-26 02:19:40 +08:00
|
|
|
/* if we reached this point in gimp_busy mode, return now */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gimp->busy)
|
2003-02-21 20:16:43 +08:00
|
|
|
return return_val;
|
2000-03-26 02:17:01 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
/* cursor update support */
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (GIMP_DISPLAY_CONFIG (gimp->config)->cursor_updating)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-15 01:12:51 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (active_tool)
|
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
if ((! gimp_image_is_empty (gimage) ||
|
2002-05-16 00:28:41 +08:00
|
|
|
gimp_tool_control_handles_empty_image (active_tool->control)) &&
|
2001-11-09 03:14:51 +08:00
|
|
|
! (state & (GDK_BUTTON1_MASK |
|
|
|
|
GDK_BUTTON2_MASK |
|
|
|
|
GDK_BUTTON3_MASK)))
|
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
tool_manager_cursor_update_active (gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
else if (gimp_image_is_empty (gimage))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_display_shell_set_cursor (shell,
|
|
|
|
GIMP_BAD_CURSOR,
|
2002-05-16 00:28:41 +08:00
|
|
|
gimp_tool_control_get_tool_cursor (active_tool->control),
|
2002-02-07 19:33:01 +08:00
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_display_shell_set_cursor (shell,
|
|
|
|
GIMP_BAD_CURSOR,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-07-16 11:23:14 +08:00
|
|
|
if (update_cursor)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_update_cursor (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y);
|
|
|
|
}
|
1998-06-06 11:49:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_hruler_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
if (gdisp->gimage->gimp->busy)
|
2000-03-26 02:17:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (event->button == 1)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpTool *active_tool;
|
1998-03-13 11:35:33 +08:00
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-move-tool");
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
|
|
|
|
tool_info);
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
|
|
|
|
|
|
|
if (active_tool)
|
|
|
|
{
|
2002-02-07 19:33:01 +08:00
|
|
|
gdk_pointer_grab (shell->canvas->window, FALSE,
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, event->time);
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
gimp_move_tool_start_hguide (active_tool, gdisp);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_vruler_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
if (gdisp->gimage->gimp->busy)
|
2000-03-26 02:17:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (event->button == 1)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-move-tool");
|
2001-07-08 01:36:00 +08:00
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
|
|
|
|
tool_info);
|
1998-03-13 11:35:33 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
if (active_tool)
|
|
|
|
{
|
2002-02-07 19:33:01 +08:00
|
|
|
gdk_pointer_grab (shell->canvas->window, FALSE,
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, event->time);
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
gimp_move_tool_start_vguide (active_tool, gdisp);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1998-06-09 17:20:46 +08:00
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_origin_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2002-05-24 10:20:20 +08:00
|
|
|
if (! shell->gdisp->gimage->gimp->busy && event->button == 1)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2002-05-24 10:20:20 +08:00
|
|
|
gimp_display_shell_origin_menu_popup (shell,
|
|
|
|
event->button,
|
|
|
|
event->time);
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-29 22:09:50 +08:00
|
|
|
/* Return TRUE to stop signal emission so the button doesn't grab the
|
2001-08-07 20:42:23 +08:00
|
|
|
* pointer away from us.
|
|
|
|
*/
|
2001-07-29 22:09:50 +08:00
|
|
|
return TRUE;
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2002-02-28 21:47:03 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_color_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
if (bevent->button == 3)
|
|
|
|
{
|
|
|
|
GimpColorButton *color_button;
|
|
|
|
guchar r, g, b;
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
color_button = GIMP_COLOR_BUTTON (widget);
|
|
|
|
|
|
|
|
r = shell->canvas->style->bg[GTK_STATE_NORMAL].red >> 8;
|
|
|
|
g = shell->canvas->style->bg[GTK_STATE_NORMAL].green >> 8;
|
|
|
|
b = shell->canvas->style->bg[GTK_STATE_NORMAL].blue >> 8;
|
|
|
|
|
|
|
|
gimp_rgba_set_uchar (&color, r, g, b, 255);
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_item_factory_set_color (color_button->item_factory,
|
2002-11-24 20:49:19 +08:00
|
|
|
"/From Theme", &color, FALSE);
|
2002-11-24 06:22:21 +08:00
|
|
|
|
|
|
|
gimp_rgba_set_uchar (&color,
|
|
|
|
render_blend_light_check[0],
|
|
|
|
render_blend_light_check[1],
|
|
|
|
render_blend_light_check[2],
|
|
|
|
255);
|
|
|
|
gimp_item_factory_set_color (color_button->item_factory,
|
|
|
|
"/Light Check Color", &color, FALSE);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_rgba_set_uchar (&color,
|
|
|
|
render_blend_dark_check[0],
|
|
|
|
render_blend_dark_check[1],
|
|
|
|
render_blend_dark_check[2],
|
|
|
|
255);
|
2002-02-28 21:47:03 +08:00
|
|
|
gimp_item_factory_set_color (color_button->item_factory,
|
2002-11-24 06:22:21 +08:00
|
|
|
"/Dark Check Color", &color, FALSE);
|
2002-02-28 21:47:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
void
|
2002-02-28 21:47:03 +08:00
|
|
|
gimp_display_shell_color_button_changed (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-16 23:08:59 +08:00
|
|
|
{
|
2002-11-24 06:22:21 +08:00
|
|
|
GimpRGB color;
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
shell->padding_mode_set = TRUE;
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_display_shell_set_padding (shell,
|
|
|
|
GIMP_DISPLAY_PADDING_MODE_CUSTOM,
|
|
|
|
&color);
|
2001-11-16 23:08:59 +08:00
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
|
2002-02-28 21:47:03 +08:00
|
|
|
void
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_display_shell_color_button_menu_callback (gpointer callback_data,
|
|
|
|
guint callback_action,
|
|
|
|
GtkWidget *widget)
|
2002-02-28 21:47:03 +08:00
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (callback_data);
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
if (callback_action == GIMP_DISPLAY_PADDING_MODE_CUSTOM)
|
|
|
|
{
|
|
|
|
gtk_button_clicked (GTK_BUTTON (shell->padding_button));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (callback_action == 0xffff)
|
|
|
|
{
|
|
|
|
GimpDisplayConfig *config;
|
|
|
|
|
|
|
|
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
shell->padding_mode_set = FALSE;
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_display_shell_set_padding (shell,
|
|
|
|
config->canvas_padding_mode,
|
|
|
|
&config->canvas_padding_color);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->padding_mode_set = TRUE;
|
|
|
|
|
|
|
|
gimp_display_shell_set_padding (shell, callback_action,
|
|
|
|
&shell->padding_color);
|
|
|
|
}
|
|
|
|
}
|
2002-02-28 21:47:03 +08:00
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
2002-05-06 03:17:41 +08:00
|
|
|
GdkEventButton *bevent,
|
2001-11-30 22:41:56 +08:00
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2002-05-06 03:17:41 +08:00
|
|
|
if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 3))
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_item_factory_popup_with_data (shell->qmask_factory, shell, NULL);
|
2001-11-30 22:41:56 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_qmask_toggled (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_image_set_qmask_state (shell->gdisp->gimage,
|
|
|
|
GTK_TOGGLE_BUTTON (widget)->active);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (shell->gdisp->gimage);
|
2001-11-30 22:41:56 +08:00
|
|
|
}
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_nav_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 1))
|
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_popup (shell, widget, bevent->x, bevent->y);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell, 0, (adjustment->value - shell->offset_y));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell, (adjustment->value - shell->offset_x), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-03 23:03:11 +08:00
|
|
|
gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords)
|
2001-12-01 00:39:40 +08:00
|
|
|
{
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_X, &coords->x))
|
|
|
|
{
|
2003-02-03 23:03:11 +08:00
|
|
|
gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y);
|
|
|
|
|
|
|
|
/* CLAMP() the return value of each *_get_axis() call to be safe
|
|
|
|
* against buggy XInput drivers. Provide default values if the
|
|
|
|
* requested axis does not exist.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure))
|
|
|
|
coords->pressure = CLAMP (coords->pressure, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->pressure = 1.0;
|
|
|
|
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt))
|
|
|
|
coords->xtilt = CLAMP (coords->xtilt, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->xtilt = 0.5;
|
|
|
|
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt))
|
|
|
|
coords->ytilt = CLAMP (coords->ytilt, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->ytilt = 0.5;
|
|
|
|
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel))
|
|
|
|
coords->wheel = CLAMP (coords->wheel, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->wheel = 0.5;
|
2001-12-01 00:39:40 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_get_device_coords (shell, device, coords);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
gdouble axes[GDK_AXIS_LAST];
|
|
|
|
|
|
|
|
gdk_device_get_state (device, shell->canvas->window, axes, NULL);
|
|
|
|
|
2003-02-03 23:03:11 +08:00
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
|
|
|
|
|
|
|
|
/* CLAMP() the return value of each *_get_axis() call to be safe
|
|
|
|
* against buggy XInput drivers. Provide default values if the
|
|
|
|
* requested axis does not exist.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (gdk_device_get_axis (device, axes, GDK_AXIS_PRESSURE, &coords->pressure))
|
|
|
|
coords->pressure = CLAMP (coords->pressure, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->pressure = 1.0;
|
|
|
|
|
|
|
|
if (gdk_device_get_axis (device, axes, GDK_AXIS_XTILT, &coords->xtilt))
|
|
|
|
coords->xtilt = CLAMP (coords->xtilt, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->xtilt = 0.5;
|
|
|
|
|
|
|
|
if (gdk_device_get_axis (device, axes, GDK_AXIS_YTILT, &coords->ytilt))
|
|
|
|
coords->ytilt = CLAMP (coords->ytilt, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->ytilt = 0.5;
|
|
|
|
|
|
|
|
if (gdk_device_get_axis (device, axes, GDK_AXIS_WHEEL, &coords->wheel))
|
|
|
|
coords->wheel = CLAMP (coords->wheel, 0.0, 1.0);
|
|
|
|
else
|
|
|
|
coords->wheel = 0.5;
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-03 23:03:11 +08:00
|
|
|
gimp_display_shell_get_event_state (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state)
|
2001-12-01 00:39:40 +08:00
|
|
|
{
|
|
|
|
if (gdk_event_get_state (event, state))
|
2003-02-03 23:03:11 +08:00
|
|
|
return TRUE;
|
2001-12-01 00:39:40 +08:00
|
|
|
|
|
|
|
gimp_display_shell_get_device_state (shell, device, state);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state)
|
|
|
|
{
|
|
|
|
gdk_device_get_state (device, shell->canvas->window, NULL, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkModifierType
|
|
|
|
gimp_display_shell_key_to_state (gint key)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case GDK_Alt_L:
|
|
|
|
case GDK_Alt_R:
|
|
|
|
return GDK_MOD1_MASK;
|
|
|
|
case GDK_Shift_L:
|
|
|
|
case GDK_Shift_R:
|
|
|
|
return GDK_SHIFT_MASK;
|
|
|
|
case GDK_Control_L:
|
|
|
|
case GDK_Control_R:
|
|
|
|
return GDK_CONTROL_MASK;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-16 00:28:41 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_update_tool_modifiers (GimpDisplayShell *shell,
|
|
|
|
GdkModifierType old_state,
|
|
|
|
GdkModifierType current_state)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
|
|
|
|
gimp = shell->gdisp->gimage->gimp;
|
|
|
|
|
|
|
|
if ((old_state & GDK_SHIFT_MASK) != (current_state & GDK_SHIFT_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimp,
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
(current_state & GDK_SHIFT_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
current_state,
|
|
|
|
shell->gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((old_state & GDK_CONTROL_MASK) != (current_state & GDK_CONTROL_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimp,
|
|
|
|
GDK_CONTROL_MASK,
|
|
|
|
(current_state & GDK_CONTROL_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
current_state,
|
|
|
|
shell->gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((old_state & GDK_MOD1_MASK) != (current_state & GDK_MOD1_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimp,
|
|
|
|
GDK_MOD1_MASK,
|
|
|
|
(current_state & GDK_MOD1_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
current_state,
|
|
|
|
shell->gdisp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_origin_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *origin;
|
|
|
|
gint origin_x;
|
|
|
|
gint origin_y;
|
|
|
|
|
|
|
|
origin = (GtkWidget *) data;
|
|
|
|
|
|
|
|
gdk_window_get_origin (origin->window, &origin_x, &origin_y);
|
|
|
|
|
|
|
|
*x = origin_x + origin->allocation.x + origin->allocation.width - 1;
|
|
|
|
*y = origin_y + origin->allocation.y + (origin->allocation.height - 1) / 2;
|
|
|
|
|
|
|
|
if (*x + GTK_WIDGET (menu)->allocation.width > gdk_screen_width ())
|
|
|
|
*x -= (GTK_WIDGET (menu)->allocation.width + origin->allocation.width);
|
|
|
|
|
|
|
|
if (*y + GTK_WIDGET (menu)->allocation.height > gdk_screen_height ())
|
|
|
|
*y -= (GTK_WIDGET (menu)->allocation.height);
|
|
|
|
}
|
2002-03-19 21:14:25 +08:00
|
|
|
|
2002-05-24 10:20:20 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_origin_menu_popup (GimpDisplayShell *shell,
|
|
|
|
guint button,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
GtkItemFactory *factory;
|
|
|
|
gint x, y;
|
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
factory = GTK_ITEM_FACTORY (shell->popup_factory);
|
2002-05-24 10:20:20 +08:00
|
|
|
|
|
|
|
gimp_display_shell_origin_menu_position (GTK_MENU (factory->widget),
|
|
|
|
&x, &y,
|
|
|
|
shell->origin);
|
|
|
|
|
|
|
|
gtk_item_factory_popup_with_data (factory,
|
2003-01-12 20:35:00 +08:00
|
|
|
shell->gdisp,
|
2002-05-24 10:20:20 +08:00
|
|
|
NULL,
|
|
|
|
x, y,
|
|
|
|
button, time);
|
|
|
|
}
|
|
|
|
|
2002-03-19 21:14:25 +08:00
|
|
|
/* gimp_display_shell_compress_motion:
|
|
|
|
*
|
|
|
|
* This function walks the whole GDK event queue seeking motion events
|
|
|
|
* corresponding to the widget 'widget'. If it finds any it will
|
|
|
|
* remove them from the queue, and return the most recent motion event.
|
|
|
|
* Otherwise it will return NULL.
|
|
|
|
*
|
|
|
|
* The gimp_display_shell_compress_motion function source may be re-used under
|
|
|
|
* the XFree86-style license. <adam@gimp.org>
|
|
|
|
*/
|
|
|
|
GdkEvent *
|
|
|
|
gimp_display_shell_compress_motion (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
GList *requeued_events = NULL;
|
|
|
|
GList *list;
|
|
|
|
GdkEvent *last_motion = NULL;
|
|
|
|
|
|
|
|
/* Move the entire GDK event queue to a private list, filtering
|
|
|
|
* out any motion events for the desired widget.
|
|
|
|
*/
|
|
|
|
while (gdk_events_pending ())
|
|
|
|
{
|
|
|
|
event = gdk_event_get ();
|
|
|
|
|
|
|
|
if (!event)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
|
|
|
else if ((gtk_get_event_widget (event) == shell->canvas) &&
|
|
|
|
(event->any.type == GDK_MOTION_NOTIFY))
|
|
|
|
{
|
|
|
|
if (last_motion)
|
|
|
|
gdk_event_free (last_motion);
|
|
|
|
|
|
|
|
last_motion = event;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
requeued_events = g_list_prepend (requeued_events, event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Replay the remains of our private event list back into the
|
|
|
|
* event queue in order.
|
|
|
|
*/
|
|
|
|
requeued_events = g_list_reverse (requeued_events);
|
|
|
|
|
|
|
|
for (list = requeued_events; list; list = g_list_next (list))
|
|
|
|
{
|
2003-02-21 20:16:43 +08:00
|
|
|
gdk_event_put ((GdkEvent *) list->data);
|
|
|
|
gdk_event_free ((GdkEvent *) list->data);
|
2002-03-19 21:14:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (requeued_events);
|
|
|
|
|
|
|
|
return last_motion;
|
|
|
|
}
|