Mercurial > pidgin
comparison console/libgnt/gntmain.c @ 14544:d1f9b05c3f58
[gaim-migrate @ 17265]
This should cause new windows caused by user actions (click, keypress)
to get focus on creation.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 12 Sep 2006 23:56:25 +0000 |
parents | 5ac8f22e7b08 |
children | 62bb53609a36 |
comparison
equal
deleted
inserted
replaced
14543:ad44ab4442b1 | 14544:d1f9b05c3f58 |
---|---|
43 static int Y_MIN; | 43 static int Y_MIN; |
44 static int Y_MAX; | 44 static int Y_MAX; |
45 | 45 |
46 static gboolean ascii_only; | 46 static gboolean ascii_only; |
47 static gboolean mouse_enabled; | 47 static gboolean mouse_enabled; |
48 | |
49 /** | |
50 * 'event_stack' will be set to TRUE when a user-event, ie. a mouse-click | |
51 * or a key-press is being processed. This variable will be used to determine | |
52 * whether to give focus to a new window. | |
53 */ | |
54 static gboolean event_stack; | |
48 | 55 |
49 static GMainLoop *loop; | 56 static GMainLoop *loop; |
50 | 57 |
51 static struct | 58 static struct |
52 { | 59 { |
130 if (ordered) | 137 if (ordered) |
131 w = ordered->data; | 138 w = ordered->data; |
132 | 139 |
133 focus_list = g_list_append(focus_list, widget); | 140 focus_list = g_list_append(focus_list, widget); |
134 | 141 |
135 ordered = g_list_append(ordered, widget); | 142 if (event_stack) { |
143 ordered = g_list_prepend(ordered, widget); | |
144 g_object_set_data(G_OBJECT(widget), "give_focus", GINT_TO_POINTER(event_stack)); | |
145 } else | |
146 ordered = g_list_append(ordered, widget); | |
136 | 147 |
137 gnt_widget_set_focus(widget, TRUE); | 148 gnt_widget_set_focus(widget, TRUE); |
138 if (w) | 149 if (w) |
139 gnt_widget_set_focus(w, FALSE); | 150 gnt_widget_set_focus(w, FALSE); |
140 draw_taskbar(FALSE); | 151 draw_taskbar(FALSE); |
739 endwin(); | 750 endwin(); |
740 printf("EOF\n"); | 751 printf("EOF\n"); |
741 exit(1); | 752 exit(1); |
742 } | 753 } |
743 | 754 |
755 event_stack = TRUE; | |
744 keys[rd] = 0; | 756 keys[rd] = 0; |
745 | 757 |
746 if (keys[0] == 27 && keys[1] == 'd' && keys[2] == 0) | 758 if (keys[0] == 27 && keys[1] == 'd' && keys[2] == 0) |
747 { | 759 { |
748 /* This dumps the screen contents in an html file */ | 760 /* This dumps the screen contents in an html file */ |
754 if (mouse_enabled && detect_mouse_action(keys)) | 766 if (mouse_enabled && detect_mouse_action(keys)) |
755 return TRUE; | 767 return TRUE; |
756 | 768 |
757 if (wm.key_pressed) { | 769 if (wm.key_pressed) { |
758 buffer = wm.key_pressed(keys); | 770 buffer = wm.key_pressed(keys); |
759 if (buffer == NULL) | 771 if (buffer == NULL) { |
772 event_stack = FALSE; | |
760 return TRUE; | 773 return TRUE; |
774 } | |
761 } else | 775 } else |
762 buffer = keys; | 776 buffer = keys; |
763 | 777 |
764 if (mode == GNT_KP_MODE_NORMAL) | 778 if (mode == GNT_KP_MODE_NORMAL) |
765 { | 779 { |
967 window_reverse(widget, TRUE); | 981 window_reverse(widget, TRUE); |
968 } | 982 } |
969 } | 983 } |
970 } | 984 } |
971 | 985 |
986 event_stack = FALSE; | |
972 return TRUE; | 987 return TRUE; |
973 } | 988 } |
974 | 989 |
975 static gboolean | 990 static gboolean |
976 refresh_screen() | 991 refresh_screen() |
1202 if (wm.new_window && node->me != _list.window) | 1217 if (wm.new_window && node->me != _list.window) |
1203 node->panel = wm.new_window(node->me); | 1218 node->panel = wm.new_window(node->me); |
1204 else | 1219 else |
1205 node->panel = new_panel(node->me->window); | 1220 node->panel = new_panel(node->me->window); |
1206 set_panel_userptr(node->panel, node); | 1221 set_panel_userptr(node->panel, node); |
1207 if (!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT)) | 1222 if (!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT)) { |
1208 { | 1223 if (!g_object_get_data(G_OBJECT(node->me), "give_focus")) { |
1209 bottom_panel(node->panel); /* New windows should not grab focus */ | 1224 bottom_panel(node->panel); /* New windows should not grab focus */ |
1210 gnt_widget_set_urgent(node->me); | 1225 gnt_widget_set_urgent(node->me); |
1226 } | |
1227 else { | |
1228 bring_on_top(node->me); | |
1229 } | |
1211 } | 1230 } |
1212 } | 1231 } |
1213 | 1232 |
1214 if (_list.window) | 1233 if (_list.window) |
1215 { | 1234 { |