Fixed some problems with focus (when close menus and windows).

This commit is contained in:
David Capello 2008-01-20 22:38:21 +00:00
parent 86fb5a0124
commit 1ee483cc28
4 changed files with 52 additions and 46 deletions

View File

@ -1,3 +1,12 @@
2008-01-20 David A. Capello <dacap@users.sourceforge.net>
* src/commands/cmd_configure_tools.c (cmd_configure_tools_execute):
Now the window is loaded one time and reused in all the program
execution.
* src/jinete/jmanager.c (_jmanager_close_window): Now the mouse
and focus aren't freed if it's not necessary.
2008-01-13 David A. Capello <dacap@users.sourceforge.net>
* src/widgets/editor/cursor.c, src/widgets/editor/editor.c: Fixed

View File

@ -75,35 +75,35 @@ static void cmd_configure_tools_execute(const char *argument)
JWidget check_onionskin;
JWidget brush_preview;
if (!window) {
window = load_widget("toolconf.jid", "configure_tool");
if (!window)
return;
}
/* if the window is opened, close it */
if (window) {
else if (jwidget_is_visible(window)) {
jwindow_close(window, NULL);
return;
}
/* if the window is closed, open it */
window = load_widget("toolconf.jid", "configure_tool");
if (!window)
return;
if (!get_widgets (window,
"filled", &filled,
"tiled", &tiled,
"use_grid", &use_grid,
"view_grid", &view_grid,
"set_grid", &set_grid,
"brush_size", &brush_size,
"brush_angle", &brush_angle,
"glass_dirty", &glass_dirty,
"spray_width", &spray_width,
"air_speed", &air_speed,
"cursor_color_box", &cursor_color_box,
"brush_preview_box", &brush_preview_box,
"brush_type_box", &brush_type_box,
"brush_mode_box", &brush_mode_box,
"onionskin", &check_onionskin, NULL)) {
if (!get_widgets(window,
"filled", &filled,
"tiled", &tiled,
"use_grid", &use_grid,
"view_grid", &view_grid,
"set_grid", &set_grid,
"brush_size", &brush_size,
"brush_angle", &brush_angle,
"glass_dirty", &glass_dirty,
"spray_width", &spray_width,
"air_speed", &air_speed,
"cursor_color_box", &cursor_color_box,
"brush_preview_box", &brush_preview_box,
"brush_type_box", &brush_type_box,
"brush_mode_box", &brush_mode_box,
"onionskin", &check_onionskin, NULL)) {
jwidget_free(window);
window = NULL;
return;
}
@ -166,7 +166,6 @@ static void cmd_configure_tools_execute(const char *argument)
/* load window configuration */
load_window_pos(window, "ConfigureTool");
/* open the window */
jwindow_open_bg(window);
}
@ -196,7 +195,7 @@ static bool brush_preview_msg_proc(JWidget widget, JMessage msg)
static int window_close_hook(JWidget widget, int user_data)
{
/* isn't running anymore */
window = NULL;
/* window = NULL; */
/* save window configuration */
save_window_pos(widget, "ConfigureTool");

View File

@ -967,16 +967,14 @@ void _jmanager_close_window(JWidget manager, JWidget window, bool redraw_backgro
}
/* free all widgets of special states */
#if 0
jmanager_free_capture();
jmanager_free_mouse();
if (capture_widget != NULL && jwidget_get_window(capture_widget) == window)
jmanager_free_capture();
jmanager_set_focus(manager);
#else
jmanager_free_capture();
jmanager_free_mouse();
jmanager_free_focus();
#endif
if (mouse_widget != NULL && jwidget_get_window(mouse_widget) == window)
jmanager_free_mouse();
if (focus_widget != NULL && jwidget_get_window(focus_widget) == window)
jmanager_free_focus();
/* hide window */
jwidget_hide(window);

View File

@ -51,7 +51,7 @@ JM_MESSAGE(exe_menuitem);
#define JM_OPEN_MENUITEM jm_open_menuitem()
/**
* bool final_close = msg->user.a;
* bool last_of_close_chain = msg->user.a;
*/
#define JM_CLOSE_MENUITEM jm_close_menuitem()
@ -138,7 +138,7 @@ static void set_highlight(JWidget menu, JWidget menuitem, bool click, bool open_
static void unhighlight(JWidget menu);
static void open_menuitem(JWidget menuitem, bool select_first);
static void close_menuitem(JWidget menuitem, bool final_close);
static void close_menuitem(JWidget menuitem, bool last_of_close_chain);
static void close_popup(JWidget menubox);
static void close_all(JWidget menu);
static void exe_menuitem(JWidget menuitem);
@ -933,7 +933,7 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
else if (msg->type == JM_CLOSE_MENUITEM) {
Base *base = get_base(widget);
JWidget menubox, window;
bool final_close = msg->user.a;
bool last_of_close_chain = msg->user.a;
assert(base != NULL);
assert(base->is_processing);
@ -946,24 +946,24 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
window = menubox->parent;
assert(window && window->type == JI_WINDOW);
/* set the focus to this menu-item */
if (base->close_all)
jmanager_free_focus();
else
jmanager_set_focus(widget->parent->parent);
/* fetch the "menu" to avoid free it with 'jwidget_free()' */
jmenubox_set_menu(menubox, NULL);
/* destroy the window */
jwindow_close(window, NULL);
/* set the focus to this menu-box of this menu-item */
if (base->close_all)
jmanager_free_focus();
else
jmanager_set_focus(widget->parent->parent);
/* isn't necessary to free this window because it's
automatically destroyed by the manager
... jwidget_free(window);
*/
if (final_close) {
if (last_of_close_chain) {
base->close_all = FALSE;
base->is_processing = FALSE;
}
@ -1196,7 +1196,7 @@ static void open_menuitem(JWidget menuitem, bool select_first)
}
}
static void close_menuitem(JWidget menuitem, bool final_close)
static void close_menuitem(JWidget menuitem, bool last_of_close_chain)
{
JWidget menu, child;
JMessage msg;
@ -1223,7 +1223,7 @@ static void close_menuitem(JWidget menuitem, bool final_close)
/* second: now we can close the 'menuitem' */
msg = jmessage_new(JM_CLOSE_MENUITEM);
msg->user.a = final_close;
msg->user.a = last_of_close_chain;
jmessage_add_dest(msg, menuitem);
jmanager_enqueue_message(msg);