Commit 565aaa52 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/config/gimpdisplayconfig.[ch] added a new gimprc option

2003-11-20  Sven Neumann  <sven@gimp.org>

	* app/config/gimpdisplayconfig.[ch]
	* app/config/gimprc-blurbs.h: added a new gimprc option
	"activate-on-focus" that allows to configure GIMP to activate an
	image when the image window receives the focus. Useful for window
	managers using click-to-focus. Defaults to TRUE on OS_WIN32.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell.c: implemented the new behaviour.
parent c5865e49
2003-11-20 Sven Neumann <sven@gimp.org>
* app/config/gimpdisplayconfig.[ch]
* app/config/gimprc-blurbs.h: added a new gimprc option
"activate-on-focus" that allows to configure GIMP to activate an
image when the image window receives the focus. Useful for window
managers using click-to-focus. Defaults to TRUE on OS_WIN32.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell.c: implemented the new behaviour.
2003-11-20 Michael Natterer <mitch@gimp.org>
 
* app/widgets/gimpdnd.[ch]: changed drag source stuff to allow
......@@ -65,6 +65,12 @@ static void gimp_display_config_fullscreen_notify (GObject *object,
#define DEFAULT_IMAGE_TITLE_FORMAT "%f-%p.%i (%t, %L) %z%%"
#define DEFAULT_IMAGE_STATUS_FORMAT "%n (%m)"
#ifdef OS_WIN32
# define DEFAULT_ACTIVATE_ON_FOCUS TRUE
#else
# define DEFAULT_ACTIVATE_ON_FOCUS FALSE
#endif
enum
{
......@@ -86,7 +92,8 @@ enum
PROP_MONITOR_RES_FROM_GDK,
PROP_NAV_PREVIEW_SIZE,
PROP_DEFAULT_VIEW,
PROP_DEFAULT_FULLSCREEN_VIEW
PROP_DEFAULT_FULLSCREEN_VIEW,
PROP_ACTIVATE_ON_FOCUS
};
static GObjectClass *parent_class = NULL;
......@@ -227,6 +234,11 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
DEFAULT_FULLSCREEN_VIEW_BLURB,
GIMP_TYPE_DISPLAY_OPTIONS,
GIMP_PARAM_AGGREGATE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ACTIVATE_ON_FOCUS,
"activate-on-focus",
ACTIVATE_ON_FOCUS_BLURB,
DEFAULT_ACTIVATE_ON_FOCUS,
0);
}
static void
......@@ -332,7 +344,11 @@ gimp_display_config_set_property (GObject *object,
case PROP_DEFAULT_FULLSCREEN_VIEW:
if (g_value_get_object (value))
gimp_config_sync (GIMP_CONFIG (g_value_get_object (value)),
GIMP_CONFIG (display_config->default_fullscreen_view), 0);
GIMP_CONFIG (display_config->default_fullscreen_view),
0);
break;
case PROP_ACTIVATE_ON_FOCUS:
display_config->activate_on_focus = g_value_get_boolean (value);
break;
default:
......@@ -405,6 +421,9 @@ gimp_display_config_get_property (GObject *object,
case PROP_DEFAULT_FULLSCREEN_VIEW:
g_value_set_object (value, display_config->default_fullscreen_view);
break;
case PROP_ACTIVATE_ON_FOCUS:
g_value_set_boolean (value, display_config->activate_on_focus);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -58,6 +58,7 @@ struct _GimpDisplayConfig
GimpPreviewSize nav_preview_size;
GimpDisplayOptions *default_view;
GimpDisplayOptions *default_fullscreen_view;
gboolean activate_on_focus;
};
struct _GimpDisplayConfigClass
......
......@@ -9,6 +9,11 @@
* be marked for translation.
*/
#define ACTIVATE_ON_FOCUS_BLURB \
N_("When enabled, an image will become the active image when its image " \
"window receives the focus. This is useful for window managers using " \
"\"click to focus\".")
#define BRUSH_PATH_BLURB \
"Sets the brush search path."
......
......@@ -1428,6 +1428,10 @@ prefs_dialog_new (Gimp *gimp,
_("Marching _Ants Speed:"),
GTK_TABLE (table), 0);
prefs_check_button_add (object, "activate-on-focus",
_("Activate the Focused Image"),
GTK_BOX (vbox2));
/* Zoom & Resize Behavior */
vbox2 = prefs_frame_new (_("Zoom & Resize Behavior"),
GTK_CONTAINER (vbox), FALSE);
......
......@@ -111,7 +111,6 @@ gimp_display_shell_events (GtkWidget *widget,
GimpDisplayShell *shell)
{
Gimp *gimp;
GdkEventKey *kevent;
gboolean set_display = FALSE;
/* are we in destruction? */
......@@ -124,75 +123,84 @@ gimp_display_shell_events (GtkWidget *widget,
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
if (gimp->busy)
return TRUE;
{
GdkEventKey *kevent = (GdkEventKey *) event;
kevent = (GdkEventKey *) event;
if (gimp->busy)
return TRUE;
/* 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;
}
}
/* 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;
}
return TRUE;
}
switch (kevent->keyval)
{
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
case GDK_space:
case GDK_Tab:
case GDK_ISO_Left_Tab:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Control_L: case GDK_Control_R:
break;
switch (kevent->keyval)
{
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
case GDK_space:
case GDK_Tab:
case GDK_ISO_Left_Tab:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Control_L: case GDK_Control_R:
break;
case GDK_Escape:
gimp_display_shell_set_fullscreen (shell, FALSE);
break;
case GDK_Escape:
gimp_display_shell_set_fullscreen (shell, FALSE);
break;
default:
if (shell->space_pressed)
return TRUE;
break;
}
default:
if (shell->space_pressed)
return TRUE;
break;
}
set_display = TRUE;
break;
set_display = TRUE;
break;
}
case GDK_BUTTON_PRESS:
case GDK_SCROLL:
set_display = TRUE;
break;
case GDK_FOCUS_CHANGE:
{
GdkEventFocus *fevent = (GdkEventFocus *) event;
if (fevent->in && GIMP_DISPLAY_CONFIG (gimp->config)->activate_on_focus)
set_display = TRUE;
}
break;
case GDK_WINDOW_STATE:
{
GdkEventWindowState *sevent;
GdkEventWindowState *sevent = (GdkEventWindowState *) event;
GimpDisplayOptions *options;
gboolean fullscreen;
sevent = (GdkEventWindowState *) event;
shell->window_state = sevent->new_window_state;
if (! (sevent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN))
......@@ -478,9 +486,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
{
case GDK_ENTER_NOTIFY:
{
GdkEventCrossing *cevent;
cevent = (GdkEventCrossing *) event;
GdkEventCrossing *cevent = (GdkEventCrossing *) event;
if (cevent->mode != GDK_CROSSING_NORMAL)
return TRUE;
......@@ -495,9 +501,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_LEAVE_NOTIFY:
{
GdkEventCrossing *cevent;
cevent = (GdkEventCrossing *) event;
GdkEventCrossing *cevent = (GdkEventCrossing *) event;
if (cevent->mode != GDK_CROSSING_NORMAL)
return TRUE;
......@@ -528,9 +532,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_FOCUS_CHANGE:
{
GdkEventFocus *fevent;
fevent = (GdkEventFocus *) event;
GdkEventFocus *fevent = (GdkEventFocus *) event;
if (fevent->in)
{
......@@ -577,12 +579,10 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_BUTTON_PRESS:
{
GdkEventButton *bevent;
GdkEventButton *bevent = (GdkEventButton *) event;
GdkEventMask event_mask;
GimpTool *active_tool;
bevent = (GdkEventButton *) event;
if (! GTK_WIDGET_HAS_FOCUS (canvas))
{
/* in "click to focus" mode, the BUTTON_PRESS arrives before
......@@ -708,11 +708,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_BUTTON_RELEASE:
{
GdkEventButton *bevent;
GdkEventButton *bevent = (GdkEventButton *) event;
GimpTool *active_tool;
bevent = (GdkEventButton *) event;
active_tool = tool_manager_get_active (gimp);
if (gimp->busy)
......@@ -811,11 +809,9 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_SCROLL:
{
GdkEventScroll *sevent;
GdkEventScroll *sevent = (GdkEventScroll *) event;
GdkScrollDirection direction;
sevent = (GdkEventScroll *) event;
direction = sevent->direction;
if (state & GDK_SHIFT_MASK)
......@@ -884,12 +880,10 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_MOTION_NOTIFY:
{
GdkEventMotion *mevent;
GdkEventMotion *mevent = (GdkEventMotion *) event;
GdkEvent *compressed_motion = NULL;
GimpTool *active_tool;
mevent = (GdkEventMotion *) event;
if (gimp->busy)
return TRUE;
......@@ -1034,9 +1028,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_KEY_PRESS:
{
GdkEventKey *kevent;
kevent = (GdkEventKey *) event;
GdkEventKey *kevent = (GdkEventKey *) event;
tool_manager_focus_display_active (gimp, gdisp);
......@@ -1056,9 +1048,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_space:
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (gimp);
GimpTool *active_tool = tool_manager_get_active (gimp);
if (! shell->space_pressed && ! GIMP_IS_MOVE_TOOL (active_tool))
{
......@@ -1146,9 +1136,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_KEY_RELEASE:
{
GdkEventKey *kevent;
kevent = (GdkEventKey *) event;
GdkEventKey *kevent = (GdkEventKey *) event;
tool_manager_focus_display_active (gimp, gdisp);
......@@ -1213,9 +1201,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (GIMP_DISPLAY_CONFIG (gimp->config)->cursor_updating)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (gimp);
GimpTool *active_tool = tool_manager_get_active (gimp);
if (active_tool)
{
......@@ -1261,9 +1247,7 @@ gimp_display_shell_hruler_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = shell->gdisp;
GimpDisplay *gdisp = shell->gdisp;
if (gdisp->gimage->gimp->busy)
return TRUE;
......@@ -1307,9 +1291,7 @@ gimp_display_shell_vruler_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = shell->gdisp;
GimpDisplay *gdisp = shell->gdisp;
if (gdisp->gimage->gimp->busy)
return TRUE;
......
......@@ -296,7 +296,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK));
GDK_KEY_RELEASE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_SCROLL_MASK));
/* active display callback */
g_signal_connect (shell, "button_press_event",
......
......@@ -296,7 +296,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK));
GDK_KEY_RELEASE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_SCROLL_MASK));
/* active display callback */
g_signal_connect (shell, "button_press_event",
......
......@@ -1428,6 +1428,10 @@ prefs_dialog_new (Gimp *gimp,
_("Marching _Ants Speed:"),
GTK_TABLE (table), 0);
prefs_check_button_add (object, "activate-on-focus",
_("Activate the Focused Image"),
GTK_BOX (vbox2));
/* Zoom & Resize Behavior */
vbox2 = prefs_frame_new (_("Zoom & Resize Behavior"),
GTK_CONTAINER (vbox), FALSE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment