OSDN Git Service

3.6.6-0.1
[jnethack/htdocs.git] / patch / centerpopups.patch
1 diff -aur jnethack/include/config.h new/include/config.h
2 --- jnethack/include/config.h   Sat Jan  4 22:24:22 2003
3 +++ new/include/config.h        Fri Jan  3 03:02:52 2003
4 @@ -134,6 +134,7 @@
5  #  define GRAPHIC_TOMBSTONE    /* Use graphical tombstone (rip.xpm) */
6  #  define X11LARGETILE         /* Large tile for X11 */
7  # endif
8 +# define X11CENTERPOPUPS       /* Popup dialogs at the center of window */
9  #endif
10  
11  
12 diff -aur jnethack/include/winX.h new/include/winX.h
13 --- jnethack/include/winX.h     Sat Jan  4 23:23:03 2003
14 +++ new/include/winX.h  Fri Jan  3 02:13:30 2003
15 @@ -281,6 +281,9 @@
16      int     tombtext_dx;       /* x-displacement between tombstone line */
17      int     tombtext_dy;       /* y-displacement between tombstone line */
18  #endif
19 +#ifdef X11CENTERPOPUPS
20 +    Boolean center_popups;     /* to centre popups over the main window */
21 +#endif
22  } AppResources;
23  
24  E AppResources appResources;
25 diff -aur jnethack/win/X11/JNetHack.ad new/win/X11/JNetHack.ad
26 --- jnethack/win/X11/JNetHack.ad        Sat Jan  4 22:27:07 2003
27 +++ new/win/X11/JNetHack.ad     Fri Jan  3 01:55:18 2003
28 @@ -80,6 +80,11 @@
29  ! If your window manager does click-to-focus, you'll probably want this False.
30  !JNetHack*autofocus: True
31  !
32 +! If True, popup windows are centred over the main nethack window.  If False,
33 +! they're positioned under the mouse.  True is useful with a click-to-focus
34 +! style window manager where you leave the mouse to one side when not in use.
35 +!JNetHack*centerPopups: True
36 +!
37  ! Specify the number of rows and columns of the map window.  The default
38  ! is the standard 80x21 window.  Note: this _does_not_ change JNetHack's
39  ! level size, only what you see of it.
40 diff -aur jnethack/win/X11/dialogs.c new/win/X11/dialogs.c
41 --- jnethack/win/X11/dialogs.c  Sat Jan  4 23:32:10 2003
42 +++ new/win/X11/dialogs.c       Sat Jan  4 23:31:07 2003
43 @@ -72,6 +72,11 @@
44  #endif
45  #endif
46  
47 +#ifdef X11CENTERPOPUPS
48 +#include "hack.h"
49 +#include "winX.h"
50 +#endif
51 +
52  /* ":" added to both translations below to allow limited redefining of
53   * keysyms before testing for keysym values -- dlc */
54  static const char okay_accelerators[] =
55 @@ -344,8 +349,30 @@
56      /* following line deals with a race condition w/brain-damaged WM's -dlc */
57      XtUnrealizeWidget(w);
58  
59 +#ifndef X11CENTERPOPUPS
60      XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel), &root, &child,
61                   &x, &y, &dummyx, &dummyy, &dummymask);
62 +#else
63 +    if (appResources.center_popups) {
64 +       /* At startup the toplevel window can have a negative x or y,
65 +        * and if that happens they're interpreted as zero.
66 +        */
67 +       Dimension toplevel_width, toplevel_height;
68 +       Position  toplevel_x, toplevel_y;
69 +       XtVaGetValues (toplevel,
70 +                      XtNwidth, &toplevel_width, XtNheight, &toplevel_height,
71 +                      NULL);
72 +       XtTranslateCoords(toplevel, 0, 0, &toplevel_x, &toplevel_y);
73 +       if (toplevel_x < 0)  toplevel_x = 0;
74 +       if (toplevel_y < 0)  toplevel_y = 0;
75 +       x = toplevel_x + toplevel_width / 2;
76 +       y = toplevel_y + toplevel_height / 2;
77 +
78 +    } else {
79 +       XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel), &root, &child,
80 +                     &x, &y, &dummyx, &dummyy, &dummymask);
81 +    }
82 +#endif
83      num_args = 0;
84      XtSetArg(args[num_args], XtNwidth, &width); num_args++;
85      XtSetArg(args[num_args], XtNheight, &height); num_args++;
86 diff -aur jnethack/win/X11/winX.c new/win/X11/winX.c
87 --- jnethack/win/X11/winX.c     Sat Jan  4 22:25:17 2003
88 +++ new/win/X11/winX.c  Fri Jan  3 02:13:28 2003
89 @@ -1004,6 +1004,10 @@
90      { "tombtext_dy", "Tombtext_dy", XtRInt, sizeof(int),
91        XtOffset(AppResources *,tombtext_dy), XtRString, "13" },
92  #endif
93 +#ifdef X11CENTERPOPUPS
94 +    { "centerPopups", "CenterPopups", XtRBoolean, sizeof(Boolean),
95 +      XtOffset(AppResources *,center_popups), XtRImmediate, False },
96 +#endif
97  };
98  
99  void