[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0ce48e2882: Handle exposure in the widget's expose proc on X
From: |
Po Lu |
Subject: |
master 0ce48e2882: Handle exposure in the widget's expose proc on X |
Date: |
Sat, 30 Apr 2022 02:32:26 -0400 (EDT) |
branch: master
commit 0ce48e2882ad73925f9b524d879d8e57909e6d38
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Handle exposure in the widget's expose proc on X
* src/widget.c (emacsFrameClassRec): Don't inherit expose proc.
(get_default_char_pixel_size):
(pixel_to_char_size):
(char_to_pixel_size):
(round_size_to_char):
(EmacsFrameInitialize):
(EmacsFrameRealize):
(EmacsFrameResize): Clean up coding style.
(EmacsFrameExpose): New function. Expose the frame here to
satisfy the toolkit when it calls the expose proc by hand.
* src/xterm.c (handle_one_xevent): Handle exposure through the
widget instead.
---
src/widget.c | 54 +++++++++++++++++++++++++++++++++++++++---------------
src/xterm.c | 6 ++++++
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/src/widget.c b/src/widget.c
index 4231aa71b5..b125b4caee 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -42,11 +42,13 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include <X11/ShellP.h>
#include "../lwlib/lwlib.h"
-static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1,
Cardinal *dum2);
-static void EmacsFrameDestroy (Widget widget);
-static void EmacsFrameRealize (Widget widget, XtValueMask *mask,
XSetWindowAttributes *attrs);
-static void EmacsFrameResize (Widget widget);
-static XtGeometryResult EmacsFrameQueryGeometry (Widget widget,
XtWidgetGeometry *request, XtWidgetGeometry *result);
+static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *);
+static void EmacsFrameDestroy (Widget);
+static void EmacsFrameRealize (Widget, XtValueMask *, XSetWindowAttributes *);
+static void EmacsFrameResize (Widget);
+static void EmacsFrameExpose (Widget, XEvent *, Region);
+static XtGeometryResult EmacsFrameQueryGeometry (Widget, XtWidgetGeometry *,
+ XtWidgetGeometry *);
#define offset(field) offsetof (EmacsFrameRec, emacs_frame.field)
@@ -118,12 +120,12 @@ static EmacsFrameClassRec emacsFrameClassRec = {
/* resource_count */ XtNumber (resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
+ /* compress_exposure */ XtExposeNoCompress,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ EmacsFrameDestroy,
/* resize */ EmacsFrameResize,
- /* expose */ XtInheritExpose,
+ /* expose */ EmacsFrameExpose,
/* Emacs never does XtSetvalues on this widget, so we have no code
for it. */
@@ -156,33 +158,41 @@ static void
get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int
*pixel_height)
{
struct frame *f = ew->emacs_frame.frame;
+
*pixel_width = FRAME_COLUMN_WIDTH (f);
*pixel_height = FRAME_LINE_HEIGHT (f);
}
static void
-pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension
pixel_height, int *char_width, int *char_height)
+pixel_to_char_size (EmacsFrame ew, Dimension pixel_width,
+ Dimension pixel_height, int *char_width, int *char_height)
{
struct frame *f = ew->emacs_frame.frame;
+
*char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width);
*char_height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (int) pixel_height);
}
static void
-char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension
*pixel_width, Dimension *pixel_height)
+char_to_pixel_size (EmacsFrame ew, int char_width, int char_height,
+ Dimension *pixel_width, Dimension *pixel_height)
{
struct frame *f = ew->emacs_frame.frame;
+
*pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width);
*pixel_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, char_height);
}
static void
-round_size_to_char (EmacsFrame ew, Dimension in_width, Dimension in_height,
Dimension *out_width, Dimension *out_height)
+round_size_to_char (EmacsFrame ew, Dimension in_width, Dimension in_height,
+ Dimension *out_width, Dimension *out_height)
{
int char_width;
int char_height;
- pixel_to_char_size (ew, in_width, in_height, &char_width, &char_height);
- char_to_pixel_size (ew, char_width, char_height, out_width, out_height);
+ pixel_to_char_size (ew, in_width, in_height,
+ &char_width, &char_height);
+ char_to_pixel_size (ew, char_width, char_height,
+ out_width, out_height);
}
static Widget
@@ -334,7 +344,8 @@ update_from_various_frame_slots (EmacsFrame ew)
}
static void
-EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2)
+EmacsFrameInitialize (Widget request, Widget new,
+ ArgList dum1, Cardinal *dum2)
{
EmacsFrame ew = (EmacsFrame) new;
@@ -359,7 +370,8 @@ resize_cb (Widget widget,
static void
-EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes
*attrs)
+EmacsFrameRealize (Widget widget, XtValueMask *mask,
+ XSetWindowAttributes *attrs)
{
EmacsFrame ew = (EmacsFrame) widget;
struct frame *f = ew->emacs_frame.frame;
@@ -404,7 +416,8 @@ EmacsFrameResize (Widget widget)
ew->core.width, ew->core.height,
f->new_width, f->new_height);
- change_frame_size (f, ew->core.width, ew->core.height, false, true, false);
+ change_frame_size (f, ew->core.width, ew->core.height,
+ false, true, false);
if (get_wm_shell (widget))
update_wm_hints (get_wm_shell (widget), ew);
@@ -462,6 +475,17 @@ EmacsFrameSetCharSize (Widget widget, int columns, int
rows)
rows * FRAME_LINE_HEIGHT (f));
}
+static void
+EmacsFrameExpose (Widget widget, XEvent *event, Region region)
+{
+ EmacsFrame ew = (EmacsFrame) widget;
+ struct frame *f = ew->emacs_frame.frame;
+
+ expose_frame (f, event->xexpose.x, event->xexpose.y,
+ event->xexpose.width, event->xexpose.height);
+ flush_frame (f);
+}
+
void
widget_store_internal_border (Widget widget)
diff --git a/src/xterm.c b/src/xterm.c
index d442837bc6..e52f19a8e3 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -14680,6 +14680,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (!FRAME_GARBAGED_P (f))
{
+#ifdef USE_X_TOOLKIT
+ if (f->output_data.x->edit_widget)
+ /* The widget's expose proc will be run in this
+ case. */
+ goto OTHER;
+#endif
#ifdef USE_GTK
/* This seems to be needed for GTK 2.6 and later, see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15398. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0ce48e2882: Handle exposure in the widget's expose proc on X,
Po Lu <=