diff options
| author | Pip Cet | 2024-08-08 16:59:22 +0000 |
|---|---|---|
| committer | Pip Cet | 2024-08-08 16:59:22 +0000 |
| commit | 4cb2ff8ca077c575b457215ae09516e5c2e59aca (patch) | |
| tree | ee3e1125abf937e4e0cad8899857a6e30d8dbd05 /src/widget.c | |
| parent | 42731228d24c37edb2dc848c3a74d5c932a817ef (diff) | |
| download | emacs-4cb2ff8ca077c575b457215ae09516e5c2e59aca.tar.gz emacs-4cb2ff8ca077c575b457215ae09516e5c2e59aca.zip | |
Fix Lucid toolkit crashes in MPS builds
* src/xfns.c (x_window): Turn a pointer to struct frame into a pointer
to a pointer to struct frame, allocate with 'igc_xzalloc' if HAVE_MPS,
'xmalloc' otherwise.
* src/widget.c (resources):
(get_default_char_pixel_size):
(pixel_to_char_size):
(char_to_pixel_size):
(set_frame_size):
(update_various_frame_slots):
(update_from_various_frame_slots):
(EmacsFrameInitialize):
(EmacsFrameRealize):
(EmacsFrameDestroy):
(EmacsFrameResize):
(EmacsFrameSetCharSize):
(EmacsFrameExpose):
(widget_store_internal_border):
* src/widgetprv.h (EmacsFramePart): Adjust accordingly.
Diffstat (limited to 'src/widget.c')
| -rw-r--r-- | src/widget.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/widget.c b/src/widget.c index d22732ff93a..e6549e156ad 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -42,6 +42,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 42 | #include <X11/ShellP.h> | 42 | #include <X11/ShellP.h> |
| 43 | #include "../lwlib/lwlib.h" | 43 | #include "../lwlib/lwlib.h" |
| 44 | 44 | ||
| 45 | #ifdef HAVE_MPS | ||
| 46 | #include "igc.h" | ||
| 47 | #endif | ||
| 48 | |||
| 45 | static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *); | 49 | static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *); |
| 46 | static void EmacsFrameDestroy (Widget); | 50 | static void EmacsFrameDestroy (Widget); |
| 47 | static void EmacsFrameRealize (Widget, XtValueMask *, XSetWindowAttributes *); | 51 | static void EmacsFrameRealize (Widget, XtValueMask *, XSetWindowAttributes *); |
| @@ -61,7 +65,7 @@ static XtResource resources[] = { | |||
| 61 | 65 | ||
| 62 | {(char *) XtNemacsFrame, (char *) XtCEmacsFrame, | 66 | {(char *) XtNemacsFrame, (char *) XtCEmacsFrame, |
| 63 | XtRPointer, sizeof (XtPointer), | 67 | XtRPointer, sizeof (XtPointer), |
| 64 | offset (frame), XtRImmediate, 0}, | 68 | offset (framep), XtRImmediate, 0}, |
| 65 | 69 | ||
| 66 | {(char *) XtNminibuffer, (char *) XtCMinibuffer, XtRInt, sizeof (int), | 70 | {(char *) XtNminibuffer, (char *) XtCMinibuffer, XtRInt, sizeof (int), |
| 67 | offset (minibuffer), XtRImmediate, (XtPointer)0}, | 71 | offset (minibuffer), XtRImmediate, (XtPointer)0}, |
| @@ -157,7 +161,7 @@ emacsFrameClass (void) | |||
| 157 | static void | 161 | static void |
| 158 | get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int *pixel_height) | 162 | get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int *pixel_height) |
| 159 | { | 163 | { |
| 160 | struct frame *f = ew->emacs_frame.frame; | 164 | struct frame *f = *ew->emacs_frame.framep; |
| 161 | 165 | ||
| 162 | *pixel_width = FRAME_COLUMN_WIDTH (f); | 166 | *pixel_width = FRAME_COLUMN_WIDTH (f); |
| 163 | *pixel_height = FRAME_LINE_HEIGHT (f); | 167 | *pixel_height = FRAME_LINE_HEIGHT (f); |
| @@ -167,7 +171,7 @@ static void | |||
| 167 | pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, | 171 | pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, |
| 168 | Dimension pixel_height, int *char_width, int *char_height) | 172 | Dimension pixel_height, int *char_width, int *char_height) |
| 169 | { | 173 | { |
| 170 | struct frame *f = ew->emacs_frame.frame; | 174 | struct frame *f = *ew->emacs_frame.framep; |
| 171 | 175 | ||
| 172 | *char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width); | 176 | *char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width); |
| 173 | *char_height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (int) pixel_height); | 177 | *char_height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (int) pixel_height); |
| @@ -177,7 +181,7 @@ static void | |||
| 177 | char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, | 181 | char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, |
| 178 | Dimension *pixel_width, Dimension *pixel_height) | 182 | Dimension *pixel_width, Dimension *pixel_height) |
| 179 | { | 183 | { |
| 180 | struct frame *f = ew->emacs_frame.frame; | 184 | struct frame *f = *ew->emacs_frame.framep; |
| 181 | 185 | ||
| 182 | *pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width); | 186 | *pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width); |
| 183 | *pixel_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, char_height); | 187 | *pixel_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, char_height); |
| @@ -259,7 +263,7 @@ set_frame_size (EmacsFrame ew) | |||
| 259 | 263 | ||
| 260 | */ | 264 | */ |
| 261 | 265 | ||
| 262 | struct frame *f = ew->emacs_frame.frame; | 266 | struct frame *f = *ew->emacs_frame.framep; |
| 263 | 267 | ||
| 264 | ew->core.width = FRAME_PIXEL_WIDTH (f); | 268 | ew->core.width = FRAME_PIXEL_WIDTH (f); |
| 265 | ew->core.height = FRAME_PIXEL_HEIGHT (f); | 269 | ew->core.height = FRAME_PIXEL_HEIGHT (f); |
| @@ -326,7 +330,7 @@ widget_update_wm_size_hints (Widget widget, Widget frame) | |||
| 326 | static void | 330 | static void |
| 327 | update_various_frame_slots (EmacsFrame ew) | 331 | update_various_frame_slots (EmacsFrame ew) |
| 328 | { | 332 | { |
| 329 | struct frame *f = ew->emacs_frame.frame; | 333 | struct frame *f = *ew->emacs_frame.framep; |
| 330 | 334 | ||
| 331 | f->internal_border_width = ew->emacs_frame.internal_border_width; | 335 | f->internal_border_width = ew->emacs_frame.internal_border_width; |
| 332 | } | 336 | } |
| @@ -334,7 +338,7 @@ update_various_frame_slots (EmacsFrame ew) | |||
| 334 | static void | 338 | static void |
| 335 | update_from_various_frame_slots (EmacsFrame ew) | 339 | update_from_various_frame_slots (EmacsFrame ew) |
| 336 | { | 340 | { |
| 337 | struct frame *f = ew->emacs_frame.frame; | 341 | struct frame *f = *ew->emacs_frame.framep; |
| 338 | struct x_output *x = f->output_data.x; | 342 | struct x_output *x = f->output_data.x; |
| 339 | 343 | ||
| 340 | ew->core.height = FRAME_PIXEL_HEIGHT (f) - x->menubar_height; | 344 | ew->core.height = FRAME_PIXEL_HEIGHT (f) - x->menubar_height; |
| @@ -359,7 +363,7 @@ EmacsFrameInitialize (Widget request, Widget new, | |||
| 359 | { | 363 | { |
| 360 | EmacsFrame ew = (EmacsFrame) new; | 364 | EmacsFrame ew = (EmacsFrame) new; |
| 361 | 365 | ||
| 362 | if (!ew->emacs_frame.frame) | 366 | if (!*ew->emacs_frame.framep) |
| 363 | { | 367 | { |
| 364 | fputs ("can't create an emacs frame widget without a frame\n", stderr); | 368 | fputs ("can't create an emacs frame widget without a frame\n", stderr); |
| 365 | exit (1); | 369 | exit (1); |
| @@ -384,7 +388,7 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, | |||
| 384 | XSetWindowAttributes *attrs) | 388 | XSetWindowAttributes *attrs) |
| 385 | { | 389 | { |
| 386 | EmacsFrame ew = (EmacsFrame) widget; | 390 | EmacsFrame ew = (EmacsFrame) widget; |
| 387 | struct frame *f = ew->emacs_frame.frame; | 391 | struct frame *f = *ew->emacs_frame.framep; |
| 388 | 392 | ||
| 389 | /* This used to contain SubstructureRedirectMask, but this turns out | 393 | /* This used to contain SubstructureRedirectMask, but this turns out |
| 390 | to be a problem with XIM on Solaris, and events from that mask | 394 | to be a problem with XIM on Solaris, and events from that mask |
| @@ -410,14 +414,21 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, | |||
| 410 | static void | 414 | static void |
| 411 | EmacsFrameDestroy (Widget widget) | 415 | EmacsFrameDestroy (Widget widget) |
| 412 | { | 416 | { |
| 413 | /* All GCs are now freed in x_free_frame_resources. */ | 417 | EmacsFrame ew = (EmacsFrame) widget; |
| 418 | struct frame **fp = ew->emacs_frame.framep; | ||
| 419 | |||
| 420 | #ifdef HAVE_MPS | ||
| 421 | igc_xfree (fp); | ||
| 422 | #else | ||
| 423 | xfree (fp); | ||
| 424 | #endif | ||
| 414 | } | 425 | } |
| 415 | 426 | ||
| 416 | static void | 427 | static void |
| 417 | EmacsFrameResize (Widget widget) | 428 | EmacsFrameResize (Widget widget) |
| 418 | { | 429 | { |
| 419 | EmacsFrame ew = (EmacsFrame) widget; | 430 | EmacsFrame ew = (EmacsFrame) widget; |
| 420 | struct frame *f = ew->emacs_frame.frame; | 431 | struct frame *f = *ew->emacs_frame.framep; |
| 421 | 432 | ||
| 422 | if (CONSP (frame_size_history)) | 433 | if (CONSP (frame_size_history)) |
| 423 | frame_size_history_extra | 434 | frame_size_history_extra |
| @@ -470,7 +481,7 @@ void | |||
| 470 | EmacsFrameSetCharSize (Widget widget, int columns, int rows) | 481 | EmacsFrameSetCharSize (Widget widget, int columns, int rows) |
| 471 | { | 482 | { |
| 472 | EmacsFrame ew = (EmacsFrame) widget; | 483 | EmacsFrame ew = (EmacsFrame) widget; |
| 473 | struct frame *f = ew->emacs_frame.frame; | 484 | struct frame *f = *ew->emacs_frame.framep; |
| 474 | 485 | ||
| 475 | if (CONSP (frame_size_history)) | 486 | if (CONSP (frame_size_history)) |
| 476 | frame_size_history_extra | 487 | frame_size_history_extra |
| @@ -489,7 +500,7 @@ static void | |||
| 489 | EmacsFrameExpose (Widget widget, XEvent *event, Region region) | 500 | EmacsFrameExpose (Widget widget, XEvent *event, Region region) |
| 490 | { | 501 | { |
| 491 | EmacsFrame ew = (EmacsFrame) widget; | 502 | EmacsFrame ew = (EmacsFrame) widget; |
| 492 | struct frame *f = ew->emacs_frame.frame; | 503 | struct frame *f = *ew->emacs_frame.framep; |
| 493 | 504 | ||
| 494 | expose_frame (f, event->xexpose.x, event->xexpose.y, | 505 | expose_frame (f, event->xexpose.x, event->xexpose.y, |
| 495 | event->xexpose.width, event->xexpose.height); | 506 | event->xexpose.width, event->xexpose.height); |
| @@ -501,7 +512,7 @@ void | |||
| 501 | widget_store_internal_border (Widget widget) | 512 | widget_store_internal_border (Widget widget) |
| 502 | { | 513 | { |
| 503 | EmacsFrame ew = (EmacsFrame) widget; | 514 | EmacsFrame ew = (EmacsFrame) widget; |
| 504 | struct frame *f = ew->emacs_frame.frame; | 515 | struct frame *f = *ew->emacs_frame.framep; |
| 505 | 516 | ||
| 506 | ew->emacs_frame.internal_border_width = f->internal_border_width; | 517 | ew->emacs_frame.internal_border_width = f->internal_border_width; |
| 507 | } | 518 | } |