Mercurial > pidgin.yaz
comparison console/libgnt/gntwm.c @ 15778:c2c2a854f5b3
Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 07 Mar 2007 12:58:34 +0000 |
parents | 909e59dae123 |
children | 94867b2f38f5 |
comparison
equal
deleted
inserted
replaced
15777:909e59dae123 | 15778:c2c2a854f5b3 |
---|---|
873 } | 873 } |
874 | 874 |
875 static void | 875 static void |
876 gnt_wm_class_init(GntWMClass *klass) | 876 gnt_wm_class_init(GntWMClass *klass) |
877 { | 877 { |
878 int i; | |
879 | |
878 klass->new_window = gnt_wm_new_window_real; | 880 klass->new_window = gnt_wm_new_window_real; |
879 klass->decorate_window = NULL; | 881 klass->decorate_window = NULL; |
880 klass->close_window = NULL; | 882 klass->close_window = NULL; |
881 klass->window_resize_confirm = return_true; | 883 klass->window_resize_confirm = return_true; |
882 klass->window_resized = gnt_wm_win_resized; | 884 klass->window_resized = gnt_wm_win_resized; |
1002 "\033" GNT_KEY_CTRL_J, NULL); | 1004 "\033" GNT_KEY_CTRL_J, NULL); |
1003 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, | 1005 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, |
1004 "\033" GNT_KEY_CTRL_K, NULL); | 1006 "\033" GNT_KEY_CTRL_K, NULL); |
1005 | 1007 |
1006 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | 1008 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
1009 | |
1010 /* Make sure Alt+x are detected properly. */ | |
1011 for (i = '0'; i <= '9'; i++) { | |
1012 char str[] = "\033X"; | |
1013 str[1] = i; | |
1014 gnt_keys_add_combination(str); | |
1015 } | |
1016 | |
1007 GNTDEBUG; | 1017 GNTDEBUG; |
1008 } | 1018 } |
1009 | 1019 |
1010 /****************************************************************************** | 1020 /****************************************************************************** |
1011 * GntWM API | 1021 * GntWM API |
1207 time_t gnt_wm_get_idle_time() | 1217 time_t gnt_wm_get_idle_time() |
1208 { | 1218 { |
1209 return time(NULL) - last_active_time; | 1219 return time(NULL) - last_active_time; |
1210 } | 1220 } |
1211 | 1221 |
1212 void gnt_wm_process_input(GntWM *wm, const char *keys) | 1222 gboolean gnt_wm_process_input(GntWM *wm, const char *keys) |
1213 { | 1223 { |
1224 gboolean ret = FALSE; | |
1225 | |
1214 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); | 1226 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); |
1215 | 1227 |
1216 idle_update = TRUE; | 1228 idle_update = TRUE; |
1217 | 1229 |
1218 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) | 1230 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) |
1219 return; | 1231 return TRUE; |
1220 | 1232 |
1221 /* Do some manual checking */ | 1233 /* Do some manual checking */ |
1222 if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) { | 1234 if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) { |
1223 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; | 1235 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; |
1224 int x, y, w, h; | 1236 int x, y, w, h; |
1245 y++; | 1257 y++; |
1246 } | 1258 } |
1247 if (ox != x || oy != y) { | 1259 if (ox != x || oy != y) { |
1248 gnt_screen_move_widget(widget, x, y); | 1260 gnt_screen_move_widget(widget, x, y); |
1249 window_reverse(widget, TRUE, wm); | 1261 window_reverse(widget, TRUE, wm); |
1250 return; | 1262 return TRUE; |
1251 } | 1263 } |
1252 } else if (wm->mode == GNT_KP_MODE_RESIZE) { | 1264 } else if (wm->mode == GNT_KP_MODE_RESIZE) { |
1253 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | 1265 if (strcmp(keys, GNT_KEY_LEFT) == 0) { |
1254 w--; | 1266 w--; |
1255 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | 1267 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { |
1262 h++; | 1274 h++; |
1263 } | 1275 } |
1264 if (oh != h || ow != w) { | 1276 if (oh != h || ow != w) { |
1265 gnt_screen_resize_widget(widget, w, h); | 1277 gnt_screen_resize_widget(widget, w, h); |
1266 window_reverse(widget, TRUE, wm); | 1278 window_reverse(widget, TRUE, wm); |
1267 return; | 1279 return TRUE; |
1268 } | 1280 } |
1269 } | 1281 } |
1270 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { | 1282 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { |
1271 window_reverse(widget, FALSE, wm); | 1283 window_reverse(widget, FALSE, wm); |
1272 wm->mode = GNT_KP_MODE_NORMAL; | 1284 wm->mode = GNT_KP_MODE_NORMAL; |
1273 } | 1285 } |
1274 return; | 1286 return TRUE; |
1275 } | 1287 } |
1276 | 1288 |
1277 wm->event_stack = TRUE; | 1289 wm->event_stack = TRUE; |
1278 | 1290 |
1279 /* Escape to close the window-list or action-list window */ | 1291 /* Escape to close the window-list or action-list window */ |
1280 if (strcmp(keys, "\033") == 0) { | 1292 if (strcmp(keys, "\033") == 0) { |
1281 if (wm->_list.window) { | 1293 if (wm->_list.window) { |
1282 gnt_widget_destroy(wm->_list.window); | 1294 gnt_widget_destroy(wm->_list.window); |
1283 wm->event_stack = FALSE; | 1295 wm->event_stack = FALSE; |
1284 return; | 1296 return TRUE; |
1285 } | 1297 } |
1286 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { | 1298 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { |
1287 /* Alt+x for quick switch */ | 1299 /* Alt+x for quick switch */ |
1288 int n = *(keys + 1) - '0'; | 1300 int n = *(keys + 1) - '0'; |
1289 GList *list = NULL; | 1301 GList *list = NULL; |
1292 n = 10; | 1304 n = 10; |
1293 | 1305 |
1294 list = g_list_append(list, GINT_TO_POINTER(n - 1)); | 1306 list = g_list_append(list, GINT_TO_POINTER(n - 1)); |
1295 switch_window_n(GNT_BINDABLE(wm), list); | 1307 switch_window_n(GNT_BINDABLE(wm), list); |
1296 g_list_free(list); | 1308 g_list_free(list); |
1297 return; | 1309 return TRUE; |
1298 } | 1310 } |
1299 | 1311 |
1300 if (wm->menu) | 1312 if (wm->menu) |
1301 gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); | 1313 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); |
1302 else if (wm->_list.window) | 1314 else if (wm->_list.window) |
1303 gnt_widget_key_pressed(wm->_list.window, keys); | 1315 ret = gnt_widget_key_pressed(wm->_list.window, keys); |
1304 else if (wm->ordered) | 1316 else if (wm->ordered) |
1305 gnt_widget_key_pressed(GNT_WIDGET(wm->ordered->data), keys); | 1317 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->ordered->data), keys); |
1306 wm->event_stack = FALSE; | 1318 wm->event_stack = FALSE; |
1319 return ret; | |
1307 } | 1320 } |
1308 | 1321 |
1309 static void | 1322 static void |
1310 gnt_wm_win_resized(GntWM *wm, GntNode *node) | 1323 gnt_wm_win_resized(GntWM *wm, GntNode *node) |
1311 { | 1324 { |