comparison src/gui_gtk_x11.c @ 48:67300faee616 v7-3-618

v7-3-618
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 01 Aug 2012 18:08:28 +0900
parents c16898406ff2
children
comparison
equal deleted inserted replaced
47:6c0584ec21b1 48:67300faee616
84 # include "gui_gtk_f.h" 84 # include "gui_gtk_f.h"
85 #endif 85 #endif
86 86
87 #ifdef HAVE_X11_SUNKEYSYM_H 87 #ifdef HAVE_X11_SUNKEYSYM_H
88 # include <X11/Sunkeysym.h> 88 # include <X11/Sunkeysym.h>
89 static guint32 clipboard_event_time = CurrentTime;
90 #endif 89 #endif
91 90
92 /* 91 /*
93 * Easy-to-use macro for multihead support. 92 * Easy-to-use macro for multihead support.
94 */ 93 */
931 int modifiers; 930 int modifiers;
932 int key; 931 int key;
933 guint state; 932 guint state;
934 char_u *s, *d; 933 char_u *s, *d;
935 934
936 clipboard_event_time = event->time; 935 gui.event_time = event->time;
937 key_sym = event->keyval; 936 key_sym = event->keyval;
938 state = event->state; 937 state = event->state;
939 938
940 #ifdef FEAT_XIM 939 #ifdef FEAT_XIM
941 if (xim_queue_key_press_event(event, TRUE)) 940 if (xim_queue_key_press_event(event, TRUE))
1126 static gboolean 1125 static gboolean
1127 key_release_event(GtkWidget *widget UNUSED, 1126 key_release_event(GtkWidget *widget UNUSED,
1128 GdkEventKey *event, 1127 GdkEventKey *event,
1129 gpointer data UNUSED) 1128 gpointer data UNUSED)
1130 { 1129 {
1131 clipboard_event_time = event->time; 1130 gui.event_time = event->time;
1132 /* 1131 /*
1133 * GTK+ 2 input methods may do fancy stuff on key release events too. 1132 * GTK+ 2 input methods may do fancy stuff on key release events too.
1134 * With the default IM for instance, you can enter any UCS code point 1133 * With the default IM for instance, you can enter any UCS code point
1135 * by holding down CTRL-SHIFT and typing hexadecimal digits. 1134 * by holding down CTRL-SHIFT and typing hexadecimal digits.
1136 */ 1135 */
1170 VimClipboard *cbd; 1169 VimClipboard *cbd;
1171 char_u *text; 1170 char_u *text;
1172 char_u *tmpbuf = NULL; 1171 char_u *tmpbuf = NULL;
1173 guchar *tmpbuf_utf8 = NULL; 1172 guchar *tmpbuf_utf8 = NULL;
1174 int len; 1173 int len;
1175 int motion_type; 1174 int motion_type = MAUTO;
1176 1175
1177 if (data->selection == clip_plus.gtk_sel_atom) 1176 if (data->selection == clip_plus.gtk_sel_atom)
1178 cbd = &clip_plus; 1177 cbd = &clip_plus;
1179 else 1178 else
1180 cbd = &clip_star; 1179 cbd = &clip_star;
1181 1180
1182 text = (char_u *)data->data; 1181 text = (char_u *)data->data;
1183 len = data->length; 1182 len = data->length;
1184 motion_type = MCHAR;
1185 1183
1186 if (text == NULL || len <= 0) 1184 if (text == NULL || len <= 0)
1187 { 1185 {
1188 received_selection = RS_FAIL; 1186 received_selection = RS_FAIL;
1189 /* clip_free_selection(cbd); ??? */ 1187 /* clip_free_selection(cbd); ??? */
1414 vim_free(string); 1412 vim_free(string);
1415 } 1413 }
1416 } 1414 }
1417 1415
1418 /* 1416 /*
1419 * Check if the GUI can be started. Called before gvimrc is sourced. 1417 * Check if the GUI can be started. Called before gvimrc is sourced and
1418 * before fork().
1419 * Return OK or FAIL.
1420 */
1421 int
1422 gui_mch_early_init_check(void)
1423 {
1424 char_u *p;
1425
1426 /* Guess that when $DISPLAY isn't set the GUI can't start. */
1427 p = mch_getenv((char_u *)"DISPLAY");
1428 if (p == NULL || *p == NUL)
1429 {
1430 gui.dying = TRUE;
1431 EMSG(_((char *)e_opendisp));
1432 return FAIL;
1433 }
1434 return OK;
1435 }
1436
1437 /*
1438 * Check if the GUI can be started. Called before gvimrc is sourced but after
1439 * fork().
1420 * Return OK or FAIL. 1440 * Return OK or FAIL.
1421 */ 1441 */
1422 int 1442 int
1423 gui_mch_init_check(void) 1443 gui_mch_init_check(void)
1424 { 1444 {
1620 int button; 1640 int button;
1621 int repeated_click = FALSE; 1641 int repeated_click = FALSE;
1622 int x, y; 1642 int x, y;
1623 int_u vim_modifiers; 1643 int_u vim_modifiers;
1624 1644
1625 clipboard_event_time = event->time; 1645 gui.event_time = event->time;
1626 1646
1627 /* Make sure we have focus now we've been selected */ 1647 /* Make sure we have focus now we've been selected */
1628 if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget)) 1648 if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget))
1629 gtk_widget_grab_focus(widget); 1649 gtk_widget_grab_focus(widget);
1630 1650
1731 gpointer data UNUSED) 1751 gpointer data UNUSED)
1732 { 1752 {
1733 int x, y; 1753 int x, y;
1734 int_u vim_modifiers; 1754 int_u vim_modifiers;
1735 1755
1736 clipboard_event_time = event->time; 1756 gui.event_time = event->time;
1737 1757
1738 /* Remove any motion "machine gun" timers used for automatic further 1758 /* Remove any motion "machine gun" timers used for automatic further
1739 extension of allocation areas if outside of the applications window 1759 extension of allocation areas if outside of the applications window
1740 area .*/ 1760 area .*/
1741 if (motion_repeat_timer) 1761 if (motion_repeat_timer)
3050 int n_targets = N_SELECTION_TARGETS; 3070 int n_targets = N_SELECTION_TARGETS;
3051 GtkTargetEntry targets[N_SELECTION_TARGETS]; 3071 GtkTargetEntry targets[N_SELECTION_TARGETS];
3052 3072
3053 for (i = 0; i < (int)N_SELECTION_TARGETS; ++i) 3073 for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
3054 { 3074 {
3055 /* OpenOffice tries to use TARGET_HTML and fails when it doesn't 3075 /* OpenOffice tries to use TARGET_HTML and fails when we don't
3056 * return something, instead of trying another target. Therefore only 3076 * return something, instead of trying another target. Therefore only
3057 * offer TARGET_HTML when it works. */ 3077 * offer TARGET_HTML when it works. */
3058 if (!clip_html && selection_targets[i].info == TARGET_HTML) 3078 if (!clip_html && selection_targets[i].info == TARGET_HTML)
3059 n_targets--; 3079 n_targets--;
3060 else 3080 else
3081 int n_targets = N_DND_TARGETS; 3101 int n_targets = N_DND_TARGETS;
3082 GtkTargetEntry targets[N_DND_TARGETS]; 3102 GtkTargetEntry targets[N_DND_TARGETS];
3083 3103
3084 for (i = 0; i < (int)N_DND_TARGETS; ++i) 3104 for (i = 0; i < (int)N_DND_TARGETS; ++i)
3085 { 3105 {
3086 if (!clip_html && selection_targets[i].info == TARGET_HTML) 3106 if (!clip_html && dnd_targets[i].info == TARGET_HTML)
3087 n_targets--; 3107 n_targets--;
3088 else 3108 else
3089 targets[j++] = dnd_targets[i]; 3109 targets[j++] = dnd_targets[i];
3090 } 3110 }
3091 3111
3092 gtk_drag_dest_unset(gui.drawarea); 3112 gtk_drag_dest_unset(gui.drawarea);
3093 gtk_drag_dest_set(gui.drawarea, 3113 gtk_drag_dest_set(gui.drawarea,
3094 GTK_DEST_DEFAULT_ALL, 3114 GTK_DEST_DEFAULT_ALL,
3095 targets, n_targets, 3115 targets, n_targets,
3096 GDK_ACTION_COPY); 3116 GDK_ACTION_COPY | GDK_ACTION_MOVE);
3097 } 3117 }
3098 3118
3099 /* 3119 /*
3100 * Initialize the GUI. Create all the windows, set up all the callbacks etc. 3120 * Initialize the GUI. Create all the windows, set up all the callbacks etc.
3101 * Returns OK for success, FAIL when the GUI can't be started. 3121 * Returns OK for success, FAIL when the GUI can't be started.
3900 if (gui.mainwin != NULL) 3920 if (gui.mainwin != NULL)
3901 gtk_window_unmaximize(GTK_WINDOW(gui.mainwin)); 3921 gtk_window_unmaximize(GTK_WINDOW(gui.mainwin));
3902 } 3922 }
3903 3923
3904 /* 3924 /*
3925 * Called when the font changed while the window is maximized. Compute the
3926 * new Rows and Columns. This is like resizing the window.
3927 */
3928 void
3929 gui_mch_newfont()
3930 {
3931 int w, h;
3932
3933 gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h);
3934 w -= get_menu_tool_width();
3935 h -= get_menu_tool_height();
3936 gui_resize_shell(w, h);
3937 }
3938
3939 /*
3905 * Set the windows size. 3940 * Set the windows size.
3906 */ 3941 */
3907 void 3942 void
3908 gui_mch_set_shellsize(int width, int height, 3943 gui_mch_set_shellsize(int width, int height,
3909 int min_width UNUSED, int min_height UNUSED, 3944 int min_width UNUSED, int min_height UNUSED,
4409 gui.wide_font = NULL; 4444 gui.wide_font = NULL;
4410 } 4445 }
4411 4446
4412 if (gui_mch_maximized()) 4447 if (gui_mch_maximized())
4413 { 4448 {
4414 int w, h;
4415
4416 /* Update lines and columns in accordance with the new font, keep the 4449 /* Update lines and columns in accordance with the new font, keep the
4417 * window maximized. */ 4450 * window maximized. */
4418 gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h); 4451 gui_mch_newfont();
4419 w -= get_menu_tool_width();
4420 h -= get_menu_tool_height();
4421 gui_resize_shell(w, h);
4422 } 4452 }
4423 else 4453 else
4424 { 4454 {
4425 /* Preserve the logical dimensions of the screen. */ 4455 /* Preserve the logical dimensions of the screen. */
4426 update_window_manager_hints(0, 0); 4456 update_window_manager_hints(0, 0);
5417 gui_mch_stop_blink(); 5447 gui_mch_stop_blink();
5418 focus = gui.in_focus; 5448 focus = gui.in_focus;
5419 } 5449 }
5420 5450
5421 #if defined(FEAT_NETBEANS_INTG) 5451 #if defined(FEAT_NETBEANS_INTG)
5422 /* Process the queued netbeans messages. */ 5452 /* Process any queued netbeans messages. */
5423 netbeans_parse_messages(); 5453 netbeans_parse_messages();
5424 #endif 5454 #endif
5425 5455
5426 /* 5456 /*
5427 * Loop in GTK+ processing until a timeout or input occurs. 5457 * Loop in GTK+ processing until a timeout or input occurs.
5652 clip_mch_own_selection(VimClipboard *cbd) 5682 clip_mch_own_selection(VimClipboard *cbd)
5653 { 5683 {
5654 int success; 5684 int success;
5655 5685
5656 success = gtk_selection_owner_set(gui.drawarea, cbd->gtk_sel_atom, 5686 success = gtk_selection_owner_set(gui.drawarea, cbd->gtk_sel_atom,
5657 clipboard_event_time); 5687 gui.event_time);
5658 gui_mch_update(); 5688 gui_mch_update();
5659 return (success) ? OK : FAIL; 5689 return (success) ? OK : FAIL;
5660 } 5690 }
5661 5691
5662 /* 5692 /*