aboutsummaryrefslogtreecommitdiffstats
path: root/src/pgtkterm.c
diff options
context:
space:
mode:
authorPo Lu2021-12-29 09:53:42 +0800
committerPo Lu2021-12-29 09:59:30 +0800
commit9249365837c33e18f8504dcbf12b8c3d217f0d43 (patch)
tree7ead38d4557c0818b02172e82bfa9b4103022ae6 /src/pgtkterm.c
parent1e6c7cfd0beed5937dfb1ba4ad805666b19ea23e (diff)
downloademacs-9249365837c33e18f8504dcbf12b8c3d217f0d43.tar.gz
emacs-9249365837c33e18f8504dcbf12b8c3d217f0d43.zip
Add support for xwidgets to the PGTK port
* src/emacsgtkfixed.c (EMACS_FIXED_GET_CLASS): New function. (struct GtkFixedPrivateL): New struct. (emacs_fixed_gtk_widget_size_allocate): (emacs_fixed_class_init): New functions. * src/keyboard.h: Declare lispy_function_keys also when HAVE_PGTK. * src/pgtkterm.c (x_free_frame_resources): Destroy all xwidget views. (pgtk_scroll_run): Move xwidget views that overlap with the scrolled area. (pgtk_emacs_to_gtk_modifiers): Expose function. * src/pgtkterm.h: Wrap in include guard. (pgtk_emacs_to_gtk_modifiers): New prototype. * src/xwidget.c (xw_forward_event_translate): (xw_forward_event_from_view): New functions. (Fmake_xwidget): Remove obsolete PGTK specific code. (Fxwidget_perform_lispy_event): Convert modifiers correctly on PGTK. (define_cursors): Use GDK functions to define cursors on PGTK. (xwidget_view_from_window): Disable on non-PGTK builds. (xwidget_show_view): (xwidget_hide_view): Implement on PGTK. (xv_do_draw): Disable on non-PGTK builds. (offscreen_damage_event): Queue xwidget views for draw. (xwidget_expose): Disable on non-PGTK builds. (xwidget_init_view): (x_draw_xwidget_glyph_string): (Fdelete_xwidget_view): Implement for PGTK. (syms_of_xwidget): Don't initialize XID to widget table on PGTK. (lower_frame_xwidget_views): Disable on PGTK. * src/xwidget.h (struct xwidget_view): New fields for PGTK builds. (kill_frame_xwidget_views): Enable on PGTK.
Diffstat (limited to 'src/pgtkterm.c')
-rw-r--r--src/pgtkterm.c90
1 files changed, 89 insertions, 1 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index c75dab5130a..0814fb0df88 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -245,6 +245,9 @@ x_free_frame_resources (struct frame *f)
245 245
246 block_input (); 246 block_input ();
247 247
248#ifdef HAVE_XWIDGETS
249 kill_frame_xwidget_views (f);
250#endif
248 free_frame_faces (f); 251 free_frame_faces (f);
249 252
250 if (FRAME_X_OUTPUT (f)->scale_factor_atimer != NULL) 253 if (FRAME_X_OUTPUT (f)->scale_factor_atimer != NULL)
@@ -2999,6 +3002,91 @@ pgtk_scroll_run (struct window *w, struct run *run)
2999 3002
3000 block_input (); 3003 block_input ();
3001 3004
3005#ifdef HAVE_XWIDGETS
3006 /* "Copy" xwidget views in the area that will be scrolled. */
3007 GtkWidget *tem, *parent = FRAME_GTK_WIDGET (f);
3008 GList *children = gtk_container_get_children (GTK_CONTAINER (parent));
3009 GList *iter;
3010 struct xwidget_view *view;
3011
3012 for (iter = children; iter; iter = iter->next)
3013 {
3014 tem = iter->data;
3015 view = g_object_get_data (G_OBJECT (tem), XG_XWIDGET_VIEW);
3016
3017 if (view && !view->hidden)
3018 {
3019 int window_y = view->y + view->clip_top;
3020 int window_height = view->clip_bottom - view->clip_top;
3021
3022 Emacs_Rectangle r1, r2, result;
3023 r1.x = w->pixel_left;
3024 r1.y = from_y;
3025 r1.width = w->pixel_width;
3026 r1.height = height;
3027 r2 = r1;
3028 r2.y = window_y;
3029 r2.height = window_height;
3030
3031 /* The window is offscreen, just unmap it. */
3032 if (window_height == 0)
3033 {
3034 view->hidden = true;
3035 gtk_widget_hide (tem);
3036 continue;
3037 }
3038
3039 bool intersects_p =
3040 gui_intersect_rectangles (&r1, &r2, &result);
3041
3042 if (XWINDOW (view->w) == w && intersects_p)
3043 {
3044 int y = view->y + (to_y - from_y);
3045 int text_area_x, text_area_y, text_area_width, text_area_height;
3046 int clip_top, clip_bottom;
3047
3048 window_box (w, view->area, &text_area_x, &text_area_y,
3049 &text_area_width, &text_area_height);
3050
3051 view->y = y;
3052
3053 clip_top = 0;
3054 clip_bottom = XXWIDGET (view->model)->height;
3055
3056 if (y < text_area_y)
3057 clip_top = text_area_y - y;
3058
3059 if ((y + clip_bottom) > (text_area_y + text_area_height))
3060 {
3061 clip_bottom -= (y + clip_bottom) - (text_area_y + text_area_height);
3062 }
3063
3064 view->clip_top = clip_top;
3065 view->clip_bottom = clip_bottom;
3066
3067 /* This means the view has moved offscreen. Unmap
3068 it and hide it here. */
3069 if ((view->clip_bottom - view->clip_top) <= 0)
3070 {
3071 view->hidden = true;
3072 gtk_widget_hide (tem);
3073 }
3074 else
3075 {
3076 gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (f)),
3077 tem, view->x + view->clip_left,
3078 view->y + view->clip_top);
3079 gtk_widget_set_size_request (tem, view->clip_right - view->clip_left,
3080 view->clip_bottom - view->clip_top);
3081 gtk_widget_queue_allocate (tem);
3082 }
3083 }
3084 }
3085 }
3086
3087 g_list_free (children);
3088#endif
3089
3002 /* Cursor off. Will be switched on again in x_update_window_end. */ 3090 /* Cursor off. Will be switched on again in x_update_window_end. */
3003 gui_clear_cursor (w); 3091 gui_clear_cursor (w);
3004 3092
@@ -5099,7 +5187,7 @@ pgtk_gtk_to_emacs_modifiers (struct pgtk_display_info *dpyinfo, int state)
5099 return mod; 5187 return mod;
5100} 5188}
5101 5189
5102static int 5190int
5103pgtk_emacs_to_gtk_modifiers (struct pgtk_display_info *dpyinfo, int state) 5191pgtk_emacs_to_gtk_modifiers (struct pgtk_display_info *dpyinfo, int state)
5104{ 5192{
5105 int mod_ctrl; 5193 int mod_ctrl;