comparison src/gui_gtk_x11.c @ 856:8cd729851562 v7.0g

updated for version 7.0g
author vimboss
date Sun, 30 Apr 2006 18:54:39 +0000
parents e73f2978bd40
children b933657f7c9d
comparison
equal deleted inserted replaced
855:d2a4f08396fe 856:8cd729851562
810 if (blink_state == BLINK_NONE) 810 if (blink_state == BLINK_NONE)
811 gui_mch_start_blink(); 811 gui_mch_start_blink();
812 812
813 /* make sure keyboard input goes to the draw area (if this is focus for a window) */ 813 /* make sure keyboard input goes to the draw area (if this is focus for a window) */
814 if (widget != gui.drawarea) 814 if (widget != gui.drawarea)
815 gtk_widget_grab_focus(gui.drawarea); 815 gtk_widget_grab_focus(gui.drawarea);
816 816
817 return TRUE; 817 return TRUE;
818 } 818 }
819 819
820 /*ARGSUSED*/ 820 /*ARGSUSED*/
2841 2841
2842 #ifdef FEAT_GUI_GNOME 2842 #ifdef FEAT_GUI_GNOME
2843 if (using_gnome && widget != NULL) 2843 if (using_gnome && widget != NULL)
2844 { 2844 {
2845 # ifdef HAVE_GTK2 2845 # ifdef HAVE_GTK2
2846 GtkWidget *parent; 2846 GtkWidget *parent;
2847 BonoboDockItem *dockitem; 2847 BonoboDockItem *dockitem;
2848 2848
2849 parent = gtk_widget_get_parent(widget); 2849 parent = gtk_widget_get_parent(widget);
2850 if (G_TYPE_FROM_INSTANCE(parent) == BONOBO_TYPE_DOCK_ITEM) 2850 if (G_TYPE_FROM_INSTANCE(parent) == BONOBO_TYPE_DOCK_ITEM)
2851 { 2851 {
2852 /* Only menu & toolbar are dock items. Could tabline be? 2852 /* Only menu & toolbar are dock items. Could tabline be?
2853 * Seem to be only the 2 defined in GNOME */ 2853 * Seem to be only the 2 defined in GNOME */
2854 widget = parent; 2854 widget = parent;
2855 dockitem = BONOBO_DOCK_ITEM(widget); 2855 dockitem = BONOBO_DOCK_ITEM(widget);
2856 2856
2857 if (dockitem == NULL || dockitem->is_floating) 2857 if (dockitem == NULL || dockitem->is_floating)
2858 return 0; 2858 return 0;
2859 item_orientation = bonobo_dock_item_get_orientation(dockitem); 2859 item_orientation = bonobo_dock_item_get_orientation(dockitem);
2860 } 2860 }
2861 # else 2861 # else
2862 GnomeDockItem *dockitem; 2862 GnomeDockItem *dockitem;
2863 2863
2864 widget = widget->parent; 2864 widget = widget->parent;
2865 dockitem = GNOME_DOCK_ITEM(widget); 2865 dockitem = GNOME_DOCK_ITEM(widget);
2951 * values have been used (those that dictate our initial size) 2951 * values have been used (those that dictate our initial size)
2952 * Let forced (i.e., correct) values thruogh always. 2952 * Let forced (i.e., correct) values thruogh always.
2953 */ 2953 */
2954 if (!(force_width && force_height) && init_window_hints_state > 0) 2954 if (!(force_width && force_height) && init_window_hints_state > 0)
2955 { 2955 {
2956 /* Don't do it! */ 2956 /* Don't do it! */
2957 init_window_hints_state = 2; 2957 init_window_hints_state = 2;
2958 return; 2958 return;
2959 } 2959 }
2960 2960
2961 /* This also needs to be done when the main window isn't there yet, 2961 /* This also needs to be done when the main window isn't there yet,
2962 * otherwise the hints don't work. */ 2962 * otherwise the hints don't work. */
2963 width = gui_get_base_width(); 2963 width = gui_get_base_width();
2976 * we wish to be instead of the legitimate minimum so that we actually 2976 * we wish to be instead of the legitimate minimum so that we actually
2977 * resize correctly. 2977 * resize correctly.
2978 */ 2978 */
2979 if (force_width && force_height) 2979 if (force_width && force_height)
2980 { 2980 {
2981 min_width = force_width; 2981 min_width = force_width;
2982 min_height = force_height; 2982 min_height = force_height;
2983 } 2983 }
2984 else 2984 else
2985 { 2985 {
2986 min_width = width + MIN_COLUMNS * gui.char_width; 2986 min_width = width + MIN_COLUMNS * gui.char_width;
2987 min_height = height + MIN_LINES * gui.char_height; 2987 min_height = height + MIN_LINES * gui.char_height;
2988 } 2988 }
2989 2989
2990 /* Avoid an expose event when the size didn't change. */ 2990 /* Avoid an expose event when the size didn't change. */
2991 if (width != old_width 2991 if (width != old_width
2992 || height != old_height 2992 || height != old_height
2993 || min_width != old_min_width 2993 || min_width != old_min_width
2994 || min_height != old_min_height 2994 || min_height != old_min_height
2995 || gui.char_width != old_char_width 2995 || gui.char_width != old_char_width
2996 || gui.char_height != old_char_height) 2996 || gui.char_height != old_char_height)
2997 { 2997 {
2998 GdkGeometry geometry; 2998 GdkGeometry geometry;
3000 3000
3001 geometry.width_inc = gui.char_width; 3001 geometry.width_inc = gui.char_width;
3002 geometry.height_inc = gui.char_height; 3002 geometry.height_inc = gui.char_height;
3003 geometry.base_width = width; 3003 geometry.base_width = width;
3004 geometry.base_height = height; 3004 geometry.base_height = height;
3005 geometry.min_width = min_width; 3005 geometry.min_width = min_width;
3006 geometry.min_height = min_height; 3006 geometry.min_height = min_height;
3007 geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC 3007 geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC
3008 |GDK_HINT_MIN_SIZE; 3008 |GDK_HINT_MIN_SIZE;
3009 # ifdef HAVE_GTK2 3009 # ifdef HAVE_GTK2
3010 /* Using gui.formwin as geometry widget doesn't work as expected 3010 /* Using gui.formwin as geometry widget doesn't work as expected
3011 * with GTK+ 2 -- dunno why. Presumably all the resizing hacks 3011 * with GTK+ 2 -- dunno why. Presumably all the resizing hacks
3014 &geometry, geometry_mask); 3014 &geometry, geometry_mask);
3015 # else 3015 # else
3016 gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.formwin, 3016 gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.formwin,
3017 &geometry, geometry_mask); 3017 &geometry, geometry_mask);
3018 # endif 3018 # endif
3019 old_width = width; 3019 old_width = width;
3020 old_height = height; 3020 old_height = height;
3021 old_min_width = min_width; 3021 old_min_width = min_width;
3022 old_min_height = min_height; 3022 old_min_height = min_height;
3023 old_char_width = gui.char_width; 3023 old_char_width = gui.char_width;
3024 old_char_height = gui.char_height; 3024 old_char_height = gui.char_height;
3025 } 3025 }
3026 } 3026 }
3027 3027
3028 #ifdef FEAT_TOOLBAR 3028 #ifdef FEAT_TOOLBAR
3029 3029
3344 /* Remove any old labels. */ 3344 /* Remove any old labels. */
3345 while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) 3345 while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL)
3346 gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); 3346 gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr);
3347 3347
3348 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) 3348 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx)
3349 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), curtabidx); 3349 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), curtabidx);
3350 3350
3351 /* Make sure everything is in place before drawing text. */ 3351 /* Make sure everything is in place before drawing text. */
3352 gui_mch_update(); 3352 gui_mch_update();
3353 3353
3354 ignore_tabline_evt = FALSE; 3354 ignore_tabline_evt = FALSE;
3364 if (gui.tabline == NULL) 3364 if (gui.tabline == NULL)
3365 return; 3365 return;
3366 3366
3367 ignore_tabline_evt = TRUE; 3367 ignore_tabline_evt = TRUE;
3368 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) 3368 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1)
3369 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), nr - 1); 3369 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), nr - 1);
3370 ignore_tabline_evt = FALSE; 3370 ignore_tabline_evt = FALSE;
3371 } 3371 }
3372 3372
3373 #endif /* FEAT_GUI_TABLINE */ 3373 #endif /* FEAT_GUI_TABLINE */
3374 3374
3676 gtk_tooltips_enable(GTK_TOOLTIPS(tabline_tooltip)); 3676 gtk_tooltips_enable(GTK_TOOLTIPS(tabline_tooltip));
3677 3677
3678 { 3678 {
3679 GtkWidget *page, *label, *event_box; 3679 GtkWidget *page, *label, *event_box;
3680 3680
3681 /* Add the first tab. */ 3681 /* Add the first tab. */
3682 page = gtk_vbox_new(FALSE, 0); 3682 page = gtk_vbox_new(FALSE, 0);
3683 gtk_widget_show(page); 3683 gtk_widget_show(page);
3684 gtk_container_add(GTK_CONTAINER(gui.tabline), page); 3684 gtk_container_add(GTK_CONTAINER(gui.tabline), page);
3685 label = gtk_label_new("-Empty-"); 3685 label = gtk_label_new("-Empty-");
3686 gtk_widget_show(label); 3686 gtk_widget_show(label);
3690 gtk_misc_set_padding(GTK_MISC(label), 2, 2); 3690 gtk_misc_set_padding(GTK_MISC(label), 2, 2);
3691 gtk_container_add(GTK_CONTAINER(event_box), label); 3691 gtk_container_add(GTK_CONTAINER(event_box), label);
3692 gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box); 3692 gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box);
3693 } 3693 }
3694 gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page", 3694 gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page",
3695 GTK_SIGNAL_FUNC(on_select_tab), NULL); 3695 GTK_SIGNAL_FUNC(on_select_tab), NULL);
3696 3696
3697 /* Create a popup menu for the tab line and connect it. */ 3697 /* Create a popup menu for the tab line and connect it. */
3698 tabline_menu = create_tabline_menu(); 3698 tabline_menu = create_tabline_menu();
3699 gtk_signal_connect_object(GTK_OBJECT(gui.tabline), "button_press_event", 3699 gtk_signal_connect_object(GTK_OBJECT(gui.tabline), "button_press_event",
3700 GTK_SIGNAL_FUNC(on_tabline_menu), GTK_OBJECT(tabline_menu)); 3700 GTK_SIGNAL_FUNC(on_tabline_menu), GTK_OBJECT(tabline_menu));
3701 #endif 3701 #endif
3702 3702
3703 gui.formwin = gtk_form_new(); 3703 gui.formwin = gtk_form_new();
3704 gtk_container_border_width(GTK_CONTAINER(gui.formwin), 0); 3704 gtk_container_border_width(GTK_CONTAINER(gui.formwin), 0);
3705 gtk_widget_set_events(gui.formwin, GDK_EXPOSURE_MASK); 3705 gtk_widget_set_events(gui.formwin, GDK_EXPOSURE_MASK);
3795 * only its widgets. Arguably, this could be common code and we not use 3795 * only its widgets. Arguably, this could be common code and we not use
3796 * the window focus at all, but let's be safe. 3796 * the window focus at all, but let's be safe.
3797 */ 3797 */
3798 if (gtk_socket_id == 0) 3798 if (gtk_socket_id == 0)
3799 { 3799 {
3800 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_out_event", 3800 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_out_event",
3801 GTK_SIGNAL_FUNC(focus_out_event), NULL); 3801 GTK_SIGNAL_FUNC(focus_out_event), NULL);
3802 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_in_event", 3802 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_in_event",
3803 GTK_SIGNAL_FUNC(focus_in_event), NULL); 3803 GTK_SIGNAL_FUNC(focus_in_event), NULL);
3804 } 3804 }
3805 else 3805 else
3806 { 3806 {
3807 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_out_event", 3807 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_out_event",
3808 GTK_SIGNAL_FUNC(focus_out_event), NULL); 3808 GTK_SIGNAL_FUNC(focus_out_event), NULL);
3809 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_in_event", 3809 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_in_event",
3810 GTK_SIGNAL_FUNC(focus_in_event), NULL); 3810 GTK_SIGNAL_FUNC(focus_in_event), NULL);
3811 #ifdef FEAT_GUI_TABLINE 3811 #ifdef FEAT_GUI_TABLINE
3812 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_out_event", 3812 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_out_event",
3813 GTK_SIGNAL_FUNC(focus_out_event), NULL); 3813 GTK_SIGNAL_FUNC(focus_out_event), NULL);
3814 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_in_event", 3814 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_in_event",
3815 GTK_SIGNAL_FUNC(focus_in_event), NULL); 3815 GTK_SIGNAL_FUNC(focus_in_event), NULL);
3816 #endif /* FEAT_GUI_TABLINE */ 3816 #endif /* FEAT_GUI_TABLINE */
3817 } 3817 }
3818 3818
3819 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "motion_notify_event", 3819 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "motion_notify_event",
3820 GTK_SIGNAL_FUNC(motion_notify_event), NULL); 3820 GTK_SIGNAL_FUNC(motion_notify_event), NULL);
3904 /* When in a GtkPlug, we can't guarantee valid heights (as a round 3904 /* When in a GtkPlug, we can't guarantee valid heights (as a round
3905 * no. of char-heights), so we have to manually sanitise them. 3905 * no. of char-heights), so we have to manually sanitise them.
3906 * Widths seem to sort themselves out, don't ask me why. 3906 * Widths seem to sort themselves out, don't ask me why.
3907 */ 3907 */
3908 if (gtk_socket_id != 0) 3908 if (gtk_socket_id != 0)
3909 usable_height -= (gui.char_height - (gui.char_height/2)); /* sic. */ 3909 usable_height -= (gui.char_height - (gui.char_height/2)); /* sic. */
3910 3910
3911 gtk_form_freeze(GTK_FORM(gui.formwin)); 3911 gtk_form_freeze(GTK_FORM(gui.formwin));
3912 gui_resize_shell(event->width, usable_height); 3912 gui_resize_shell(event->width, usable_height);
3913 gtk_form_thaw(GTK_FORM(gui.formwin)); 3913 gtk_form_thaw(GTK_FORM(gui.formwin));
3914 3914
3956 static gboolean 3956 static gboolean
3957 check_startup_plug_hints(gpointer data) 3957 check_startup_plug_hints(gpointer data)
3958 { 3958 {
3959 if (init_window_hints_state == 1) 3959 if (init_window_hints_state == 1)
3960 { 3960 {
3961 /* Safe to use normal hints now */ 3961 /* Safe to use normal hints now */
3962 init_window_hints_state = 0; 3962 init_window_hints_state = 0;
3963 update_window_manager_hints(0, 0); 3963 update_window_manager_hints(0, 0);
3964 return FALSE; /* stop timer */ 3964 return FALSE; /* stop timer */
3965 } 3965 }
3966 3966
3967 /* Keep on trying */ 3967 /* Keep on trying */
3968 init_window_hints_state = 1; 3968 init_window_hints_state = 1;
3969 return TRUE; 3969 return TRUE;
4032 gtk_widget_set_uposition(gui.mainwin, x, y); 4032 gtk_widget_set_uposition(gui.mainwin, x, y);
4033 #endif 4033 #endif
4034 vim_free(gui.geom); 4034 vim_free(gui.geom);
4035 gui.geom = NULL; 4035 gui.geom = NULL;
4036 4036
4037 /* From now until everyone's stopped trying to set the window hints 4037 /* From now until everyone's stopped trying to set the window hints
4038 * to their correct minimum values, stop them being set as we need 4038 * to their correct minimum values, stop them being set as we need
4039 * them to remain at our required size for the parent GtkSocket to 4039 * them to remain at our required size for the parent GtkSocket to
4040 * give us the right initial size. 4040 * give us the right initial size.
4041 */ 4041 */
4042 if (gtk_socket_id != 0 && (mask & WidthValue || mask & HeightValue)) 4042 if (gtk_socket_id != 0 && (mask & WidthValue || mask & HeightValue))
4043 { 4043 {
4044 guint pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width); 4044 guint pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
4045 guint pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height); 4045 guint pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height);
4046 4046
4047 #ifdef HAVE_GTK2 4047 #ifdef HAVE_GTK2
4048 pixel_width += get_menu_tool_width(); 4048 pixel_width += get_menu_tool_width();
4049 pixel_height += get_menu_tool_height(); 4049 pixel_height += get_menu_tool_height();
4050 #endif 4050 #endif
4051 4051
4052 update_window_manager_hints(pixel_width, pixel_height); 4052 update_window_manager_hints(pixel_width, pixel_height);
4053 init_window_hints_state = 1; 4053 init_window_hints_state = 1;
4054 g_timeout_add(1000, check_startup_plug_hints, NULL); 4054 g_timeout_add(1000, check_startup_plug_hints, NULL);
4055 } 4055 }
4056 } 4056 }
4057 4057
4058 gtk_form_set_size(GTK_FORM(gui.formwin), 4058 gtk_form_set_size(GTK_FORM(gui.formwin),
4059 (guint)(gui_get_base_width() + Columns * gui.char_width), 4059 (guint)(gui_get_base_width() + Columns * gui.char_width),
4060 (guint)(gui_get_base_height() + Rows * gui.char_height)); 4060 (guint)(gui_get_base_height() + Rows * gui.char_height));
4297 update_window_manager_hints(0, 0); 4297 update_window_manager_hints(0, 0);
4298 4298
4299 #else /* HAVE_GTK2 */ 4299 #else /* HAVE_GTK2 */
4300 /* this will cause the proper resizement to happen too */ 4300 /* this will cause the proper resizement to happen too */
4301 if (gtk_socket_id == 0) 4301 if (gtk_socket_id == 0)
4302 update_window_manager_hints(0, 0); 4302 update_window_manager_hints(0, 0);
4303 4303
4304 /* With GTK+ 2, changing the size of the form widget doesn't resize 4304 /* With GTK+ 2, changing the size of the form widget doesn't resize
4305 * the window. So let's do it the other way around and resize the 4305 * the window. So let's do it the other way around and resize the
4306 * main window instead. */ 4306 * main window instead. */
4307 width += get_menu_tool_width(); 4307 width += get_menu_tool_width();
4308 height += get_menu_tool_height(); 4308 height += get_menu_tool_height();
4309 4309
4310 if (gtk_socket_id == 0) 4310 if (gtk_socket_id == 0)
4311 gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height); 4311 gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height);
4312 else 4312 else
4313 update_window_manager_hints(width, height); 4313 update_window_manager_hints(width, height);
4314 4314
4315 #if 0 4315 #if 0
4316 if (!resize_idle_installed) 4316 if (!resize_idle_installed)
4317 { 4317 {
4318 g_idle_add_full(GDK_PRIORITY_EVENTS + 10, 4318 g_idle_add_full(GDK_PRIORITY_EVENTS + 10,
7174 } 7174 }
7175 } 7175 }
7176 # endif /* !HAVE_GTK2 */ 7176 # endif /* !HAVE_GTK2 */
7177 7177
7178 #endif /* FEAT_SIGN_ICONS */ 7178 #endif /* FEAT_SIGN_ICONS */
7179