comparison src/gui_gtk_x11.c @ 8412:7ee2b87ba896 v7.4.1497

commit https://github.com/vim/vim/commit/0ecbe33718b06a3771fd2c65b331c8c9504657d7 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 5 22:40:52 2016 +0100 patch 7.4.1497 Problem: Cursor drawing problem with GTK 3. Solution: Handle blinking differently. (Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Sat, 05 Mar 2016 22:45:04 +0100
parents 1e58a938aafc
children 42020d59a432
comparison
equal deleted inserted replaced
8411:fcc4277a29c2 8412:7ee2b87ba896
615 /* 615 /*
616 * Redraw the corresponding portions of the screen. 616 * Redraw the corresponding portions of the screen.
617 */ 617 */
618 #if GTK_CHECK_VERSION(3,0,0) 618 #if GTK_CHECK_VERSION(3,0,0)
619 static gboolean is_key_pressed = FALSE; 619 static gboolean is_key_pressed = FALSE;
620 static gboolean blink_mode = TRUE;
620 621
621 static gboolean gui_gtk_is_blink_on(void); 622 static gboolean gui_gtk_is_blink_on(void);
622 static gboolean gui_gtk_is_no_blink(void);
623 static void gui_gtk_window_clear(GdkWindow *win); 623 static void gui_gtk_window_clear(GdkWindow *win);
624 624
625 static void 625 static void
626 gui_gtk3_redraw(int x, int y, int width, int height) 626 gui_gtk3_redraw(int x, int y, int width, int height)
627 { 627 {
647 { 647 {
648 unsigned int cond = 0; 648 unsigned int cond = 0;
649 cond |= gui_gtk_is_blink_on(); 649 cond |= gui_gtk_is_blink_on();
650 cond |= is_key_pressed; 650 cond |= is_key_pressed;
651 cond |= gui.in_focus == FALSE; 651 cond |= gui.in_focus == FALSE;
652 cond |= gui_gtk_is_no_blink();
653 return cond; 652 return cond;
654 } 653 }
655 654
656 static gboolean 655 static gboolean
657 draw_event(GtkWidget *widget, 656 draw_event(GtkWidget *widget,
679 { 678 {
680 int i; 679 int i;
681 for (i = 0; i < list->num_rectangles; i++) 680 for (i = 0; i < list->num_rectangles; i++)
682 { 681 {
683 const cairo_rectangle_t rect = list->rectangles[i]; 682 const cairo_rectangle_t rect = list->rectangles[i];
684 gui_gtk3_redraw(rect.x, rect.y, rect.width, rect.height); 683 if (blink_mode)
684 gui_gtk3_redraw(rect.x, rect.y, rect.width, rect.height);
685 else
686 gui_redraw(rect.x, rect.y, rect.width, rect.height);
685 } 687 }
686 } 688 }
687 cairo_rectangle_list_destroy(list); 689 cairo_rectangle_list_destroy(list);
688 690
689 cairo_paint(cr); 691 cairo_paint(cr);
788 static gboolean 790 static gboolean
789 gui_gtk_is_blink_on(void) 791 gui_gtk_is_blink_on(void)
790 { 792 {
791 return blink_state == BLINK_ON; 793 return blink_state == BLINK_ON;
792 } 794 }
793
794 static gboolean
795 gui_gtk_is_no_blink(void)
796 {
797 return blink_waittime == 0 || blink_ontime == 0 || blink_offtime == 0;
798 }
799 #endif 795 #endif
800 796
801 void 797 void
802 gui_mch_set_blinking(long waittime, long on, long off) 798 gui_mch_set_blinking(long waittime, long on, long off)
803 { 799 {
800 #if GTK_CHECK_VERSION(3,0,0)
801 if (waittime == 0 || on == 0 || off == 0)
802 {
803 blink_mode = FALSE;
804
805 blink_waittime = 700;
806 blink_ontime = 400;
807 blink_offtime = 250;
808 }
809 else
810 {
811 blink_mode = TRUE;
812
813 blink_waittime = waittime;
814 blink_ontime = on;
815 blink_offtime = off;
816 }
817 #else
804 blink_waittime = waittime; 818 blink_waittime = waittime;
805 blink_ontime = on; 819 blink_ontime = on;
806 blink_offtime = off; 820 blink_offtime = off;
821 #endif
807 } 822 }
808 823
809 /* 824 /*
810 * Stop the cursor blinking. Show the cursor if it wasn't shown. 825 * Stop the cursor blinking. Show the cursor if it wasn't shown.
811 */ 826 */