aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-08 19:14:52 +0800
committerPo Lu2022-02-08 19:14:52 +0800
commit996daa00ae3cab514a0f9fca0ee8b108f220677e (patch)
treeabd31820fe3ef2c2e87aca4f9917593bbabdf887 /src
parentf788bb33e5ac4d4a482e88dedd89e5a64dd1f7d5 (diff)
downloademacs-996daa00ae3cab514a0f9fca0ee8b108f220677e.tar.gz
emacs-996daa00ae3cab514a0f9fca0ee8b108f220677e.zip
Implement frame resize synchronization on GTK 3
* src/xterm.c (XTframe_up_to_date): (handle_one_xevent): Use the GTK frame clock to implement frame resize synchronization. * src/xterm.h (struct x_output): New variable `xg_sync_end_pending_p'.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c45
-rw-r--r--src/xterm.h3
2 files changed, 46 insertions, 2 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 8bdb3c9ea1b..9b480069275 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1848,10 +1848,14 @@ x_update_end (struct frame *f)
1848static void 1848static void
1849XTframe_up_to_date (struct frame *f) 1849XTframe_up_to_date (struct frame *f)
1850{ 1850{
1851#ifdef HAVE_XSYNC 1851#if defined HAVE_XSYNC && !defined HAVE_GTK3
1852 XSyncValue add; 1852 XSyncValue add;
1853 XSyncValue current; 1853 XSyncValue current;
1854 Bool overflow_p; 1854 Bool overflow_p;
1855#elif defined HAVE_XSYNC
1856 GtkWidget *widget;
1857 GdkWindow *window;
1858 GdkFrameClock *clock;
1855#endif 1859#endif
1856 1860
1857 eassert (FRAME_X_P (f)); 1861 eassert (FRAME_X_P (f));
@@ -1861,6 +1865,7 @@ XTframe_up_to_date (struct frame *f)
1861 show_back_buffer (f); 1865 show_back_buffer (f);
1862 1866
1863#ifdef HAVE_XSYNC 1867#ifdef HAVE_XSYNC
1868#ifndef HAVE_GTK3
1864 if (FRAME_X_OUTPUT (f)->sync_end_pending_p 1869 if (FRAME_X_OUTPUT (f)->sync_end_pending_p
1865 && FRAME_X_BASIC_COUNTER (f) != None) 1870 && FRAME_X_BASIC_COUNTER (f) != None)
1866 { 1871 {
@@ -1892,6 +1897,20 @@ XTframe_up_to_date (struct frame *f)
1892 1897
1893 FRAME_X_OUTPUT (f)->ext_sync_end_pending_p = false; 1898 FRAME_X_OUTPUT (f)->ext_sync_end_pending_p = false;
1894 } 1899 }
1900#else
1901 if (FRAME_X_OUTPUT (f)->xg_sync_end_pending_p)
1902 {
1903 widget = FRAME_GTK_OUTER_WIDGET (f);
1904 window = gtk_widget_get_window (widget);
1905 eassert (window);
1906 clock = gdk_window_get_frame_clock (window);
1907 eassert (clock);
1908
1909 gdk_frame_clock_request_phase (clock,
1910 GDK_FRAME_CLOCK_PHASE_AFTER_PAINT);
1911 FRAME_X_OUTPUT (f)->xg_sync_end_pending_p = false;
1912 }
1913#endif
1895#endif 1914#endif
1896 unblock_input (); 1915 unblock_input ();
1897} 1916}
@@ -9130,7 +9149,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9130 goto done; 9149 goto done;
9131 } 9150 }
9132 9151
9133#if defined HAVE_XSYNC && !defined HAVE_GTK3 9152#if defined HAVE_XSYNC
9134 if (event->xclient.data.l[0] == dpyinfo->Xatom_net_wm_sync_request 9153 if (event->xclient.data.l[0] == dpyinfo->Xatom_net_wm_sync_request
9135 && event->xclient.format == 32 9154 && event->xclient.format == 32
9136 && dpyinfo->xsync_supported_p) 9155 && dpyinfo->xsync_supported_p)
@@ -9138,9 +9157,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9138 struct frame *f 9157 struct frame *f
9139 = x_top_window_to_frame (dpyinfo, 9158 = x_top_window_to_frame (dpyinfo,
9140 event->xclient.window); 9159 event->xclient.window);
9160#if defined HAVE_GTK3
9161 GtkWidget *widget;
9162 GdkWindow *window;
9163 GdkFrameClock *frame_clock;
9164#endif
9141 9165
9142 if (f) 9166 if (f)
9143 { 9167 {
9168#ifndef HAVE_GTK3
9144 if (event->xclient.data.l[4] == 0) 9169 if (event->xclient.data.l[4] == 0)
9145 { 9170 {
9146 XSyncIntsToValue (&FRAME_X_OUTPUT (f)->pending_basic_counter_value, 9171 XSyncIntsToValue (&FRAME_X_OUTPUT (f)->pending_basic_counter_value,
@@ -9155,6 +9180,22 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9155 } 9180 }
9156 9181
9157 *finish = X_EVENT_DROP; 9182 *finish = X_EVENT_DROP;
9183#else
9184 widget = FRAME_GTK_OUTER_WIDGET (f);
9185
9186 if (widget && !FRAME_X_OUTPUT (f)->xg_sync_end_pending_p)
9187 {
9188 window = gtk_widget_get_window (widget);
9189 eassert (window);
9190 frame_clock = gdk_window_get_frame_clock (window);
9191 eassert (frame_clock);
9192
9193 gdk_frame_clock_request_phase (frame_clock,
9194 GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT);
9195
9196 FRAME_X_OUTPUT (f)->xg_sync_end_pending_p = true;
9197 }
9198#endif
9158 goto done; 9199 goto done;
9159 } 9200 }
9160 } 9201 }
diff --git a/src/xterm.h b/src/xterm.h
index 854d87c83ce..1ce3e7a6cf8 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -822,6 +822,9 @@ struct x_output
822 822
823 bool_bf sync_end_pending_p : 1; 823 bool_bf sync_end_pending_p : 1;
824 bool_bf ext_sync_end_pending_p : 1; 824 bool_bf ext_sync_end_pending_p : 1;
825#ifdef HAVE_GTK3
826 bool_bf xg_sync_end_pending_p : 1;
827#endif
825#endif 828#endif
826 829
827 /* Relief GCs, colors etc. */ 830 /* Relief GCs, colors etc. */