clamp windows to screen and cascade multiple windows of the same type
--Sven
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Fri Mar 24 23:08:08 CET 2000 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/session.[ch]: clamp windows to screen and cascade multiple
|
||||||
|
windows of the same type (e.g. info_dialogs). The cascading is a
|
||||||
|
somehow trivial approach which is not always correct, but it seems
|
||||||
|
to work reasonably well.
|
||||||
|
|
||||||
2000-03-24 Michael Natterer <mitch@gimp.org>
|
2000-03-24 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* Makefile.am
|
* Makefile.am
|
||||||
@ -8,7 +15,7 @@
|
|||||||
|
|
||||||
* app/app_procs.c: load gimp_splash.ppm
|
* app/app_procs.c: load gimp_splash.ppm
|
||||||
|
|
||||||
The idea if shearing the data_dir between Gimp versions has
|
The idea of sharing the data_dir between Gimp versions has
|
||||||
vanished, so this seems like the right thing to do (TM).
|
vanished, so this seems like the right thing to do (TM).
|
||||||
|
|
||||||
Keep the 1.0 splash around for sentimental reasons but don't
|
Keep the 1.0 splash around for sentimental reasons but don't
|
||||||
|
@ -67,70 +67,70 @@ SessionInfo toolbox_session_info =
|
|||||||
{
|
{
|
||||||
"toolbox",
|
"toolbox",
|
||||||
NULL,
|
NULL,
|
||||||
0, 0, 0, 0, FALSE
|
0, 0, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo lc_dialog_session_info =
|
SessionInfo lc_dialog_session_info =
|
||||||
{
|
{
|
||||||
"lc-dialog",
|
"lc-dialog",
|
||||||
(GtkItemFactoryCallback) dialogs_lc_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_lc_cmd_callback,
|
||||||
0, 400, 0, 0, FALSE
|
0, 400, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo info_dialog_session_info =
|
SessionInfo info_dialog_session_info =
|
||||||
{
|
{
|
||||||
"info-dialog",
|
"info-dialog",
|
||||||
NULL,
|
NULL,
|
||||||
165, 0, 0, 0, FALSE
|
165, 0, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo tool_options_session_info =
|
SessionInfo tool_options_session_info =
|
||||||
{
|
{
|
||||||
"tool-options",
|
"tool-options",
|
||||||
(GtkItemFactoryCallback) dialogs_tool_options_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_tool_options_cmd_callback,
|
||||||
0, 345, 0, 0, FALSE
|
0, 345, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo palette_session_info =
|
SessionInfo palette_session_info =
|
||||||
{
|
{
|
||||||
"palette",
|
"palette",
|
||||||
(GtkItemFactoryCallback) dialogs_palette_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_palette_cmd_callback,
|
||||||
140, 180, 0, 0, FALSE
|
140, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo brush_select_session_info =
|
SessionInfo brush_select_session_info =
|
||||||
{
|
{
|
||||||
"brush-select",
|
"brush-select",
|
||||||
(GtkItemFactoryCallback) dialogs_brushes_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_brushes_cmd_callback,
|
||||||
150, 180, 0, 0, FALSE
|
150, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo pattern_select_session_info =
|
SessionInfo pattern_select_session_info =
|
||||||
{
|
{
|
||||||
"pattern-select",
|
"pattern-select",
|
||||||
(GtkItemFactoryCallback) dialogs_patterns_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_patterns_cmd_callback,
|
||||||
160, 180, 0, 0, FALSE
|
160, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo gradient_select_session_info =
|
SessionInfo gradient_select_session_info =
|
||||||
{
|
{
|
||||||
"gradient-select",
|
"gradient-select",
|
||||||
(GtkItemFactoryCallback) dialogs_gradients_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_gradients_cmd_callback,
|
||||||
170, 180, 0, 0, FALSE
|
170, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo device_status_session_info =
|
SessionInfo device_status_session_info =
|
||||||
{
|
{
|
||||||
"device-status",
|
"device-status",
|
||||||
(GtkItemFactoryCallback) dialogs_device_status_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_device_status_cmd_callback,
|
||||||
0, 600, 0, 0, FALSE
|
0, 600, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo error_console_session_info =
|
SessionInfo error_console_session_info =
|
||||||
{
|
{
|
||||||
"error-console",
|
"error-console",
|
||||||
(GtkItemFactoryCallback) dialogs_error_console_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_error_console_cmd_callback,
|
||||||
400, 0, 250, 300, FALSE
|
400, 0, 250, 300, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ void
|
|||||||
session_get_window_info (GtkWidget *window,
|
session_get_window_info (GtkWidget *window,
|
||||||
SessionInfo *info)
|
SessionInfo *info)
|
||||||
{
|
{
|
||||||
if (!save_session_info || info == NULL || window->window == NULL)
|
if (info == NULL || window == NULL || window->window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gdk_window_get_root_origin (window->window, &info->x, &info->y);
|
gdk_window_get_root_origin (window->window, &info->x, &info->y);
|
||||||
@ -148,29 +148,55 @@ session_get_window_info (GtkWidget *window,
|
|||||||
if (we_are_exiting)
|
if (we_are_exiting)
|
||||||
info->open = GTK_WIDGET_VISIBLE (window);
|
info->open = GTK_WIDGET_VISIBLE (window);
|
||||||
|
|
||||||
if (g_list_find (session_info_updates, info) == NULL)
|
/* this place is free for a new window, reset the counter */
|
||||||
|
info->count = 0;
|
||||||
|
|
||||||
|
if (save_session_info &&
|
||||||
|
g_list_find (session_info_updates, info) == NULL)
|
||||||
|
{
|
||||||
session_info_updates = g_list_append (session_info_updates, info);
|
session_info_updates = g_list_append (session_info_updates, info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
session_set_window_geometry (GtkWidget *window,
|
session_set_window_geometry (GtkWidget *window,
|
||||||
SessionInfo *info,
|
SessionInfo *info,
|
||||||
gboolean set_size)
|
gboolean set_size)
|
||||||
{
|
{
|
||||||
if ( window == NULL || info == NULL)
|
static gint screen_width = 0;
|
||||||
return;
|
static gint screen_height = 0;
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WIN32
|
g_return_if_fail (window != NULL && info != NULL);
|
||||||
/* We should not position windows so that no decoration is visible */
|
|
||||||
if (info->y > 0)
|
|
||||||
gtk_widget_set_uposition (window, info->x, info->y);
|
|
||||||
#else
|
|
||||||
gtk_widget_set_uposition (window, info->x, info->y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((set_size) && (info->width > 0) && (info->height > 0))
|
if (screen_width == 0 || screen_height == 0)
|
||||||
|
{
|
||||||
|
screen_width = gdk_screen_width ();
|
||||||
|
screen_height = gdk_screen_height ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cascade multiple windows of same type (e.g. info_dialogs) */
|
||||||
|
x = info->x + info->count * 32;
|
||||||
|
y = info->y + info->count * 32;
|
||||||
|
info->count++;
|
||||||
|
|
||||||
|
if (set_size)
|
||||||
|
{
|
||||||
|
if (x >= 0 && x + info->width < screen_width &&
|
||||||
|
y >= 0 && y + info->height < screen_height)
|
||||||
|
{
|
||||||
|
gtk_widget_set_uposition (window, x, y);
|
||||||
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
|
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (x >= 0 && x + 32 < screen_width &&
|
||||||
|
y >= 0 && y + 32 < screen_height)
|
||||||
|
gtk_widget_set_uposition (window, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
save_sessionrc (void)
|
save_sessionrc (void)
|
||||||
|
@ -32,7 +32,8 @@ struct _SessionInfo
|
|||||||
gint y;
|
gint y;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
gint open;
|
gint count;
|
||||||
|
gboolean open;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* global session variables */
|
/* global session variables */
|
||||||
|
@ -67,70 +67,70 @@ SessionInfo toolbox_session_info =
|
|||||||
{
|
{
|
||||||
"toolbox",
|
"toolbox",
|
||||||
NULL,
|
NULL,
|
||||||
0, 0, 0, 0, FALSE
|
0, 0, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo lc_dialog_session_info =
|
SessionInfo lc_dialog_session_info =
|
||||||
{
|
{
|
||||||
"lc-dialog",
|
"lc-dialog",
|
||||||
(GtkItemFactoryCallback) dialogs_lc_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_lc_cmd_callback,
|
||||||
0, 400, 0, 0, FALSE
|
0, 400, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo info_dialog_session_info =
|
SessionInfo info_dialog_session_info =
|
||||||
{
|
{
|
||||||
"info-dialog",
|
"info-dialog",
|
||||||
NULL,
|
NULL,
|
||||||
165, 0, 0, 0, FALSE
|
165, 0, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo tool_options_session_info =
|
SessionInfo tool_options_session_info =
|
||||||
{
|
{
|
||||||
"tool-options",
|
"tool-options",
|
||||||
(GtkItemFactoryCallback) dialogs_tool_options_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_tool_options_cmd_callback,
|
||||||
0, 345, 0, 0, FALSE
|
0, 345, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo palette_session_info =
|
SessionInfo palette_session_info =
|
||||||
{
|
{
|
||||||
"palette",
|
"palette",
|
||||||
(GtkItemFactoryCallback) dialogs_palette_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_palette_cmd_callback,
|
||||||
140, 180, 0, 0, FALSE
|
140, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo brush_select_session_info =
|
SessionInfo brush_select_session_info =
|
||||||
{
|
{
|
||||||
"brush-select",
|
"brush-select",
|
||||||
(GtkItemFactoryCallback) dialogs_brushes_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_brushes_cmd_callback,
|
||||||
150, 180, 0, 0, FALSE
|
150, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo pattern_select_session_info =
|
SessionInfo pattern_select_session_info =
|
||||||
{
|
{
|
||||||
"pattern-select",
|
"pattern-select",
|
||||||
(GtkItemFactoryCallback) dialogs_patterns_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_patterns_cmd_callback,
|
||||||
160, 180, 0, 0, FALSE
|
160, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo gradient_select_session_info =
|
SessionInfo gradient_select_session_info =
|
||||||
{
|
{
|
||||||
"gradient-select",
|
"gradient-select",
|
||||||
(GtkItemFactoryCallback) dialogs_gradients_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_gradients_cmd_callback,
|
||||||
170, 180, 0, 0, FALSE
|
170, 180, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo device_status_session_info =
|
SessionInfo device_status_session_info =
|
||||||
{
|
{
|
||||||
"device-status",
|
"device-status",
|
||||||
(GtkItemFactoryCallback) dialogs_device_status_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_device_status_cmd_callback,
|
||||||
0, 600, 0, 0, FALSE
|
0, 600, 0, 0, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionInfo error_console_session_info =
|
SessionInfo error_console_session_info =
|
||||||
{
|
{
|
||||||
"error-console",
|
"error-console",
|
||||||
(GtkItemFactoryCallback) dialogs_error_console_cmd_callback,
|
(GtkItemFactoryCallback) dialogs_error_console_cmd_callback,
|
||||||
400, 0, 250, 300, FALSE
|
400, 0, 250, 300, 0, FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ void
|
|||||||
session_get_window_info (GtkWidget *window,
|
session_get_window_info (GtkWidget *window,
|
||||||
SessionInfo *info)
|
SessionInfo *info)
|
||||||
{
|
{
|
||||||
if (!save_session_info || info == NULL || window->window == NULL)
|
if (info == NULL || window == NULL || window->window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gdk_window_get_root_origin (window->window, &info->x, &info->y);
|
gdk_window_get_root_origin (window->window, &info->x, &info->y);
|
||||||
@ -148,29 +148,55 @@ session_get_window_info (GtkWidget *window,
|
|||||||
if (we_are_exiting)
|
if (we_are_exiting)
|
||||||
info->open = GTK_WIDGET_VISIBLE (window);
|
info->open = GTK_WIDGET_VISIBLE (window);
|
||||||
|
|
||||||
if (g_list_find (session_info_updates, info) == NULL)
|
/* this place is free for a new window, reset the counter */
|
||||||
|
info->count = 0;
|
||||||
|
|
||||||
|
if (save_session_info &&
|
||||||
|
g_list_find (session_info_updates, info) == NULL)
|
||||||
|
{
|
||||||
session_info_updates = g_list_append (session_info_updates, info);
|
session_info_updates = g_list_append (session_info_updates, info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
session_set_window_geometry (GtkWidget *window,
|
session_set_window_geometry (GtkWidget *window,
|
||||||
SessionInfo *info,
|
SessionInfo *info,
|
||||||
gboolean set_size)
|
gboolean set_size)
|
||||||
{
|
{
|
||||||
if ( window == NULL || info == NULL)
|
static gint screen_width = 0;
|
||||||
return;
|
static gint screen_height = 0;
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WIN32
|
g_return_if_fail (window != NULL && info != NULL);
|
||||||
/* We should not position windows so that no decoration is visible */
|
|
||||||
if (info->y > 0)
|
|
||||||
gtk_widget_set_uposition (window, info->x, info->y);
|
|
||||||
#else
|
|
||||||
gtk_widget_set_uposition (window, info->x, info->y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((set_size) && (info->width > 0) && (info->height > 0))
|
if (screen_width == 0 || screen_height == 0)
|
||||||
|
{
|
||||||
|
screen_width = gdk_screen_width ();
|
||||||
|
screen_height = gdk_screen_height ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cascade multiple windows of same type (e.g. info_dialogs) */
|
||||||
|
x = info->x + info->count * 32;
|
||||||
|
y = info->y + info->count * 32;
|
||||||
|
info->count++;
|
||||||
|
|
||||||
|
if (set_size)
|
||||||
|
{
|
||||||
|
if (x >= 0 && x + info->width < screen_width &&
|
||||||
|
y >= 0 && y + info->height < screen_height)
|
||||||
|
{
|
||||||
|
gtk_widget_set_uposition (window, x, y);
|
||||||
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
|
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (x >= 0 && x + 32 < screen_width &&
|
||||||
|
y >= 0 && y + 32 < screen_height)
|
||||||
|
gtk_widget_set_uposition (window, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
save_sessionrc (void)
|
save_sessionrc (void)
|
||||||
|
@ -32,7 +32,8 @@ struct _SessionInfo
|
|||||||
gint y;
|
gint y;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
gint open;
|
gint count;
|
||||||
|
gboolean open;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* global session variables */
|
/* global session variables */
|
||||||
|
Reference in New Issue
Block a user