| 1 |
/*========================================================================*\ |
| 2 |
|
| 3 |
Copyright (c) 1990-2014 Paul Vojta and others |
| 4 |
|
| 5 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
of this software and associated documentation files (the "Software"), to |
| 7 |
deal in the Software without restriction, including without limitation the |
| 8 |
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 9 |
sell copies of the Software, and to permit persons to whom the Software is |
| 10 |
furnished to do so, subject to the following conditions: |
| 11 |
|
| 12 |
The above copyright notice and this permission notice shall be included in |
| 13 |
all copies or substantial portions of the Software. |
| 14 |
|
| 15 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL PAUL |
| 18 |
VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 |
THE SOFTWARE. |
| 22 |
|
| 23 |
NOTE: xdvi is based on prior work as noted in the modification history, below. |
| 24 |
|
| 25 |
\*========================================================================*/ |
| 26 |
|
| 27 |
/* |
| 28 |
* DVI previewer for X. |
| 29 |
* |
| 30 |
* Eric Cooper, CMU, September 1985. |
| 31 |
* |
| 32 |
* Code derived from dvi-imagen.c. |
| 33 |
* |
| 34 |
* Modification history: |
| 35 |
* 1/1986 Modified for X.10 --Bob Scheifler, MIT LCS. |
| 36 |
* 7/1988 Modified for X.11 --Mark Eichin, MIT |
| 37 |
* 12/1988 Added 'R' option, toolkit, magnifying glass |
| 38 |
* --Paul Vojta, UC Berkeley. |
| 39 |
* 2/1989 Added tpic support --Jeffrey Lee, U of Toronto |
| 40 |
* 4/1989 Modified for System V --Donald Richardson, Clarkson Univ. |
| 41 |
* 3/1990 Added VMS support --Scott Allendorf, U of Iowa |
| 42 |
* 7/1990 Added reflection mode --Michael Pak, Hebrew U of Jerusalem |
| 43 |
* 1/1992 Added greyscale code --Till Brychcy, Techn. Univ. Muenchen |
| 44 |
* and Lee Hetherington, MIT |
| 45 |
* 7/1992 Added extra menu buttons--Nelson H. F. Beebe <[email protected]> |
| 46 |
* 4/1994 Added DPS support, bounding box |
| 47 |
* --Ricardo Telichevesky |
| 48 |
* and Luis Miguel Silveira, MIT RLE. |
| 49 |
* 2/1995 Added rulers support --Nelson H. F. Beebe <[email protected]> |
| 50 |
* 1/2001 Added source specials --including ideas from Stefan Ulrich, |
| 51 |
* U Munich |
| 52 |
* |
| 53 |
* Compilation options: |
| 54 |
* |
| 55 |
* VMS compile for VMS |
| 56 |
* WORDS_BIGENDIAN store bitmaps internally with most significant bit first |
| 57 |
* BMTYPE store bitmaps in unsigned BMTYPE |
| 58 |
* BMBYTES sizeof(unsigned BMTYPE) |
| 59 |
* ALTFONT default for -altfont option |
| 60 |
* SHRINK default for -s option (shrink factor) |
| 61 |
* MFMODE default for -mfmode option |
| 62 |
* A4 use European size paper, and change default dimension to cm |
| 63 |
* TEXXET support reflection dvi codes (right-to-left typesetting) |
| 64 |
* GREY use grey levels to shrink fonts |
| 65 |
* PS_GS use Ghostscript to render pictures/bounding boxes |
| 66 |
* PS_DPS use display postscript to render pictures/bounding boxes |
| 67 |
* PS_NEWS use the NeWS server to render pictures/bounding boxes |
| 68 |
* GS_PATH path to call the Ghostscript interpreter by |
| 69 |
* MAGICK use ImageMagick to render (external) image files |
| 70 |
*/ |
| 71 |
|
| 72 |
|
| 73 |
#include "xdvi-config.h" |
| 74 |
#include "xdvi.h" |
| 75 |
#include "version.h" |
| 76 |
|
| 77 |
/* Xlib and Xutil are already included */ |
| 78 |
#include <X11/cursorfont.h> |
| 79 |
#include <X11/keysym.h> |
| 80 |
#include <X11/Xatom.h> |
| 81 |
#include <X11/StringDefs.h> |
| 82 |
#include <X11/Shell.h> /* needed for def. of XtNiconX */ |
| 83 |
|
| 84 |
#ifdef HAVE_X11_XMU_EDITRES_H |
| 85 |
# include <X11/Xmu/Editres.h> |
| 86 |
#endif |
| 87 |
|
| 88 |
/* to allow one common dependency file for Xaw/Motif, |
| 89 |
we always include all the headers and have |
| 90 |
#ifdef MOTIF |
| 91 |
tests inside the headers. |
| 92 |
*/ |
| 93 |
#if defined(NEW_MENU_CREATION) || defined(MOTIF) |
| 94 |
#include "menu.h" |
| 95 |
#else |
| 96 |
#include "xm_menu.h" |
| 97 |
#include "xaw_menu.h" |
| 98 |
#endif /* NEW_MENU_CREATION */ |
| 99 |
#include "xm_toolbar.h" |
| 100 |
|
| 101 |
#ifdef MOTIF |
| 102 |
|
| 103 |
# include <Xm/Xm.h> |
| 104 |
# include <Xm/Frame.h> |
| 105 |
# include <Xm/PushB.h> |
| 106 |
# include <Xm/MainW.h> |
| 107 |
# include <Xm/ToggleB.h> |
| 108 |
# include <Xm/RowColumn.h> |
| 109 |
# include <Xm/ScrolledW.h> |
| 110 |
# include <Xm/MenuShell.h> |
| 111 |
# include <Xm/DrawingA.h> |
| 112 |
# include <Xm/Form.h> |
| 113 |
# include <Xm/PanedW.h> |
| 114 |
# include <Xm/List.h> |
| 115 |
# include <Xm/Protocols.h> |
| 116 |
|
| 117 |
# include <Xm/Display.h> |
| 118 |
|
| 119 |
# ifdef MOTIF11 /* FIXME: We'll probably need a config check for this? */ |
| 120 |
/* used to set up XmStrings */ |
| 121 |
XmStringCharSet G_charset = (XmStringCharSet)XmSTRING_DEFAULT_CHARSET; |
| 122 |
# else |
| 123 |
XmStringCharSet G_charset = XmFONTLIST_DEFAULT_TAG; |
| 124 |
# endif |
| 125 |
|
| 126 |
#else /* MOTIF */ |
| 127 |
|
| 128 |
# include <X11/Xaw/Viewport.h> |
| 129 |
# include <X11/Xaw/AsciiText.h> |
| 130 |
# include <X11/Xaw/Box.h> |
| 131 |
# include <X11/Xaw/Command.h> |
| 132 |
# include <X11/Xaw/Dialog.h> |
| 133 |
# include <X11/Xaw/Form.h> |
| 134 |
# include <X11/Xaw/Paned.h> |
| 135 |
# include <X11/Xaw/Scrollbar.h> |
| 136 |
# include <X11/Xaw/Command.h> |
| 137 |
|
| 138 |
#endif /* MOTIF */ |
| 139 |
|
| 140 |
#include <signal.h> |
| 141 |
#include <stdlib.h> |
| 142 |
#include <ctype.h> |
| 143 |
|
| 144 |
#include "xserver-info.h" |
| 145 |
|
| 146 |
#include "kpathsea/c-fopen.h" |
| 147 |
#include "kpathsea/c-pathch.h" |
| 148 |
#include "kpathsea/c-stat.h" |
| 149 |
#include "kpathsea/progname.h" |
| 150 |
#include "kpathsea/tex-file.h" |
| 151 |
#include "kpathsea/tex-hush.h" |
| 152 |
#include "kpathsea/tex-make.h" |
| 153 |
#include "string-utils.h" |
| 154 |
#include "kpathsea/c-errno.h" |
| 155 |
|
| 156 |
#include "translations.h" |
| 157 |
#include "c-openmx.h" |
| 158 |
#include "xicon.h" |
| 159 |
#include "x_util.h" |
| 160 |
#include "message-window.h" |
| 161 |
#include "events.h" |
| 162 |
#include "mag.h" |
| 163 |
#include "pagesel.h" |
| 164 |
#include "dvi-draw.h" |
| 165 |
#include "statusline.h" |
| 166 |
#include "util.h" |
| 167 |
#include "hypertex.h" |
| 168 |
#include "xaw_menu.h" |
| 169 |
#include "xdvi-debug.h" |
| 170 |
#include "pagehist.h" |
| 171 |
#include "filehist.h" |
| 172 |
#include "print-internal.h" |
| 173 |
#include "exit-handlers.h" |
| 174 |
#include "xm_prefsP.h" /* for Xdvi_PREFS_BROWSER_DEFAULTS and Xdvi_PREFS_EDITOR_DEFAULTS */ |
| 175 |
|
| 176 |
#if FREETYPE |
| 177 |
# include "font-open.h" /* for init_t1_lookup() */ |
| 178 |
#endif |
| 179 |
|
| 180 |
#ifdef VMS |
| 181 |
# include "pixmaps/hand.xbm" |
| 182 |
# include "pixmaps/hand_mask.xbm" |
| 183 |
#endif |
| 184 |
#include "pixmaps/magglass.xbm" |
| 185 |
#include "pixmaps/magglass_mask.xbm" |
| 186 |
|
| 187 |
#ifdef DEBUG |
| 188 |
#include<asm/msr.h> |
| 189 |
unsigned long time_start=0, time_end=0; |
| 190 |
#endif |
| 191 |
|
| 192 |
|
| 193 |
#ifdef MOTIF |
| 194 |
#include <Xm/MwmUtil.h> |
| 195 |
|
| 196 |
#else /* MOTIF */ |
| 197 |
|
| 198 |
/* need to fake it */ |
| 199 |
|
| 200 |
/* bit definitions for MwmHints.flags */ |
| 201 |
#define MWM_HINTS_FUNCTIONS (1L << 0) |
| 202 |
#define MWM_HINTS_DECORATIONS (1L << 1) |
| 203 |
#define MWM_HINTS_INPUT_MODE (1L << 2) |
| 204 |
#define MWM_HINTS_STATUS (1L << 3) |
| 205 |
|
| 206 |
/* bit definitions for MwmHints.decorations */ |
| 207 |
#define MWM_DECOR_ALL (1L << 0) |
| 208 |
#define MWM_DECOR_BORDER (1L << 1) |
| 209 |
#define MWM_DECOR_RESIZEH (1L << 2) |
| 210 |
#define MWM_DECOR_TITLE (1L << 3) |
| 211 |
#define MWM_DECOR_MENU (1L << 4) |
| 212 |
#define MWM_DECOR_MINIMIZE (1L << 5) |
| 213 |
#define MWM_DECOR_MAXIMIZE (1L << 6) |
| 214 |
|
| 215 |
struct PropMotifWmHints { |
| 216 |
unsigned long flags; |
| 217 |
unsigned long functions; |
| 218 |
unsigned long decorations; |
| 219 |
long inputMode; |
| 220 |
unsigned long status; |
| 221 |
}; |
| 222 |
|
| 223 |
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 |
| 224 |
|
| 225 |
#endif /* MOTIF */ |
| 226 |
|
| 227 |
#if HAVE_X11_INTRINSICI_H |
| 228 |
# include <X11/IntrinsicI.h> |
| 229 |
#else |
| 230 |
|
| 231 |
/* Taken from <X11/TranslateI.h> in libXt-1.1.3 (June 2012) */ |
| 232 |
typedef struct _LateBindings { |
| 233 |
unsigned int knot:1; |
| 234 |
unsigned int pair:1; |
| 235 |
unsigned short ref_count; /* garbage collection */ |
| 236 |
KeySym keysym; |
| 237 |
} LateBindings, *LateBindingsPtr; |
| 238 |
|
| 239 |
#endif /* not HAVE_X11_INTRINSICI_H */ |
| 240 |
|
| 241 |
struct mouse_acts *mouse_actions; |
| 242 |
|
| 243 |
char *dvi_property; /* for setting in window */ |
| 244 |
size_t dvi_property_length; /* length of above, for efficiency */ |
| 245 |
XImage *G_image; |
| 246 |
int G_backing_store; |
| 247 |
Display *DISP; |
| 248 |
Screen *SCRN; |
| 249 |
XtAccelerators G_accels_cr; |
| 250 |
|
| 251 |
#ifdef GREY |
| 252 |
Visual *G_visual; |
| 253 |
unsigned int G_depth; |
| 254 |
Colormap G_colormap; |
| 255 |
#else |
| 256 |
# define G_depth (unsigned int) DefaultDepthOfScreen(SCRN) |
| 257 |
# define G_visual DefaultVisualOfScreen(SCRN) |
| 258 |
# define G_colormap DefaultColormapOfScreen(SCRN) |
| 259 |
#endif |
| 260 |
|
| 261 |
/* global widgets */ |
| 262 |
|
| 263 |
#if defined(MOTIF) |
| 264 |
Widget page_list; |
| 265 |
#if USE_XAW_PANNER |
| 266 |
#include "Panner.h" |
| 267 |
Widget panner; |
| 268 |
static Dimension g_save_shadow_thickness; |
| 269 |
#endif |
| 270 |
#endif |
| 271 |
|
| 272 |
static Atom mainDeleteWindow; |
| 273 |
|
| 274 |
#ifndef MOTIF |
| 275 |
static Atom wmProtocols; |
| 276 |
static void |
| 277 |
handle_delete_message(Widget widget, XtPointer closure, XEvent *event, Boolean *cont) |
| 278 |
{ |
| 279 |
UNUSED(cont); |
| 280 |
UNUSED(widget); |
| 281 |
|
| 282 |
ASSERT(closure == NULL, "handle_delete_message doesn't accept a non-NULL closure argument"); |
| 283 |
if (event->type == ClientMessage |
| 284 |
&& event->xclient.message_type == wmProtocols |
| 285 |
&& (unsigned)(event->xclient.data.l[0]) == mainDeleteWindow) { |
| 286 |
/* non-k xdvi also evaluates closure, but we don't, since it's a function pointer |
| 287 |
which isn't convertible to void * in ANSI C */ |
| 288 |
xdvi_exit(EXIT_SUCCESS); |
| 289 |
} |
| 290 |
} |
| 291 |
#endif |
| 292 |
|
| 293 |
#ifdef TEST_SCROLLING |
| 294 |
#warning ========== compiling with TEST_SCROLLING ========== |
| 295 |
#endif |
| 296 |
|
| 297 |
|
| 298 |
/* for measuring distance from the ruler */ |
| 299 |
int g_ruler_pos_x, g_ruler_pos_y; |
| 300 |
|
| 301 |
Boolean ignore_papersize_specials = False; |
| 302 |
|
| 303 |
#ifndef ALTFONT |
| 304 |
# define ALTFONT "cmr10" |
| 305 |
#endif |
| 306 |
|
| 307 |
#ifndef SHRINK |
| 308 |
# define SHRINK 8 |
| 309 |
#endif |
| 310 |
|
| 311 |
#ifndef MFMODE |
| 312 |
# define MFMODE NULL |
| 313 |
#endif |
| 314 |
|
| 315 |
#undef MKTEXPK |
| 316 |
#define MKTEXPK MAKEPK |
| 317 |
|
| 318 |
#if defined(PS_GS) && !defined(GS_PATH) |
| 319 |
# define GS_PATH "gs" |
| 320 |
#endif |
| 321 |
|
| 322 |
static Dimension bwidth = 2; |
| 323 |
|
| 324 |
struct x_resources resource; |
| 325 |
|
| 326 |
struct program_globals globals; |
| 327 |
|
| 328 |
/* color of cursor */ |
| 329 |
static XColor m_cursor_color; |
| 330 |
|
| 331 |
|
| 332 |
struct WindowRec mane = { (Window) 0, 1, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0 }; |
| 333 |
|
| 334 |
/* currwin is temporary storage except for within redraw() */ |
| 335 |
struct WindowRec currwin = { (Window) 0, 1, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0 }; |
| 336 |
|
| 337 |
#define offset(field) XtOffsetOf(struct x_resources, field) |
| 338 |
static int base_tick_length = 4; |
| 339 |
|
| 340 |
static char XtRBool3[] = "Bool3"; /* resource for Bool3 */ |
| 341 |
|
| 342 |
static XtResource application_resources[] = { |
| 343 |
{"regression", "Regression", XtRBoolean, sizeof(Boolean), |
| 344 |
offset(regression), XtRString, "false"}, |
| 345 |
{"geometry", "Geometry", XtRString, sizeof(char *), |
| 346 |
offset(geometry), XtRString, (XtPointer) NULL}, |
| 347 |
{"windowSize", "WindowSize", XtRString, sizeof(char *), |
| 348 |
offset(windowsize), XtRString, (XtPointer) NULL}, |
| 349 |
{"rememberWindowSize", "RememberWindowSize", XtRBoolean, sizeof(Boolean), |
| 350 |
offset(remember_windowsize), XtRString, "false"}, |
| 351 |
/* used to check whether app-defaults file is out of sync. Initialize |
| 352 |
to a low default value (one before the resource was introduced) */ |
| 353 |
{"appDefaultsFileVersion", "AppDefaultsFileVersion", XtRInt, sizeof(int), |
| 354 |
offset(app_defaults_fileversion), XtRImmediate, (XtPointer)20030302 }, |
| 355 |
{"shrinkFactor", "ShrinkFactor", XtRInt, sizeof(int), |
| 356 |
offset(shrinkfactor), XtRImmediate, (XtPointer) SHRINK}, |
| 357 |
{"delayRulers", "DelayRulers", XtRBoolean, sizeof(Boolean), |
| 358 |
offset(delay_rulers), XtRString, "true"}, |
| 359 |
{"useTeXPages", "UseTeXPages", XtRBoolean, sizeof(Boolean), |
| 360 |
offset(use_tex_pages), XtRString, "false"}, |
| 361 |
{"densityPercent", "DensityPercent", XtRInt, sizeof(int), |
| 362 |
offset(density), XtRString, "40"}, |
| 363 |
{"omega", "Omega", XtRBoolean, sizeof(Boolean), |
| 364 |
offset(omega), XtRString, "true"}, |
| 365 |
{"mainTranslations", "MainTranslations", XtRString, sizeof(char *), |
| 366 |
offset(main_translations), XtRString, (XtPointer) NULL}, |
| 367 |
{"mouseTranslations", "MouseTranslations", XtRString, sizeof(char *), |
| 368 |
offset(mouse_translations), XtRString, (XtPointer) NULL }, |
| 369 |
{"wheelUnit", "WheelUnit", XtRInt, sizeof(int), |
| 370 |
offset(wheel_unit), XtRImmediate, (XtPointer) 80}, |
| 371 |
{"mouseMode", "MouseMode", XtRInt, sizeof(int), |
| 372 |
offset(mouse_mode), XtRImmediate, (XtPointer) MOUSE_MODE1 }, |
| 373 |
{"mouseMode1Name", "MouseMode1Name", XtRString, sizeof(char *), |
| 374 |
offset(mouse_mode1_name), XtRString, (XtPointer) "Magnifier"}, |
| 375 |
{"mouseMode1Description", "MouseMode1Description", XtRString, sizeof(char *), |
| 376 |
offset(mouse_mode1_description), XtRString, (XtPointer) "click to enlarge text"}, |
| 377 |
{"mouseMode1Cursor", "MouseMode1Cursor", XtRInt, sizeof(int), |
| 378 |
offset(mouse_mode1_cursor), XtRImmediate, (XtPointer) -1}, |
| 379 |
{"mouseMode2Name", "MouseMode2Name", XtRString, sizeof(char *), |
| 380 |
offset(mouse_mode2_name), XtRString, (XtPointer) "Text Selection"}, |
| 381 |
{"mouseMode2Description", "MouseMode2Description", XtRString, sizeof(char *), |
| 382 |
offset(mouse_mode2_description), XtRString, (XtPointer) "click and drag to select a region of text"}, |
| 383 |
{"mouseMode2Cursor", "MouseMode2Cursor", XtRInt, sizeof(int), |
| 384 |
offset(mouse_mode2_cursor), XtRImmediate, (XtPointer) XC_cross }, |
| 385 |
{"mouseMode3Name", "MouseMode3Name", XtRString, sizeof(char *), |
| 386 |
offset(mouse_mode3_name), XtRString, (XtPointer) "Ruler"}, |
| 387 |
{"mouseMode3Description", "MouseMode3Description", XtRString, sizeof(char *), |
| 388 |
offset(mouse_mode3_description), XtRString, (XtPointer) "click and drag to set/move ruler"}, |
| 389 |
{"mouseMode3Cursor", "MouseMode3Cursor", XtRInt, sizeof(int), |
| 390 |
offset(mouse_mode3_cursor), XtRImmediate, (XtPointer) XC_crosshair }, |
| 391 |
#ifdef GREY |
| 392 |
{"gamma", "Gamma", XtRFloat, sizeof(float), |
| 393 |
offset(gamma), XtRString, "1"}, |
| 394 |
/* {"invertedFactor", "InvertedFactor", XtRFloat, sizeof(float), */ |
| 395 |
/* offset(inverted_factor), XtRString, "3.0"}, */ |
| 396 |
#endif |
| 397 |
{"pixelsPerInch", "PixelsPerInch", XtRInt, sizeof(int), |
| 398 |
offset(pixels_per_inch), XtRImmediate, (XtPointer) BDPI}, |
| 399 |
{"sideMargin", "Margin", XtRString, sizeof(char *), |
| 400 |
offset(sidemargin), XtRString, (XtPointer) NULL}, |
| 401 |
{"tickLength", "TickLength", XtRInt, sizeof(int), |
| 402 |
offset(tick_length), XtRInt, (XtPointer) &base_tick_length}, |
| 403 |
{"tickUnits", "TickUnits", XtRString, sizeof(char *), |
| 404 |
offset(tick_units), XtRString, "mm"}, |
| 405 |
{"topMargin", "Margin", XtRString, sizeof(char *), |
| 406 |
offset(topmargin), XtRString, (XtPointer) NULL}, |
| 407 |
{"xOffset", "Offset", XtRString, sizeof(char *), |
| 408 |
offset(xoffset), XtRString, (XtPointer) NULL}, |
| 409 |
{"yOffset", "Offset", XtRString, sizeof(char *), |
| 410 |
offset(yoffset), XtRString, (XtPointer) NULL}, |
| 411 |
{"useCurrentOffset", "UseCurrentOffset", XtRBoolean, sizeof(Boolean), |
| 412 |
offset(use_current_offset), XtRString, "False" }, |
| 413 |
{"paper", "Paper", XtRString, sizeof(char *), |
| 414 |
offset(paper), XtRString, (XtPointer) DEFAULT_PAPER}, |
| 415 |
{"paperLandscape", "PaperLandscape", XtRBoolean, sizeof(Boolean), |
| 416 |
offset(paper_landscape), XtRString, "false"}, |
| 417 |
{"altFont", "AltFont", XtRString, sizeof(char *), |
| 418 |
offset(alt_font), XtRString, (XtPointer) ALTFONT}, |
| 419 |
{"makePk", "MakePk", XtRBoolean, sizeof(Boolean), |
| 420 |
offset(makepk), XtRString, |
| 421 |
#ifdef MAKE_TEX_PK_BY_DEFAULT |
| 422 |
"true" |
| 423 |
#else |
| 424 |
"false" |
| 425 |
#endif |
| 426 |
}, |
| 427 |
{"mfMode", "MfMode", XtRString, sizeof(char *), |
| 428 |
offset(mfmode), XtRString, MFMODE}, |
| 429 |
{"editor", "Editor", XtRString, sizeof(char *), |
| 430 |
offset(editor), XtRString, (XtPointer) NULL}, |
| 431 |
#if FREETYPE |
| 432 |
{"type1", "Type1", XtRBoolean, sizeof(Boolean), |
| 433 |
offset(freetype), XtRString, "true"}, |
| 434 |
#endif |
| 435 |
#if HAVE_XI21 |
| 436 |
{"xi2Scrolling", "Xi2Scrolling", XtRBoolean, sizeof(Boolean), |
| 437 |
offset(xi2scrolling), XtRString, "true"}, |
| 438 |
#endif |
| 439 |
{"sourcePosition", "SourcePosition", XtRString, sizeof(char *), |
| 440 |
offset(src_pos), XtRString, (XtPointer) NULL}, |
| 441 |
{"findString", "FindString", XtRString, sizeof(char *), |
| 442 |
offset(find_string), XtRString, (XtPointer) NULL}, |
| 443 |
{"textEncoding", "TextEncoding", XtRString, sizeof(char *), |
| 444 |
offset(text_encoding), XtRString, (XtPointer) NULL}, |
| 445 |
{"fork", "Fork", XtRBoolean, sizeof(Boolean), |
| 446 |
offset(src_fork), XtRString, "true"}, |
| 447 |
#ifdef RGB_ANTI_ALIASING |
| 448 |
{"subPixels", "SubPixels", XtRString, sizeof(char *), |
| 449 |
offset(sub_pixels), XtRString, "Unknown"}, |
| 450 |
#endif |
| 451 |
{"noFileArgUseHistory", "NoFileArgUseHistory", XtRBoolean, sizeof(Boolean), |
| 452 |
offset(no_file_arg_use_history), XtRString, "true"}, |
| 453 |
{"fileHistory", "FileHistory", XtRString, sizeof(char *), |
| 454 |
offset(file_history), XtRString, (XtPointer) NULL}, |
| 455 |
{"fileHistorySize", "FileHistorySize", XtRInt, sizeof(int), |
| 456 |
offset(file_history_size), XtRImmediate, (XtPointer)20}, |
| 457 |
{"unique", "Unique", XtRBoolean, sizeof(Boolean), |
| 458 |
offset(unique), XtRString, "false"}, |
| 459 |
{"listFonts", "ListFonts", XtRBoolean, sizeof(Boolean), |
| 460 |
offset(list_fonts), XtRString, "false"}, |
| 461 |
{"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean), |
| 462 |
offset(reverse), XtRString, "false"}, |
| 463 |
{"warnSpecials", "WarnSpecials", XtRBoolean, sizeof(Boolean), |
| 464 |
offset(warn_spec), XtRString, "false"}, |
| 465 |
{"hush", "Hush", XtRBoolean, sizeof(Boolean), |
| 466 |
offset(hush), XtRString, "false"}, |
| 467 |
{"hushLostChars", "HushLostChars", XtRBoolean, sizeof(Boolean), |
| 468 |
offset(hush_chars), XtRString, "false"}, |
| 469 |
{"hushChecksums", "HushChecksums", XtRBoolean, sizeof(Boolean), |
| 470 |
offset(hush_chk), XtRString, "false"}, |
| 471 |
{"hushStdout", "HushStdout", XtRBoolean, sizeof(Boolean), |
| 472 |
offset(hush_stdout), XtRString, "false"}, |
| 473 |
{"hushBell", "HushBell", XtRBoolean, sizeof(Boolean), |
| 474 |
offset(hush_bell), XtRString, "false"}, |
| 475 |
{"safer", "Safer", XtRBoolean, sizeof(Boolean), |
| 476 |
offset(safer), XtRString, "false"}, |
| 477 |
#ifdef VMS |
| 478 |
{"foreground", "Foreground", XtRString, sizeof(char *), |
| 479 |
offset(fore_color), XtRString, (XtPointer) NULL}, |
| 480 |
{"background", "Background", XtRString, sizeof(char *), |
| 481 |
offset(back_color), XtRString, (XtPointer) NULL}, |
| 482 |
#endif |
| 483 |
{"iconGeometry", "IconGeometry", XtRString, sizeof(char *), |
| 484 |
offset(icon_geometry), XtRString, (XtPointer) NULL}, |
| 485 |
{"keepPosition", "KeepPosition", XtRBoolean, sizeof(Boolean), |
| 486 |
offset(keep_flag), XtRString, "false"}, |
| 487 |
#ifdef PS |
| 488 |
{"postscript", "Postscript", XtRInt, sizeof(int), |
| 489 |
offset(postscript), XtRImmediate, (XtPointer)1}, |
| 490 |
{"allowShell", "AllowShell", XtRBoolean, sizeof(Boolean), |
| 491 |
offset(allow_shell), XtRString, "false"}, |
| 492 |
# ifdef PS_DPS |
| 493 |
{"dps", "DPS", XtRBoolean, sizeof(Boolean), |
| 494 |
offset(useDPS), XtRString, "true"}, |
| 495 |
# endif |
| 496 |
# ifdef PS_NEWS |
| 497 |
{"news", "News", XtRBoolean, sizeof(Boolean), |
| 498 |
offset(useNeWS), XtRString, "true"}, |
| 499 |
# endif |
| 500 |
# ifdef PS_GS |
| 501 |
{"ghostscript", "Ghostscript", XtRBoolean, sizeof(Boolean), |
| 502 |
offset(useGS), XtRString, "true"}, |
| 503 |
{"gsSafer", "Safer", XtRBoolean, sizeof(Boolean), |
| 504 |
offset(gs_safer), XtRString, "true"}, |
| 505 |
{"gsAlpha", "Alpha", XtRBoolean, sizeof(Boolean), |
| 506 |
offset(gs_alpha), XtRString, "false"}, |
| 507 |
{"interpreter", "Interpreter", XtRString, sizeof(char *), |
| 508 |
offset(gs_path), XtRString, (XtPointer) GS_PATH}, |
| 509 |
{"palette", "Palette", XtRString, sizeof(char *), |
| 510 |
offset(gs_palette), XtRString, (XtPointer) "Color"}, |
| 511 |
{"gsTimeout", "GSTimeout", XtRInt, sizeof(int), |
| 512 |
offset(gs_timeout), XtRImmediate, (XtPointer)3000}, |
| 513 |
# endif /* PS_GS */ |
| 514 |
# ifdef MAGICK |
| 515 |
{"magick", "ImageMagick", XtRBoolean, sizeof(Boolean), |
| 516 |
offset(useMAGICK), XtRString, "true"}, |
| 517 |
{"magick_cache", "MagickCache", XtRString, sizeof(char *), |
| 518 |
offset(magick_cache), XtRString, (XtPointer) NULL}, |
| 519 |
# endif |
| 520 |
#endif /* PS */ |
| 521 |
{"prescan", "Prescan", XtRBoolean, sizeof(Boolean), |
| 522 |
offset(prescan), XtRString, "true"}, |
| 523 |
{"tempFile", "TempFile", XtRBoolean, sizeof(Boolean), |
| 524 |
offset(use_temp_fp), XtRString, "true"}, |
| 525 |
{"copy", "Copy", XtRBoolean, sizeof(Boolean), |
| 526 |
offset(copy), XtRString, "false"}, |
| 527 |
{"thorough", "Thorough", XtRBoolean, sizeof(Boolean), |
| 528 |
offset(thorough), XtRString, "false"}, |
| 529 |
{"fullscreen", "Fullscreen", XtRBoolean, sizeof(Boolean), |
| 530 |
offset(fullscreen), XtRString, "false"}, |
| 531 |
{"pause", "Pause", XtRBoolean, sizeof(Boolean), |
| 532 |
offset(pause), XtRString, "false"}, |
| 533 |
{"pauseSpecial", "PauseSpecial", XtRString, sizeof(char *), |
| 534 |
offset(pause_special), XtRString, (XtPointer)"xdvi:pause"}, |
| 535 |
{"debugLevel", "DebugLevel", XtRString, sizeof(char *), |
| 536 |
offset(debug_arg), XtRString, (XtPointer) NULL}, |
| 537 |
{"menuTranslations", "MenuTranslations", XtRString, sizeof(char *), |
| 538 |
offset(menu_translations), XtRString, (XtPointer) default_menu_config}, |
| 539 |
{"watchFile", "WatchFile", XtRFloat, sizeof(float), |
| 540 |
offset(watch_file), XtRString, "0"}, |
| 541 |
{"expert", "Expert", XtRBoolean, sizeof(Boolean), |
| 542 |
offset(expert), XtRString, (XtPointer) NULL}, |
| 543 |
{"expertMode", "ExpertMode", XtRInt, sizeof(int), |
| 544 |
offset(expert_mode), XtRImmediate, (XtPointer)31 /* everything on */ }, |
| 545 |
#ifndef MOTIF |
| 546 |
{"buttonSideSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), |
| 547 |
offset(btn_side_spacing), XtRImmediate, (XtPointer) 8}, |
| 548 |
{"buttonTopSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), |
| 549 |
offset(btn_top_spacing), XtRImmediate, (XtPointer) 16}, |
| 550 |
{"buttonBetweenSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), |
| 551 |
offset(btn_between_spacing), XtRImmediate, (XtPointer) 8}, |
| 552 |
/* only used if menus consist of buttons only */ |
| 553 |
{"buttonBetweenExtra", "ButtonSpacing", XtRDimension, sizeof(Dimension), |
| 554 |
offset(btn_between_extra), XtRImmediate, (XtPointer)16}, |
| 555 |
{"buttonBorderWidth", "BorderWidth", XtRDimension, sizeof(Dimension), |
| 556 |
offset(btn_border_width), XtRImmediate, (XtPointer) 1}, |
| 557 |
#endif /* MOTIF */ |
| 558 |
{"statusline", "Statusline", XtRBoolean, sizeof(Boolean), |
| 559 |
offset(statusline), XtRString, (XtPointer) NULL}, |
| 560 |
#ifdef MOTIF |
| 561 |
{"toolbarTranslations", "ToolbarTranslations", XtRString, sizeof(char *), |
| 562 |
offset(toolbar_translations), XtRString, (XtPointer) default_toolbar_translations}, |
| 563 |
{"toolbarPixmapFile", "ToolbarPixmapFile", XtRString, sizeof(char *), |
| 564 |
offset(toolbar_pixmap_file), XtRString, (XtPointer) "toolbar.xpm"}, |
| 565 |
{"toolbarButtonsRaised", "ToolbarButtonsRaised", XtRBoolean, sizeof(Boolean), |
| 566 |
offset(toolbar_buttons_raised), XtRString, "True"}, |
| 567 |
{"tooltipsInStatusline", "TooltipsInStatusline", XtRBoolean, sizeof(Boolean), |
| 568 |
offset(tooltips_in_statusline), XtRString, "True"}, |
| 569 |
{"showTooltips", "ShowTooltips", XtRBoolean, sizeof(Boolean), |
| 570 |
offset(show_tooltips), XtRString, "True"}, |
| 571 |
#endif /* MOTIF */ |
| 572 |
{"pageListHighlightCurrent", "PageListHighlightCurrent", XtRBoolean, sizeof(Boolean), |
| 573 |
offset(pagelist_highlight_current), XtRString, "True"}, |
| 574 |
{"pageListWidth", "PageListWidth", XtRDimension, sizeof(Dimension), |
| 575 |
offset(pagelist_width), XtRImmediate, (XtPointer) 80}, |
| 576 |
{"magnifierSize1", "MagnifierSize", XtRString, sizeof(char *), |
| 577 |
offset(mg_arg[0]), XtRString, (XtPointer) NULL}, |
| 578 |
{"magnifierSize2", "MagnifierSize", XtRString, sizeof(char *), |
| 579 |
offset(mg_arg[1]), XtRString, (XtPointer) NULL}, |
| 580 |
{"magnifierSize3", "MagnifierSize", XtRString, sizeof(char *), |
| 581 |
offset(mg_arg[2]), XtRString, (XtPointer) NULL}, |
| 582 |
{"magnifierSize4", "MagnifierSize", XtRString, sizeof(char *), |
| 583 |
offset(mg_arg[3]), XtRString, (XtPointer) NULL}, |
| 584 |
{"magnifierSize5", "MagnifierSize", XtRString, sizeof(char *), |
| 585 |
offset(mg_arg[4]), XtRString, (XtPointer) NULL}, |
| 586 |
#if COLOR |
| 587 |
{"color", "Color", XtRBoolean, sizeof(Boolean), |
| 588 |
offset(use_color), XtRString, "true"}, |
| 589 |
#endif /* COLOR */ |
| 590 |
{"dvipsPath", "DvipsPath", XtRString, sizeof(char *), |
| 591 |
offset(dvips_path), XtRString, (XtPointer)DEFAULT_DVIPS_PATH}, |
| 592 |
{"ps2pdfPath", "Ps2PdfPath", XtRString, sizeof(char *), |
| 593 |
offset(ps2pdf_path), XtRString, (XtPointer)DEFAULT_PS2PDF_PATH}, |
| 594 |
{"dvipsHangTime", "DvipsHangTime", XtRInt, sizeof(int), |
| 595 |
offset(dvips_hang), XtRImmediate, (XtPointer) -1500}, |
| 596 |
{"dvipsFailHangTime", "DvipsFailHangTime", XtRInt, sizeof(int), |
| 597 |
offset(dvips_fail_hang), XtRImmediate, (XtPointer) -5000}, |
| 598 |
{"dvipsPrinterString", "DvipsPrinterString", XtRString, sizeof(char *), |
| 599 |
offset(dvips_printer_str), XtRString, (XtPointer)NULL}, |
| 600 |
{"dvipsOptionsString", "DvipsOptionsString", XtRString, sizeof(char *), |
| 601 |
offset(dvips_options_str), XtRString, (XtPointer)NULL}, |
| 602 |
{"defaultSavingFormat", "DefaultSavingFormat", XtRInt, sizeof(int), |
| 603 |
offset(default_saving_format), XtRImmediate, (XtPointer)0}, |
| 604 |
{"defaultPrintingTarget", "DefaultPrintingTarget", XtRInt, sizeof(int), |
| 605 |
offset(default_printing_target), XtRImmediate, (XtPointer)1}, |
| 606 |
#ifdef GREY |
| 607 |
{"grey", "Grey", XtRBoolean, sizeof(Boolean), |
| 608 |
offset(use_grey), XtRString, "true"}, |
| 609 |
{"install", "Install", XtRBool3, sizeof(Bool3), |
| 610 |
offset(install), XtRString, "maybe"}, |
| 611 |
#endif /* GREY */ |
| 612 |
{"matchInverted", "MatchInverted", XtRBoolean, sizeof(Boolean), |
| 613 |
offset(match_highlight_inverted), XtRString, "true"}, |
| 614 |
{"ruleColor", "RuleColor", XtRPixel, sizeof(Pixel), |
| 615 |
offset(rule_pixel), XtRPixel, (XtPointer) &resource.rule_pixel}, |
| 616 |
{"ruleColor", "RuleColor", XtRString, sizeof(char *), |
| 617 |
offset(rule_color), XtRString, (XtPointer) NULL}, |
| 618 |
/* linkStyle: style for presenting links: |
| 619 |
link_style is a bitsmask `xy' with x = color, y = underline, viz.: |
| 620 |
0: no highlighting at all |
| 621 |
1: underline with linkColor |
| 622 |
2: no underlining, text with linkColor |
| 623 |
3: underlining and text with linkColor |
| 624 |
*/ |
| 625 |
{"linkStyle", "LinkStyle", XtRInt, sizeof(int), |
| 626 |
offset(link_style), XtRImmediate, (XtPointer) 3}, |
| 627 |
{"linkColor", "LinkColor", XtRString, sizeof(char *), |
| 628 |
offset(link_color), XtRString, (XtPointer)LINK_COLOR_FALLBACK}, |
| 629 |
{"visitedLinkColor", "VisitedLinkColor", XtRString, sizeof(char *), |
| 630 |
offset(visited_link_color), XtRString, (XtPointer)VISITED_LINK_COLOR_FALLBACK}, |
| 631 |
{"wwwBrowser", "WWWBrowser", XtRString, sizeof(char *), |
| 632 |
offset(browser), XtRString, (XtPointer) NULL}, |
| 633 |
#ifdef MOTIF |
| 634 |
{"prefsBrowserList", "PrefsBrowserList", XtRString, sizeof(char *), |
| 635 |
offset(prefs_browser_list), XtRString, (XtPointer)Xdvi_PREFS_BROWSER_DEFAULTS }, |
| 636 |
{"prefsEditorList", "PrefsEditorList", XtRString, sizeof(char *), |
| 637 |
offset(prefs_editor_list), XtRString, (XtPointer)Xdvi_PREFS_EDITOR_DEFAULTS }, |
| 638 |
# if USE_COMBOBOX |
| 639 |
{"searchHistory", "SearchHistory", XtRString, sizeof(char *), |
| 640 |
offset(search_history), XtRString, (XtPointer)NULL }, |
| 641 |
{"searchHistorySize", "SearchHistorySize", XtRInt, sizeof(int), |
| 642 |
offset(search_history_size), XtRImmediate, (XtPointer)20}, |
| 643 |
# endif |
| 644 |
#endif |
| 645 |
/* defaults for unknown mime types */ |
| 646 |
{"unknownMimeSuffix", "UnknownMimeSuffix", XtRString, sizeof(char *), |
| 647 |
offset(unknown_mime_suffix), XtRString, "application/x-unknown"}, |
| 648 |
{"noMimeSuffix", "NoMimeSuffix", XtRString, sizeof(char *), |
| 649 |
offset(no_mime_suffix), XtRString, "application/x-unknown"}, |
| 650 |
{"anchorPosition", "AnchorPosition", XtRString, sizeof(char *), |
| 651 |
offset(anchor_pos), XtRString, (XtPointer) NULL}, |
| 652 |
/* bitmask for current search window settings; only used internally! */ |
| 653 |
{"searchWindowDefaults", "SearchWindowDefaults", XtRInt, sizeof(int), |
| 654 |
offset(search_window_defaults), XtRImmediate, (XtPointer)0}, |
| 655 |
/* whether to open file in new window from file selector (only for DVI files) */ |
| 656 |
{"fileselOpenNewWindow", "FileselOpenNewWindow", XtRBoolean, sizeof(Boolean), |
| 657 |
offset(filesel_open_new_window), XtRString, "False"}, |
| 658 |
/* resources for help text */ |
| 659 |
{"helpGeneral", "HelpGeneral", XtRString, sizeof(char *), |
| 660 |
offset(help_general), XtRString, NULL}, |
| 661 |
{"helpHypertex", "HelpHypertex", XtRString, sizeof(char *), |
| 662 |
offset(help_hypertex), XtRString, NULL}, |
| 663 |
{"helpOthercommands", "HelpOthercommands", XtRString, sizeof(char *), |
| 664 |
offset(help_othercommands), XtRString, NULL}, |
| 665 |
{"helpMarking", "HelpMarking", XtRString, sizeof(char *), |
| 666 |
offset(help_marking), XtRString, NULL}, |
| 667 |
{"helpPagemotion", "HelpPagemotion", XtRString, sizeof(char *), |
| 668 |
offset(help_pagemotion), XtRString, NULL}, |
| 669 |
{"helpMousebuttons", "HelpMousebuttons", XtRString, sizeof(char *), |
| 670 |
offset(help_mousebuttons), XtRString, NULL}, |
| 671 |
{"helpModes", "HelpModes", XtRString, sizeof(char *), |
| 672 |
offset(help_modes), XtRString, NULL}, |
| 673 |
{"helpSearch", "HelpSearch", XtRString, sizeof(char *), |
| 674 |
offset(help_search), XtRString, NULL}, |
| 675 |
{"helpSourcespecials", "HelpSoucespecials", XtRString, sizeof(char *), |
| 676 |
offset(help_sourcespecials), XtRString, NULL}, |
| 677 |
#ifdef GREY |
| 678 |
{"pageHistorySize", "PageHistorySize", XtRInt, sizeof(int), |
| 679 |
offset(page_history_size), XtRImmediate, (XtPointer)1000}, |
| 680 |
}; |
| 681 |
|
| 682 |
static XtResource app_pixel_resources[] = { /* get these later */ |
| 683 |
#endif /* GREY */ |
| 684 |
{"foreground", "Foreground", XtRPixel, sizeof(Pixel), |
| 685 |
offset(fore_Pixel), XtRString, XtDefaultForeground}, |
| 686 |
{"background", "Background", XtRPixel, sizeof(Pixel), |
| 687 |
offset(back_Pixel), XtRString, XtDefaultBackground}, |
| 688 |
/* {"borderColor", "BorderColor", XtRPixel, sizeof(Pixel), */ |
| 689 |
/* offset(brdr_Pixel), XtRPixel, (XtPointer) &resource.fore_Pixel}, */ |
| 690 |
{"highlight", "Highlight", XtRPixel, sizeof(Pixel), |
| 691 |
offset(hl_Pixel), XtRPixel, (XtPointer) &resource.fore_Pixel}, |
| 692 |
{"cursorColor", "CursorColor", XtRPixel, sizeof(Pixel), |
| 693 |
offset(cr_Pixel), XtRImmediate, (XtPointer)ULONG_MAX}, |
| 694 |
}; |
| 695 |
#undef offset |
| 696 |
|
| 697 |
|
| 698 |
#ifndef MOTIF |
| 699 |
|
| 700 |
# ifdef NOQUERY |
| 701 |
# define drawWidgetClass widgetClass |
| 702 |
# else |
| 703 |
|
| 704 |
static XtGeometryResult |
| 705 |
QueryGeometry(Widget w, |
| 706 |
XtWidgetGeometry *constraints, |
| 707 |
XtWidgetGeometry *reply) |
| 708 |
{ |
| 709 |
UNUSED(w); |
| 710 |
UNUSED(constraints); |
| 711 |
reply->request_mode = CWWidth | CWHeight; |
| 712 |
reply->width = globals.page.w; |
| 713 |
reply->height = globals.page.h; |
| 714 |
|
| 715 |
return XtGeometryAlmost; |
| 716 |
} |
| 717 |
|
| 718 |
# include <X11/IntrinsicP.h> |
| 719 |
# include <X11/CoreP.h> |
| 720 |
|
| 721 |
/* if the following gives you trouble, just compile with -DNOQUERY */ |
| 722 |
static WidgetClassRec drawingWidgetClass = { |
| 723 |
{ |
| 724 |
/* superclass */ &widgetClassRec, |
| 725 |
/* class_name */ "Draw", |
| 726 |
/* widget_size */ sizeof(WidgetRec), |
| 727 |
/* class_initialize */ NULL, |
| 728 |
/* class_part_initialize */ NULL, |
| 729 |
/* class_inited */ FALSE, |
| 730 |
/* initialize */ NULL, |
| 731 |
/* initialize_hook */ NULL, |
| 732 |
/* realize */ XtInheritRealize, |
| 733 |
/* actions */ NULL, |
| 734 |
/* num_actions */ 0, |
| 735 |
/* resources */ NULL, |
| 736 |
/* num_resources */ 0, |
| 737 |
/* xrm_class */ NULLQUARK, |
| 738 |
/* compress_motion */ FALSE, |
| 739 |
/* compress_exposure */ TRUE, |
| 740 |
/* compress_enterleave */ FALSE, |
| 741 |
/* visible_interest */ FALSE, |
| 742 |
/* destroy */ NULL, |
| 743 |
/* resize */ XtInheritResize, |
| 744 |
/* expose */ XtInheritExpose, |
| 745 |
/* set_values */ NULL, |
| 746 |
/* set_values_hook */ NULL, |
| 747 |
/* set_values_almost */ XtInheritSetValuesAlmost, |
| 748 |
/* get_values_hook */ NULL, |
| 749 |
/* accept_focus */ XtInheritAcceptFocus, |
| 750 |
/* version */ XtVersion, |
| 751 |
/* callback_offsets */ NULL, |
| 752 |
/* tm_table */ XtInheritTranslations, |
| 753 |
/* query_geometry */ QueryGeometry, |
| 754 |
/* display_accelerator */ XtInheritDisplayAccelerator, |
| 755 |
/* extension */ NULL |
| 756 |
} |
| 757 |
}; |
| 758 |
|
| 759 |
# define drawWidgetClass &drawingWidgetClass |
| 760 |
|
| 761 |
# endif /* NOQUERY */ |
| 762 |
#endif /* not MOTIF */ |
| 763 |
|
| 764 |
|
| 765 |
int |
| 766 |
atopix(const char *arg) |
| 767 |
{ |
| 768 |
int len = strlen(arg); |
| 769 |
const char *arg_end = arg; |
| 770 |
char tmp[16]; |
| 771 |
double factor, val; |
| 772 |
|
| 773 |
while ((*arg_end >= '0' && *arg_end <= '9') || *arg_end == '.') |
| 774 |
++arg_end; |
| 775 |
|
| 776 |
if (arg_end >= arg + XtNumber(tmp) - 1) { /* should be rare */ |
| 777 |
char *tmp_var = xstrndup(arg, arg_end - arg); |
| 778 |
val = atof(tmp_var); |
| 779 |
free(tmp_var); |
| 780 |
} |
| 781 |
else { |
| 782 |
memcpy(tmp, arg, arg_end - arg); |
| 783 |
tmp[arg_end - arg] = '\0'; |
| 784 |
val = atof(tmp); |
| 785 |
} |
| 786 |
|
| 787 |
#if A4 |
| 788 |
factor = 1.0 / 2.54; /* cm */ |
| 789 |
#else |
| 790 |
factor = 1.0; /* inches */ |
| 791 |
#endif |
| 792 |
if (len > 2) |
| 793 |
switch (arg[len - 2] << 8 | arg[len - 1]) { |
| 794 |
#if A4 |
| 795 |
case 'i' << 8 | 'n': |
| 796 |
factor = 1.0; |
| 797 |
break; |
| 798 |
#else |
| 799 |
case 'c' << 8 | 'm': |
| 800 |
factor = 1.0 / 2.54; |
| 801 |
break; |
| 802 |
#endif |
| 803 |
case 'm' << 8 | 'm': |
| 804 |
factor = 1.0 / 25.4; |
| 805 |
break; |
| 806 |
case 'p' << 8 | 't': |
| 807 |
factor = 1.0 / 72.27; |
| 808 |
break; |
| 809 |
case 'p' << 8 | 'c': |
| 810 |
factor = 12.0 / 72.27; |
| 811 |
break; |
| 812 |
case 'b' << 8 | 'p': |
| 813 |
factor = 1.0 / 72.0; |
| 814 |
break; |
| 815 |
case 'd' << 8 | 'd': |
| 816 |
factor = 1238.0 / 1157.0 / 72.27; |
| 817 |
break; |
| 818 |
case 'c' << 8 | 'c': |
| 819 |
factor = 12 * 1238.0 / 1157.0 / 72.27; |
| 820 |
break; |
| 821 |
case 's' << 8 | 'p': |
| 822 |
factor = 1.0 / 72.27 / 65536; |
| 823 |
break; |
| 824 |
} |
| 825 |
|
| 826 |
return factor * val * resource.pixels_per_inch + 0.5; |
| 827 |
} |
| 828 |
|
| 829 |
int |
| 830 |
atopix_signed(const char *arg) |
| 831 |
{ |
| 832 |
return *arg == '-' ? -atopix(arg + 1) : atopix(arg); |
| 833 |
} |
| 834 |
|
| 835 |
#if CHECK_APP_FILEVERSION |
| 836 |
static void |
| 837 |
check_app_defaults_fileversion(void) |
| 838 |
{ |
| 839 |
/* update this when new essential resources are introduced */ |
| 840 |
static const int required_version = 20030303; |
| 841 |
|
| 842 |
if (resource.app_defaults_fileversion < required_version) { |
| 843 |
const char *filename = kpse_find_file("XDvi", kpse_program_text_format, 0); |
| 844 |
if (filename == NULL) |
| 845 |
filename = "XDvi"; |
| 846 |
|
| 847 |
fprintf(stderr, "filename: %d\n", resource.app_defaults_fileversion); |
| 848 |
popup_message(globals.widgets.top_level, |
| 849 |
MSG_WARN, |
| 850 |
NULL, |
| 851 |
"Your application defaults file `%s' is outdated. " |
| 852 |
"This version of xdvi requires a file " |
| 853 |
"with date >= %d. Your file is older, or doesn't have a date.\n" |
| 854 |
"Please obtain a new version of the file `XDvi', e.g. from:\n" |
| 855 |
"http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/xdvi/xdvik/texk/xdvik/texmf/\n" |
| 856 |
"and copy it to a directory in your $XDVIINPUTS path.", |
| 857 |
filename, required_version); |
| 858 |
} |
| 859 |
} |
| 860 |
#endif |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
#ifdef GREY |
| 865 |
static Arg temp_args1[] = { |
| 866 |
{XtNdepth, (XtArgVal) 0}, |
| 867 |
{XtNvisual, (XtArgVal) 0}, |
| 868 |
{XtNcolormap, (XtArgVal) 0}, |
| 869 |
}; |
| 870 |
|
| 871 |
/* |
| 872 |
* Alternate routine to convert color name to Pixel (needed to substitute |
| 873 |
* "black" or "white" for BlackPixelOfScreen, etc., since a different visual |
| 874 |
* and colormap are in use). |
| 875 |
*/ |
| 876 |
|
| 877 |
static Boolean |
| 878 |
XdviCvtStringToPixel(Display *dpy, |
| 879 |
XrmValuePtr args, Cardinal *num_args, |
| 880 |
XrmValuePtr fromVal, XrmValuePtr toVal, |
| 881 |
XtPointer *closure_ret) |
| 882 |
{ |
| 883 |
XrmValue replacement_val; |
| 884 |
Boolean default_is_fg; |
| 885 |
|
| 886 |
if ((strcmp((String) fromVal->addr, XtDefaultForeground) == 0 |
| 887 |
&& (default_is_fg = True, True)) |
| 888 |
|| (strcmp((String) fromVal->addr, XtDefaultBackground) == 0 |
| 889 |
&& ((default_is_fg = False), True))) { |
| 890 |
replacement_val.size = sizeof(String); |
| 891 |
replacement_val.addr = (default_is_fg == resource.reverse) |
| 892 |
? "white" : "black"; |
| 893 |
fromVal = &replacement_val; |
| 894 |
} |
| 895 |
|
| 896 |
return XtCvtStringToPixel(dpy, args, num_args, fromVal, toVal, closure_ret); |
| 897 |
} |
| 898 |
|
| 899 |
#endif |
| 900 |
|
| 901 |
|
| 902 |
/* |
| 903 |
* Set the `sourceposition' propery of the window `w' to `source_str'. |
| 904 |
* This is usually done in `client' mode to notify the instance of |
| 905 |
* xdvi running in window `w' to start a forward search. After this, |
| 906 |
* the client usually exits normally. |
| 907 |
*/ |
| 908 |
static void |
| 909 |
set_sourceposition_property(const char *source_str, Window win) |
| 910 |
{ |
| 911 |
/* parse the special in order to expand the filename */ |
| 912 |
struct src_parsed_special data; |
| 913 |
char *new_special = NULL; |
| 914 |
char *expanded_filename = NULL; |
| 915 |
|
| 916 |
data.filename_len = 0; |
| 917 |
data.filename = NULL; |
| 918 |
|
| 919 |
src_parse(source_str, strlen(source_str), &data); |
| 920 |
|
| 921 |
if (data.filename_len == 0) { |
| 922 |
/* can't give a GUI warning in `client' mode - just exit with error */ |
| 923 |
XDVI_FATAL((stderr, |
| 924 |
"Filename missing in -sourceposition argument (%s)!", |
| 925 |
source_str)); |
| 926 |
} |
| 927 |
|
| 928 |
TRACE_CLIENT((stderr, "got data: line %d, col %d, file |%s|, len %lu\n", |
| 929 |
data.line, data.col, data.filename, (unsigned long)data.filename_len)); |
| 930 |
|
| 931 |
/* expand -sourceposition argument if it contains a path component. |
| 932 |
We don't use REALPATH here, because `tex -src' doesn't expand |
| 933 |
symlinks either. Instead, use canonicalize_path() to expand |
| 934 |
`../' and './' manually. */ |
| 935 |
if (strchr(data.filename, '/') != NULL |
| 936 |
&& (expanded_filename = expand_filename(data.filename, USE_CWD_PATH)) != NULL) { |
| 937 |
char *tmp = canonicalize_path(expanded_filename); |
| 938 |
free(data.filename); |
| 939 |
free(expanded_filename); |
| 940 |
expanded_filename = tmp; |
| 941 |
} |
| 942 |
else |
| 943 |
expanded_filename = data.filename; |
| 944 |
|
| 945 |
TRACE_CLIENT((stderr, "expanded1: |%s|\n", expanded_filename)); |
| 946 |
|
| 947 |
new_special = xmalloc(2 * LENGTH_OF_INT + 2 /* 2 for `:' and separating space */ |
| 948 |
+ strlen(expanded_filename) + 1); |
| 949 |
sprintf(new_special, "%d:%d %s", data.line, data.col, expanded_filename); |
| 950 |
free(expanded_filename); |
| 951 |
|
| 952 |
TRACE_CLIENT((stderr, "matched!")); |
| 953 |
set_string_property(new_special, atom_src_goto(), win); |
| 954 |
free(new_special); |
| 955 |
set_string_property("", atom_raise(), win); |
| 956 |
} |
| 957 |
|
| 958 |
static void |
| 959 |
set_stringsearch_property(const char *str, Window win) |
| 960 |
{ |
| 961 |
set_string_property(str, atom_find_string(), win); |
| 962 |
set_string_property("", atom_raise(), win); |
| 963 |
} |
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
/* Translation of valid paper types to dimensions, |
| 968 |
which are used internally. The newline characters are a hack |
| 969 |
to format the list neatly for error messages. |
| 970 |
A* series measures are taken from |
| 971 |
http://www.cl.cam.ac.uk/~mgk25/iso-paper.html |
| 972 |
*/ |
| 973 |
static const char *paper_types[] = { |
| 974 |
"us", "8.5x11in", |
| 975 |
"letter", "8.5x11in", /* dvips compatibility */ |
| 976 |
"ledger", "17x11in", /* dvips compatibility */ |
| 977 |
"tabloid", "11x17in", /* dvips compatibility */ |
| 978 |
"usr", "11x8.5in", |
| 979 |
"legal", "8.5x14in", |
| 980 |
"legalr", "14x8.5in", |
| 981 |
"foolscap", "13.5x17.0in", /* ??? */ |
| 982 |
"foolscapr", "17.0x13.5in", |
| 983 |
"", "0", |
| 984 |
|
| 985 |
/* ISO `A' formats, Portrait */ |
| 986 |
"a0", "841x1189mm", |
| 987 |
"a1", "594x841mm", |
| 988 |
"a2", "420x594mm", |
| 989 |
"a3", "297x420mm", |
| 990 |
"a4", "210x297mm", |
| 991 |
"a5", "148x210mm", |
| 992 |
"a6", "105x148mm", |
| 993 |
"a7", "74x105mm", |
| 994 |
"a8", "52x74mm", |
| 995 |
"a9", "37x52mm", |
| 996 |
"a10","26x37mm", |
| 997 |
"", "0", |
| 998 |
|
| 999 |
/* ISO `A' formats, Landscape */ |
| 1000 |
"a0r", "1189x841mm", |
| 1001 |
"a1r", "841x594mm", |
| 1002 |
"a2r", "594x420mm", |
| 1003 |
"a3r", "420x297mm", |
| 1004 |
"a4r", "297x210mm", |
| 1005 |
"a5r", "210x148mm", |
| 1006 |
"a6r", "148x105mm", |
| 1007 |
"a7r", "105x74mm", |
| 1008 |
"a8r", "74x52mm", |
| 1009 |
"a9r", "52x37mm", |
| 1010 |
"a10r","37x26mm", |
| 1011 |
"", "0", |
| 1012 |
|
| 1013 |
/* ISO `B' formats, Portrait */ |
| 1014 |
"b0", "1000x1414mm", |
| 1015 |
"b1", "707x1000mm", |
| 1016 |
"b2", "500x707mm", |
| 1017 |
"b3", "353x500mm", |
| 1018 |
"b4", "250x353mm", |
| 1019 |
"b5", "176x250mm", |
| 1020 |
"b6", "125x176mm", |
| 1021 |
"b7", "88x125mm", |
| 1022 |
"b8", "62x88mm", |
| 1023 |
"b9", "44x62mm", |
| 1024 |
"b10","31x44mm", |
| 1025 |
"", "0", |
| 1026 |
|
| 1027 |
/* ISO `B' formats, Landscape */ |
| 1028 |
"b0r", "1414x1000mm", |
| 1029 |
"b1r", "1000x707mm", |
| 1030 |
"b2r", "707x500mm", |
| 1031 |
"b3r", "500x353mm", |
| 1032 |
"b4r", "353x250mm", |
| 1033 |
"b5r", "250x176mm", |
| 1034 |
"b6r", "176x125mm", |
| 1035 |
"b7r", "125x88mm", |
| 1036 |
"b8r", "88x62mm", |
| 1037 |
"b9r", "62x44mm", |
| 1038 |
"b10r","44x31mm", |
| 1039 |
"", "0", |
| 1040 |
|
| 1041 |
/* ISO `C' formats, Portrait */ |
| 1042 |
"c0", "917x1297mm", |
| 1043 |
"c1", "648x917mm", |
| 1044 |
"c2", "458x648mm", |
| 1045 |
"c3", "324x458mm", |
| 1046 |
"c4", "229x324mm", |
| 1047 |
"c5", "162x229mm", |
| 1048 |
"c6", "114x162mm", |
| 1049 |
"c7", "81x114mm", |
| 1050 |
"c8", "57x81mm", |
| 1051 |
"c9", "40x57mm", |
| 1052 |
"c10","28x40mm", |
| 1053 |
"", "0", |
| 1054 |
|
| 1055 |
/* ISO `C' formats, Landscape */ |
| 1056 |
"c0r", "1297x917mm", |
| 1057 |
"c1r", "917x648mm", |
| 1058 |
"c2r", "648x458mm", |
| 1059 |
"c3r", "458x324mm", |
| 1060 |
"c4r", "324x229mm", |
| 1061 |
"c5r", "229x162mm", |
| 1062 |
"c6r", "162x114mm", |
| 1063 |
"c7r", "114x81mm", |
| 1064 |
"c8r", "81x57mm", |
| 1065 |
"c9r", "57x40mm", |
| 1066 |
"c10r","40x28mm", |
| 1067 |
}; |
| 1068 |
|
| 1069 |
/* access methods for paper_types */ |
| 1070 |
const char **get_paper_types(void) { |
| 1071 |
return paper_types; |
| 1072 |
} |
| 1073 |
|
| 1074 |
size_t get_paper_types_size(void) { |
| 1075 |
return XtNumber(paper_types); |
| 1076 |
} |
| 1077 |
|
| 1078 |
/* Set the icon name and title name standard properties on `globals.widgets.top_level'. |
| 1079 |
* We use the basename of the DVI file (without the .dvi), so different xdvi |
| 1080 |
* invocations can be distinguished, yet do not use up too much real estate. |
| 1081 |
* |
| 1082 |
* This function returns freshly allocated memory in *icon_name and *title_name |
| 1083 |
* which the caller is responsible for free()ing again. |
| 1084 |
*/ |
| 1085 |
void |
| 1086 |
get_icon_and_title(const char *filename, char **icon_name, char **title_name) |
| 1087 |
{ |
| 1088 |
/* Use basename of DVI file for name in icon and title. */ |
| 1089 |
const char *ptr; |
| 1090 |
char *ptr2; |
| 1091 |
|
| 1092 |
/* SU 2000/12/16: added page number information */ |
| 1093 |
const char *const title_name_fmt = "%s: %s (%d page%s)"; |
| 1094 |
|
| 1095 |
MYTRACE((stderr, "get_icon_and_title called with: |%s|", filename)); |
| 1096 |
|
| 1097 |
ptr = strrchr(filename, '/'); |
| 1098 |
if (ptr != NULL) |
| 1099 |
++ptr; |
| 1100 |
else { |
| 1101 |
ptr = filename; |
| 1102 |
} |
| 1103 |
|
| 1104 |
/* |
| 1105 |
* Remove the `file:' prefix from the icon name; since some windowmanagers |
| 1106 |
* only display a prefix in window lists etc., it's more significant this |
| 1107 |
* way. |
| 1108 |
*/ |
| 1109 |
|
| 1110 |
if (memcmp(ptr, "file:", 5) == 0) { |
| 1111 |
ptr += 5; |
| 1112 |
} |
| 1113 |
*icon_name = xstrdup(ptr); |
| 1114 |
|
| 1115 |
MYTRACE((stderr, "before chopping: icon_name: |%s|", *icon_name)); |
| 1116 |
if ((ptr2 = strstr(*icon_name, ".dvi")) != NULL) { |
| 1117 |
/* chop off .dvi extension */ |
| 1118 |
*ptr2 = '\0'; |
| 1119 |
} |
| 1120 |
MYTRACE((stderr, "after chopping: icon_name: |%s|", *icon_name)); |
| 1121 |
|
| 1122 |
*title_name = xmalloc(strlen(title_name_fmt) |
| 1123 |
+ strlen(XDVIK_PROGNAME) |
| 1124 |
+ strlen(*icon_name) |
| 1125 |
+ LENGTH_OF_INT |
| 1126 |
+ 2); /* 2 for additional plural `s' */ |
| 1127 |
MYTRACE((stderr, "total_pages: %d", total_pages)); |
| 1128 |
sprintf(*title_name, title_name_fmt, XDVIK_PROGNAME, *icon_name, total_pages, |
| 1129 |
(total_pages > 1) ? "s" : ""); |
| 1130 |
|
| 1131 |
MYTRACE((stderr, "title_name, icon_name: |%s|%s|", *title_name, *icon_name)); |
| 1132 |
} |
| 1133 |
|
| 1134 |
void |
| 1135 |
set_icon_and_title(const char *icon_name, const char *title_name) |
| 1136 |
{ |
| 1137 |
if (!XtIsRealized(globals.widgets.top_level)) { |
| 1138 |
MYTRACE((stderr, "set_icon_and_title: returning")); |
| 1139 |
return; |
| 1140 |
} |
| 1141 |
XtVaSetValues(globals.widgets.top_level, XtNtitle, (XtArgVal) title_name, XtNiconName, (XtArgVal) icon_name, NULL); |
| 1142 |
XSetStandardProperties(DISP, XtWindow(globals.widgets.top_level), title_name, icon_name, |
| 1143 |
(Pixmap) 0, NULL, 0, NULL); |
| 1144 |
} |
| 1145 |
|
| 1146 |
static void |
| 1147 |
get_window_constraints(XtWidgetGeometry *reply, |
| 1148 |
Dimension screen_w, Dimension screen_h, |
| 1149 |
int *add_h) |
| 1150 |
{ |
| 1151 |
XtWidgetGeometry constraints; |
| 1152 |
|
| 1153 |
constraints.request_mode = reply->request_mode = 0; |
| 1154 |
|
| 1155 |
/* fprintf(stderr, "setting constraints.width to %d\n", globals.page.w); */ |
| 1156 |
constraints.width = globals.page.w; |
| 1157 |
if (globals.page.w > screen_w) { |
| 1158 |
constraints.request_mode |= CWWidth; |
| 1159 |
constraints.width = screen_w; |
| 1160 |
} |
| 1161 |
|
| 1162 |
/* fprintf(stderr, "setting constraints.height to %d; screen_h = %d\n", globals.page.h, screen_h); */ |
| 1163 |
constraints.height = globals.page.h; |
| 1164 |
if (constraints.height > screen_h) { |
| 1165 |
constraints.request_mode |= CWHeight; |
| 1166 |
constraints.height = screen_h; |
| 1167 |
} |
| 1168 |
|
| 1169 |
if (constraints.request_mode != 0 |
| 1170 |
&& constraints.request_mode != (CWWidth | CWHeight)) { |
| 1171 |
#ifdef MOTIF |
| 1172 |
(void)XtQueryGeometry(globals.widgets.main_window, &constraints, reply); |
| 1173 |
#else |
| 1174 |
(void)XtQueryGeometry(globals.widgets.vport_widget, &constraints, reply); |
| 1175 |
#endif |
| 1176 |
} |
| 1177 |
/* fprintf(stderr, "reply height: %d; screen_h: %d; add_h: %d\n", reply->height, screen_h, *add_h); */ |
| 1178 |
if (!(reply->request_mode & CWWidth)) |
| 1179 |
reply->width = constraints.width; |
| 1180 |
if (reply->width >= screen_w) |
| 1181 |
reply->width = screen_w; |
| 1182 |
if (!(reply->request_mode & CWHeight)) { |
| 1183 |
reply->height = constraints.height - 2 * bwidth; |
| 1184 |
} |
| 1185 |
|
| 1186 |
if (reply->height + *add_h >= screen_h) { |
| 1187 |
reply->height = screen_h |
| 1188 |
#ifdef MOTIF |
| 1189 |
- 1.5 |
| 1190 |
#else |
| 1191 |
- 2 |
| 1192 |
#endif |
| 1193 |
* *add_h - 2 * bwidth; |
| 1194 |
} |
| 1195 |
} |
| 1196 |
|
| 1197 |
void |
| 1198 |
set_windowsize(Dimension *ret_w, Dimension *ret_h, int add_w, int add_h, Boolean override) |
| 1199 |
{ |
| 1200 |
static Arg set_wh_args[] = { |
| 1201 |
{XtNwidth, (XtArgVal) 0}, |
| 1202 |
{XtNheight, (XtArgVal) 0}, |
| 1203 |
}; |
| 1204 |
Dimension screen_w, screen_h; |
| 1205 |
|
| 1206 |
const char *test_geometry = resource.geometry; |
| 1207 |
|
| 1208 |
if (resource.fullscreen) { |
| 1209 |
Dimension w = WidthOfScreen(SCRN), h = HeightOfScreen(SCRN); |
| 1210 |
|
| 1211 |
if (currwin.shrinkfactor == 0) { /* if not set by user */ |
| 1212 |
Dimension height_factor = ROUNDUP(globals.page.unshrunk_h, h); |
| 1213 |
currwin.shrinkfactor = ROUNDUP(globals.page.unshrunk_w, w); |
| 1214 |
if (height_factor >= currwin.shrinkfactor) |
| 1215 |
currwin.shrinkfactor = height_factor; |
| 1216 |
/* fprintf(stderr, "factor was 0, using %d\n", currwin.shrinkfactor); */ |
| 1217 |
} |
| 1218 |
/* else */ |
| 1219 |
/* fprintf(stderr, "factor != 0, using %d\n", currwin.shrinkfactor); */ |
| 1220 |
|
| 1221 |
mane.shrinkfactor = currwin.shrinkfactor; |
| 1222 |
init_page(); |
| 1223 |
set_wh_args[0].value = (XtArgVal)w; |
| 1224 |
set_wh_args[1].value = (XtArgVal)h; |
| 1225 |
*ret_w = w; |
| 1226 |
*ret_h = h; |
| 1227 |
#ifdef MOTIF |
| 1228 |
#if USE_XAW_PANNER |
| 1229 |
XtVaGetValues(globals.widgets.main_window, XmNshadowThickness, &g_save_shadow_thickness, NULL); |
| 1230 |
#endif |
| 1231 |
XtVaSetValues(globals.widgets.main_window, XmNshadowThickness, 0, NULL); |
| 1232 |
#endif |
| 1233 |
XtSetValues(globals.widgets.top_level, set_wh_args, XtNumber(set_wh_args)); |
| 1234 |
} |
| 1235 |
else if (override) { |
| 1236 |
set_wh_args[0].value = (XtArgVal)*ret_w; |
| 1237 |
set_wh_args[1].value = (XtArgVal)*ret_h; |
| 1238 |
XtSetValues(globals.widgets.top_level, set_wh_args, XtNumber(set_wh_args)); |
| 1239 |
} |
| 1240 |
else { /* determine a window size that fits the current shrink factor */ |
| 1241 |
Arg temp_args3 = { XtNborderWidth, (XtArgVal)&bwidth }; |
| 1242 |
XtWidgetGeometry reply; |
| 1243 |
|
| 1244 |
XtGetValues(globals.widgets.top_level, &temp_args3, 1); /* get border width */ |
| 1245 |
screen_w = WidthOfScreen(SCRN) - 2 * bwidth; |
| 1246 |
|
| 1247 |
screen_w -= add_w; |
| 1248 |
/* screen_h = HeightOfScreen(SCRN) - 2 * bwidth - get_statusline_height() - 6; */ |
| 1249 |
screen_h = HeightOfScreen(SCRN) - 2 * bwidth; |
| 1250 |
for (;;) { /* actually, at most two passes */ |
| 1251 |
Dimension height_factor; |
| 1252 |
|
| 1253 |
TRACE_GUI((stderr, "geometry: |%s|; remember: %d, windowsize: %s", |
| 1254 |
resource.geometry ? resource.geometry : "<NULL>", |
| 1255 |
resource.remember_windowsize, |
| 1256 |
resource.windowsize ? resource.windowsize : "<NULL>")); |
| 1257 |
|
| 1258 |
if (resource.geometry == NULL && !resource.remember_windowsize) { |
| 1259 |
/* geometry not set by user, try to find geometry that fits the shrink factor */ |
| 1260 |
get_window_constraints(&reply, screen_w, screen_h, &add_h); |
| 1261 |
TRACE_GUI((stderr, "w: %d, h: %d, add_h: %d, reply: %d x %d", |
| 1262 |
screen_w, screen_h, add_h, reply.width, reply.height)); |
| 1263 |
} |
| 1264 |
else { |
| 1265 |
int x, y; |
| 1266 |
unsigned int width, height; |
| 1267 |
int flags; |
| 1268 |
|
| 1269 |
if (resource.remember_windowsize && resource.windowsize != NULL) |
| 1270 |
test_geometry = resource.windowsize; |
| 1271 |
else |
| 1272 |
test_geometry = resource.geometry; |
| 1273 |
flags = XParseGeometry(test_geometry, &x, &y, &width, &height); |
| 1274 |
|
| 1275 |
if (!(flags & WidthValue) || !(flags & HeightValue)) { |
| 1276 |
/* no geometry specified, use fallback */ |
| 1277 |
get_window_constraints(&reply, screen_w, screen_h, &add_h); |
| 1278 |
} |
| 1279 |
|
| 1280 |
/* warn about bad values */ |
| 1281 |
if (flags & WidthValue) { |
| 1282 |
if (width > (unsigned int)(2 * bwidth + add_w)) { |
| 1283 |
TRACE_GUI((stderr, "width: %u, bwidth: %hu, add_w: %d", |
| 1284 |
width, bwidth, add_w)); |
| 1285 |
reply.width = width - 2 * bwidth - add_w; |
| 1286 |
} |
| 1287 |
else { |
| 1288 |
reply.width = width; |
| 1289 |
} |
| 1290 |
} |
| 1291 |
if (flags & HeightValue) { |
| 1292 |
if (height > (unsigned int)(2 * bwidth + add_h)) { |
| 1293 |
TRACE_GUI((stderr, "height: %u, bwidth: %hu, add_h: %d", |
| 1294 |
height, bwidth, add_h)); |
| 1295 |
reply.height = height - 2 * bwidth - add_h; |
| 1296 |
} |
| 1297 |
else { |
| 1298 |
reply.height = height; |
| 1299 |
} |
| 1300 |
} |
| 1301 |
TRACE_GUI((stderr, "setting geometry: %dx%d", (int)reply.width, (int)reply.height)); |
| 1302 |
} |
| 1303 |
|
| 1304 |
/* now reply.{width,height} contain max. usable window size */ |
| 1305 |
|
| 1306 |
/* User didn't use `-s 0', use either default or other user-specified value */ |
| 1307 |
if (currwin.shrinkfactor != 0) { |
| 1308 |
/* fprintf(stderr, "factor != 0, using %d\n", currwin.shrinkfactor); */ |
| 1309 |
break; |
| 1310 |
} |
| 1311 |
/* else { */ |
| 1312 |
/* fprintf(stderr, "factor was 0, using %d\n", currwin.shrinkfactor); */ |
| 1313 |
/* } */ |
| 1314 |
|
| 1315 |
/* else, try to find a suitable shrink factor: */ |
| 1316 |
currwin.shrinkfactor = ROUNDUP(globals.page.unshrunk_w, reply.width - 2); |
| 1317 |
/* fprintf(stderr, "factor w: %d\n", currwin.shrinkfactor); */ |
| 1318 |
|
| 1319 |
height_factor = ROUNDUP(globals.page.unshrunk_h, reply.height - 2); |
| 1320 |
/* fprintf(stderr, "factor h: %d\n", height_factor); */ |
| 1321 |
if (height_factor >= currwin.shrinkfactor) |
| 1322 |
currwin.shrinkfactor = height_factor; |
| 1323 |
|
| 1324 |
/* fprintf(stderr, "factor now is: %d\n", currwin.shrinkfactor); */ |
| 1325 |
|
| 1326 |
mane.shrinkfactor = currwin.shrinkfactor; |
| 1327 |
init_page(); |
| 1328 |
set_wh_args[0].value = (XtArgVal)globals.page.w; |
| 1329 |
set_wh_args[1].value = (XtArgVal)globals.page.h; |
| 1330 |
*ret_w = globals.page.w; |
| 1331 |
*ret_h = globals.page.h; |
| 1332 |
XtSetValues(globals.widgets.draw_widget, set_wh_args, XtNumber(set_wh_args)); |
| 1333 |
} |
| 1334 |
#ifdef MOTIF |
| 1335 |
/* |
| 1336 |
SU 2002/11/23: Added scrollbar width to height computation. |
| 1337 |
Otherwise, when the vertical space isn't sufficient, a |
| 1338 |
vertical scrollbar will be added, but since this makes the |
| 1339 |
display narrower, a horizontal scrollbar will be added as |
| 1340 |
well, even if this wouldn't be neccessary. |
| 1341 |
|
| 1342 |
SU 2003/09/30: Apparently the size computation works now, even |
| 1343 |
though I'm not sure why (scrollbar value isn't in add_w). Investigate. |
| 1344 |
*/ |
| 1345 |
/* HACK ALERT: 4 for window decoration borders - FIXME: get actual values?? */ |
| 1346 |
set_wh_args[0].value = reply.width + add_w + (test_geometry == NULL ? 4 : 0); |
| 1347 |
set_wh_args[1].value = reply.height + add_h + (test_geometry == NULL ? 4 : 0); |
| 1348 |
XtSetValues(globals.widgets.top_level, set_wh_args, XtNumber(set_wh_args)); |
| 1349 |
|
| 1350 |
#else /* MOTIF */ |
| 1351 |
|
| 1352 |
set_wh_args[0].value = reply.width + add_w + 2 * bwidth; /* + (test_geometry == NULL ? 15 : (2 * bwidth)); */ |
| 1353 |
/* |
| 1354 |
FIXME: use real height of statusline here |
| 1355 |
Somehow I didn't manage to use XtVaCreateWidget in a call to |
| 1356 |
create_statusline() above, and XtManageChild() below. |
| 1357 |
In that case, we could do without get_statusline_height(). |
| 1358 |
*/ |
| 1359 |
set_wh_args[1].value = reply.height + (test_geometry == NULL ? (2 * bwidth + add_h) : 0); |
| 1360 |
XtSetValues(globals.widgets.top_level, set_wh_args, XtNumber(set_wh_args)); |
| 1361 |
set_wh_args[0].value -= add_w; |
| 1362 |
XtSetValues(globals.widgets.vport_widget, set_wh_args, XtNumber(set_wh_args)); |
| 1363 |
|
| 1364 |
#endif /* MOTIF */ |
| 1365 |
*ret_w = set_wh_args[0].value; |
| 1366 |
*ret_h = set_wh_args[1].value; |
| 1367 |
TRACE_GUI((stderr, "returning: w=%d, h=%d", *ret_w, *ret_h)); |
| 1368 |
} |
| 1369 |
} |
| 1370 |
|
| 1371 |
static void |
| 1372 |
net_wm_toggle_fullscreen(int flag) |
| 1373 |
{ |
| 1374 |
Atom NET_WM_FULLSCREEN = XInternAtom(DISP, "_NET_WM_STATE_FULLSCREEN", True); |
| 1375 |
|
| 1376 |
if (NET_WM_FULLSCREEN) { |
| 1377 |
XEvent ev; |
| 1378 |
Atom NET_WM_STATE = XInternAtom(DISP, "_NET_WM_STATE", False); |
| 1379 |
|
| 1380 |
/* XDVI_INFO((stdout, "trying _NET_WM_STATE_FULLSCREEN ...")); */ |
| 1381 |
|
| 1382 |
ev.type = ClientMessage; |
| 1383 |
ev.xclient.serial = 0; |
| 1384 |
ev.xclient.send_event = True; |
| 1385 |
ev.xclient.display = DISP; |
| 1386 |
ev.xclient.window = XtWindow(globals.widgets.top_level); |
| 1387 |
ev.xclient.message_type = NET_WM_STATE; |
| 1388 |
ev.xclient.format = 32; |
| 1389 |
ev.xclient.data.l[0] = flag; /* _NET_WM_STATE_REMOVE (0) or _NET_WM_STATE_ADD (1) */ |
| 1390 |
ev.xclient.data.l[1] = NET_WM_FULLSCREEN; |
| 1391 |
ev.xclient.data.l[2] = 0L; |
| 1392 |
|
| 1393 |
XSendEvent(DISP, DefaultRootWindow(DISP), False, |
| 1394 |
SubstructureNotifyMask, &ev); |
| 1395 |
} |
| 1396 |
else { |
| 1397 |
XDVI_INFO((stdout, "_NET_WM_STATE_FULLSCREEN not supported by this window manager.")); |
| 1398 |
} |
| 1399 |
} |
| 1400 |
|
| 1401 |
void |
| 1402 |
reconfigure_window(Boolean fullscreen, Dimension width, Dimension height, |
| 1403 |
Boolean save_position) |
| 1404 |
{ |
| 1405 |
static int x_old = 5, y_old = 15; |
| 1406 |
#ifdef SIZECONFIGURE_WORKS |
| 1407 |
int sizeconfiguremask; |
| 1408 |
XWindowChanges sizeconfigure; |
| 1409 |
#endif /* SIZECONFIGURE_WORKS */ |
| 1410 |
#ifdef MOTIF |
| 1411 |
static int save_wm_decorations; |
| 1412 |
#else |
| 1413 |
static struct PropMotifWmHints MWMHints = {MWM_HINTS_DECORATIONS, 0, 0, 0, 0}; |
| 1414 |
Atom WM_HINTS = XInternAtom(DISP, "_MOTIF_WM_HINTS", True); |
| 1415 |
#endif |
| 1416 |
int x, y; |
| 1417 |
|
| 1418 |
#ifdef SIZECONFIGURE_WORKS |
| 1419 |
sizeconfiguremask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth; |
| 1420 |
sizeconfigure.width = width; |
| 1421 |
sizeconfigure.height = height; |
| 1422 |
#endif /* SIZECONFIGURE_WORKS */ |
| 1423 |
|
| 1424 |
if (fullscreen) { |
| 1425 |
#if 0 |
| 1426 |
static Boolean first_time = True; |
| 1427 |
/* offsets between the raw window and the decorated window */ |
| 1428 |
static int wm_x_offset = 0; |
| 1429 |
static int wm_y_offset = 0; |
| 1430 |
#endif |
| 1431 |
Window dummy; |
| 1432 |
|
| 1433 |
#ifdef SIZECONFIGURE_WORKS |
| 1434 |
sizeconfigure.x = 0; |
| 1435 |
sizeconfigure.y = 0; |
| 1436 |
sizeconfigure.border_width = 0; |
| 1437 |
#endif /* SIZECONFIGURE_WORKS */ |
| 1438 |
|
| 1439 |
/* Note ZLB: avoid to call XTranslateCoordinates if the window is |
| 1440 |
not yet mapped since XTranslateCoordinates implicitly maps the |
| 1441 |
window (note: calling the function XGetWindowAttributes also |
| 1442 |
makes the window mapped). |
| 1443 |
|
| 1444 |
This effectively eliminates the flashing effect when xdvik is |
| 1445 |
started in fullscreen mode for the Motif version. For the Xaw |
| 1446 |
version we still get flashing effect (seems that the window is |
| 1447 |
already mapped). */ |
| 1448 |
|
| 1449 |
if (save_position) { |
| 1450 |
/* save current window coordinates so that we can change them back */ |
| 1451 |
(void)XTranslateCoordinates(DISP, XtWindow(globals.widgets.top_level), |
| 1452 |
RootWindowOfScreen(SCRN), |
| 1453 |
0, 0, |
| 1454 |
&x_old, &y_old, |
| 1455 |
&dummy); |
| 1456 |
#if 0 |
| 1457 |
if (first_time) { |
| 1458 |
first_time = False; |
| 1459 |
/* This is a hack for finding out wm_x_offset, wm_y_offset */ |
| 1460 |
XMoveWindow(DISP, XtWindow(globals.widgets.top_level), 0, 0); |
| 1461 |
XSync(DISP, False); |
| 1462 |
(void)XTranslateCoordinates(DISP, XtWindow(globals.widgets.top_level), |
| 1463 |
RootWindowOfScreen(SCRN), |
| 1464 |
0, 0, &wm_x_offset, &wm_y_offset, |
| 1465 |
&dummy); |
| 1466 |
fprintf(stderr, "wm offset = (%d,%d)\n", |
| 1467 |
wm_x_offset, wm_y_offset); |
| 1468 |
} |
| 1469 |
x_old -= wm_x_offset; |
| 1470 |
y_old -= wm_y_offset; |
| 1471 |
#endif |
| 1472 |
} |
| 1473 |
|
| 1474 |
x = y = 0; |
| 1475 |
|
| 1476 |
#ifdef MOTIF |
| 1477 |
XtVaGetValues(globals.widgets.top_level, XmNmwmDecorations, &save_wm_decorations, NULL); |
| 1478 |
/* FIXME: this doesn't work e.g. with KDE */ |
| 1479 |
XtVaSetValues(globals.widgets.top_level, |
| 1480 |
XmNmwmDecorations, 0, |
| 1481 |
XmNgeometry, "+0+0", |
| 1482 |
NULL); |
| 1483 |
XtVaSetValues(globals.widgets.main_window, XmNshadowThickness, 0, NULL); |
| 1484 |
#else |
| 1485 |
MWMHints.decorations = 0; |
| 1486 |
if (WM_HINTS != None) { |
| 1487 |
XChangeProperty(DISP, XtWindow(globals.widgets.top_level), |
| 1488 |
WM_HINTS, WM_HINTS, 32, |
| 1489 |
PropModeReplace, (unsigned char *)&MWMHints, |
| 1490 |
sizeof(MWMHints) / 4); |
| 1491 |
} |
| 1492 |
#endif |
| 1493 |
/* SU: apparently some new standard that is supposed to work |
| 1494 |
with some WMs ... but it doesn't with my versions of Gnome and KDE. */ |
| 1495 |
net_wm_toggle_fullscreen(1); |
| 1496 |
|
| 1497 |
#ifdef SIZECONFIGURE_WORKS |
| 1498 |
XConfigureWindow(DISP, XtWindow(globals.widgets.top_level), sizeconfiguremask, &sizeconfigure); |
| 1499 |
#endif /* SIZECONFIGURE_WORKS */ |
| 1500 |
} |
| 1501 |
else { |
| 1502 |
#ifdef SIZECONFIGURE_WORKS |
| 1503 |
sizeconfiguremask = CWWidth | CWHeight | CWX | CWY; |
| 1504 |
sizeconfigure.x = x_old; |
| 1505 |
sizeconfigure.y = y_old; |
| 1506 |
sizeconfigure.border_width = 20; |
| 1507 |
#endif /* SIZECONFIGURE_WORKS */ |
| 1508 |
XtVaSetValues(globals.widgets.top_level, XtNx, x_old, XtNy, y_old, NULL); |
| 1509 |
#ifdef MOTIF |
| 1510 |
XtVaSetValues(globals.widgets.top_level, XmNmwmDecorations, save_wm_decorations, NULL); |
| 1511 |
#if USE_XAW_PANNER |
| 1512 |
XtVaSetValues(globals.widgets.main_window, XmNshadowThickness, g_save_shadow_thickness, NULL); |
| 1513 |
#endif |
| 1514 |
#else |
| 1515 |
MWMHints.decorations = MWM_DECOR_ALL; |
| 1516 |
if (WM_HINTS != None) { |
| 1517 |
XChangeProperty(DISP, XtWindow(globals.widgets.top_level), |
| 1518 |
WM_HINTS, WM_HINTS, 32, |
| 1519 |
PropModeReplace, (unsigned char *)&MWMHints, |
| 1520 |
sizeof(MWMHints) / 4); |
| 1521 |
} |
| 1522 |
#endif |
| 1523 |
net_wm_toggle_fullscreen(0); |
| 1524 |
|
| 1525 |
x = x_old; |
| 1526 |
y = y_old; |
| 1527 |
} |
| 1528 |
|
| 1529 |
#if 1 |
| 1530 |
#if 0 |
| 1531 |
XUnmapWindow(DISP, XtWindow(globals.widgets.top_level)); |
| 1532 |
#else |
| 1533 |
XWithdrawWindow(DISP, XtWindow(globals.widgets.top_level), XScreenNumberOfScreen(SCRN)); |
| 1534 |
#endif |
| 1535 |
|
| 1536 |
/* Note ZLB: Placing XResizeWindow before XUnmapWindow or after XMapWindow |
| 1537 |
makes the fullscreen window size smaller than the screen size when |
| 1538 |
using `mwm' of Lesstif */ |
| 1539 |
XSetWindowBorderWidth(DISP, XtWindow(globals.widgets.top_level), 0); |
| 1540 |
XResizeWindow(DISP, XtWindow(globals.widgets.top_level), width, height); |
| 1541 |
|
| 1542 |
XMapRaised(DISP, XtWindow(globals.widgets.top_level)); |
| 1543 |
|
| 1544 |
/* Note ZLB: XMapWindow might change the window position with some WMs |
| 1545 |
(like Sawfish), so we place the window position after it's mapped. */ |
| 1546 |
XMoveWindow(DISP, XtWindow(globals.widgets.top_level), x, y); |
| 1547 |
#endif /* 0 */ |
| 1548 |
|
| 1549 |
/* need to redraw the page to avoid artifacts */ |
| 1550 |
globals.ev.flags |= EV_NEWPAGE; |
| 1551 |
XFlush(DISP); |
| 1552 |
} |
| 1553 |
|
| 1554 |
|
| 1555 |
/* |
| 1556 |
* Parse colors from resource.{visited_}link_color, saving them |
| 1557 |
* to g_{visited_}link_color and {visited_}link_pix. |
| 1558 |
*/ |
| 1559 |
static void |
| 1560 |
get_link_colors(Pixel *link_pix, Pixel *visited_link_pix) |
| 1561 |
{ |
| 1562 |
XrmValue from1, from2, to1, to2; |
| 1563 |
|
| 1564 |
XColor exact, approx; |
| 1565 |
double r, g, b; |
| 1566 |
double factor = 65535.0; |
| 1567 |
int ret; |
| 1568 |
|
| 1569 |
/* get rgb values from color for links */ |
| 1570 |
if ((ret = XLookupColor(DISP, G_colormap, |
| 1571 |
resource.link_color, |
| 1572 |
&exact, &approx)) != 0) { |
| 1573 |
} |
| 1574 |
else { |
| 1575 |
XDVI_WARNING((stderr, "XLookupColor failed for resource.link_color \"%s\"\n" |
| 1576 |
"- using fallback color \"%s\".", |
| 1577 |
resource.visited_link_color, LINK_COLOR_FALLBACK)); |
| 1578 |
XLookupColor(DISP, G_colormap, LINK_COLOR_FALLBACK, &exact, &approx); |
| 1579 |
} |
| 1580 |
|
| 1581 |
#if 0 |
| 1582 |
fprintf(stderr, "lookup color for %s returned: %d, %d, %d\n", |
| 1583 |
resource.link_color, exact.red, exact.green, exact.blue); |
| 1584 |
#endif |
| 1585 |
r = exact.red / factor; |
| 1586 |
g = exact.green / factor; |
| 1587 |
b = exact.blue / factor; |
| 1588 |
g_link_color_rgb = xmalloc(strlen("push rgb 0.00 0.00 0.00") + 1); |
| 1589 |
sprintf(g_link_color_rgb, "push rgb %.2f %.2f %.2f", r, g, b); |
| 1590 |
|
| 1591 |
/* same for visited links */ |
| 1592 |
if ((ret = XLookupColor(DISP, G_colormap, |
| 1593 |
resource.visited_link_color, |
| 1594 |
&exact, &approx)) != 0) { |
| 1595 |
} |
| 1596 |
else { |
| 1597 |
XDVI_WARNING((stderr, "XLookupColor failed for resource.visited_link_color \"%s\"\n" |
| 1598 |
"- using fallback color \"%s\".", |
| 1599 |
resource.visited_link_color, VISITED_LINK_COLOR_FALLBACK)); |
| 1600 |
XLookupColor(DISP, G_colormap, VISITED_LINK_COLOR_FALLBACK, &exact, &approx); |
| 1601 |
} |
| 1602 |
|
| 1603 |
#if 0 |
| 1604 |
fprintf(stderr, "lookup color for %s returned: %d, %d, %d\n", |
| 1605 |
resource.visited_link_color, exact.red, exact.green, exact.blue); |
| 1606 |
#endif |
| 1607 |
r = exact.red / factor; |
| 1608 |
g = exact.green / factor; |
| 1609 |
b = exact.blue / factor; |
| 1610 |
g_visited_link_color_rgb = xmalloc(strlen("push rgb 0.00 0.00 0.00") + 1); |
| 1611 |
sprintf(g_visited_link_color_rgb, "push rgb %.2f %.2f %.2f", r, g, b); |
| 1612 |
|
| 1613 |
/* 2nd part: Create CG for the underlines. */ |
| 1614 |
from1.addr = resource.link_color; |
| 1615 |
from1.size = strlen(from1.addr) + 1; |
| 1616 |
to1.addr = (XtPointer)link_pix; |
| 1617 |
to1.size = sizeof(Pixel); |
| 1618 |
if (!XtConvertAndStore(globals.widgets.top_level, XtRString, &from1, XtRPixel, &to1)) { |
| 1619 |
XDVI_WARNING((stderr, "String to pixel conversion failed for resource.link_color \"%s\"\n" |
| 1620 |
"- using fallback color \"%s\".", |
| 1621 |
resource.link_color, LINK_COLOR_FALLBACK)); |
| 1622 |
from1.addr = LINK_COLOR_FALLBACK; |
| 1623 |
from1.size = strlen(from1.addr) + 1; |
| 1624 |
to1.addr = (XtPointer)link_pix; |
| 1625 |
to1.size = sizeof(Pixel); |
| 1626 |
XtConvertAndStore(globals.widgets.top_level, XtRString, &from1, XtRPixel, &to1); |
| 1627 |
} |
| 1628 |
from2.addr = resource.visited_link_color; |
| 1629 |
from2.size = strlen(from2.addr) + 1; |
| 1630 |
to2.addr = (XtPointer)visited_link_pix; |
| 1631 |
to2.size = sizeof(Pixel); |
| 1632 |
if (!XtConvertAndStore(globals.widgets.top_level, XtRString, &from2, XtRPixel, &to2)) { |
| 1633 |
XDVI_WARNING((stderr, "String to pixel conversion failed for resource.visited_link_color \"%s\"\n" |
| 1634 |
"- using fallback color \"%s\".", |
| 1635 |
resource.visited_link_color, VISITED_LINK_COLOR_FALLBACK)); |
| 1636 |
from2.addr = VISITED_LINK_COLOR_FALLBACK; |
| 1637 |
from2.size = strlen(from2.addr) + 1; |
| 1638 |
to2.addr = (XtPointer)visited_link_pix; |
| 1639 |
to2.size = sizeof(Pixel); |
| 1640 |
XtConvertAndStore(globals.widgets.top_level, XtRString, &from2, XtRPixel, &to2); |
| 1641 |
} |
| 1642 |
} |
| 1643 |
|
| 1644 |
/* Widget globals.widgets.main_row, globals.widgets.menu_bar; */ |
| 1645 |
|
| 1646 |
|
| 1647 |
#ifdef MOTIF |
| 1648 |
/* make sure the translations for the drawing area are properly set |
| 1649 |
(Motif 2.x seems to somehow overwrite them somewhere in the |
| 1650 |
initialization phase; bug #610206). |
| 1651 |
*/ |
| 1652 |
void |
| 1653 |
motif_translations_hack(void) |
| 1654 |
{ |
| 1655 |
static XtTranslations xlats = NULL; |
| 1656 |
const char *const translations = \ |
| 1657 |
"<Key>osfPageUp:back-page()\n" |
| 1658 |
"<Key>osfPageDown:forward-page()\n" |
| 1659 |
"Ctrl<Key>osfBeginLine:goto-page(1)\n" |
| 1660 |
"Ctrl<Key>osfEndLine:goto-page()\n" |
| 1661 |
"<Key>osfBeginLine:home-or-top()\n" |
| 1662 |
"<Key>osfEndLine:end-or-bottom()\n" |
| 1663 |
#if 0 |
| 1664 |
/* AFAIK the following don't have any effect with Motif */ |
| 1665 |
#ifdef XK_KP_Left |
| 1666 |
"<Key>KP_Home:home()\n" |
| 1667 |
"<Key>KP_End:down()\n" |
| 1668 |
"<Key>KP_Prior:back-page()\n" |
| 1669 |
"<Key>KP_Next:forward-page()\n" |
| 1670 |
#endif |
| 1671 |
#endif |
| 1672 |
; |
| 1673 |
|
| 1674 |
if (xlats == NULL) { |
| 1675 |
xlats = XtParseTranslationTable(translations); |
| 1676 |
} |
| 1677 |
|
| 1678 |
ASSERT(globals.widgets.clip_widget != NULL, "globals.widgets.clip_widget must have been initialized"); |
| 1679 |
ASSERT(globals.widgets.draw_widget != NULL, "globals.widgets.draw_widget must have been initialized"); |
| 1680 |
XtOverrideTranslations(globals.widgets.clip_widget, xlats); |
| 1681 |
} |
| 1682 |
#endif /* MOTIF */ |
| 1683 |
|
| 1684 |
/* return an empty cursor. Lifted from unclutter.c */ |
| 1685 |
static Cursor |
| 1686 |
h_get_empty_cursor(Display *display, Window root) |
| 1687 |
{ |
| 1688 |
Pixmap cursormask; |
| 1689 |
XGCValues xgc; |
| 1690 |
GC gc; |
| 1691 |
XColor dummycolour; |
| 1692 |
Cursor cursor; |
| 1693 |
|
| 1694 |
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/); |
| 1695 |
xgc.function = GXclear; |
| 1696 |
gc = XCreateGC(display, cursormask, GCFunction, &xgc); |
| 1697 |
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1); |
| 1698 |
dummycolour.pixel = 0; |
| 1699 |
dummycolour.red = 0; |
| 1700 |
dummycolour.flags = 04; |
| 1701 |
cursor = XCreatePixmapCursor(display, |
| 1702 |
cursormask, cursormask, |
| 1703 |
&dummycolour, &dummycolour, |
| 1704 |
0, 0); |
| 1705 |
XFreePixmap(display, cursormask); |
| 1706 |
XFreeGC(display, gc); |
| 1707 |
return cursor; |
| 1708 |
} |
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
static void |
| 1713 |
create_cursors(void) |
| 1714 |
{ |
| 1715 |
XColor bg_Color; |
| 1716 |
Pixmap temp; |
| 1717 |
Pixmap mask; |
| 1718 |
|
| 1719 |
/* first try colors by name, as fix for #804294; fall back on |
| 1720 |
WhitePixelOfScreen() etc. if this fails: |
| 1721 |
*/ |
| 1722 |
if (resource.cr_Pixel != (Pixel)ULONG_MAX) { |
| 1723 |
m_cursor_color.pixel = resource.cr_Pixel; |
| 1724 |
XQueryColor(DISP, G_colormap, &m_cursor_color); |
| 1725 |
} |
| 1726 |
else { |
| 1727 |
if (XParseColor(DISP, G_colormap, "black", &m_cursor_color) == 0) { /* lookup failure */ |
| 1728 |
m_cursor_color.pixel = BlackPixelOfScreen(SCRN); |
| 1729 |
XQueryColor(DISP, G_colormap, &m_cursor_color); |
| 1730 |
} |
| 1731 |
} |
| 1732 |
if (XParseColor(DISP, G_colormap, "white", &bg_Color) == 0) { /* lookup failure */ |
| 1733 |
bg_Color.pixel = WhitePixelOfScreen(SCRN); |
| 1734 |
XQueryColor(DISP, G_colormap, &bg_Color); |
| 1735 |
} |
| 1736 |
|
| 1737 |
/* wait cursor */ |
| 1738 |
globals.cursor.wait = XCreateFontCursor(DISP, XC_watch); |
| 1739 |
|
| 1740 |
if (resource.mouse_mode1_cursor == -1) { /* Use default ready cursor (custom bitmap) */ |
| 1741 |
temp = XCreateBitmapFromData(DISP, RootWindowOfScreen(SCRN), |
| 1742 |
(char *)magglass_bits, |
| 1743 |
magglass_width, magglass_height); |
| 1744 |
mask = XCreateBitmapFromData(DISP, RootWindowOfScreen(SCRN), |
| 1745 |
(char *)magglass_mask_bits, |
| 1746 |
magglass_mask_width, magglass_mask_height); |
| 1747 |
|
| 1748 |
globals.cursor.mode1 = XCreatePixmapCursor(DISP, temp, mask, |
| 1749 |
&m_cursor_color, &bg_Color, |
| 1750 |
magglass_x_hot, magglass_y_hot); |
| 1751 |
XFreePixmap(DISP, temp); |
| 1752 |
XFreePixmap(DISP, mask); |
| 1753 |
} |
| 1754 |
else { |
| 1755 |
globals.cursor.mode1 = XCreateFontCursor(DISP, resource.mouse_mode1_cursor); |
| 1756 |
} |
| 1757 |
|
| 1758 |
globals.cursor.corrupted = XCreateFontCursor(DISP, XC_watch); |
| 1759 |
|
| 1760 |
/* empty cursor */ |
| 1761 |
globals.cursor.empty = h_get_empty_cursor(DISP, RootWindowOfScreen(SCRN)); |
| 1762 |
|
| 1763 |
#if !COLOR |
| 1764 |
XRecolorCursor(DISP, globals.cursor.ready, &m_cursor_color, &bg_Color); |
| 1765 |
XRecolorCursor(DISP, globals.cursor.wait, &m_cursor_color, &bg_Color); |
| 1766 |
#endif |
| 1767 |
/* Cursor when page is paused */ |
| 1768 |
#ifdef VMS |
| 1769 |
temp = XCreateBitmapFromData(DISP, RootWindowOfScreen(SCRN), |
| 1770 |
(char *)hand_bits, hand_width, hand_height); |
| 1771 |
mask = XCreateBitmapFromData(DISP, RootWindowOfScreen(SCRN), |
| 1772 |
(char *)hand_mask_bits, hand_mask_width, hand_mask_height); |
| 1773 |
globals.cursor.pause = XCreatePixmapCursor(DISP, temp, mask, |
| 1774 |
&m_cursor_color, &bg_Color, 6, 6); |
| 1775 |
XFreePixmap(DISP, temp); |
| 1776 |
XFreePixmap(DISP, mask); |
| 1777 |
#else |
| 1778 |
globals.cursor.pause = XCreateFontCursor(DISP, XC_watch); |
| 1779 |
#endif |
| 1780 |
|
| 1781 |
/* cursors indicating dragging direction */ |
| 1782 |
globals.cursor.drag_v = XCreateFontCursor(DISP, XC_sb_v_double_arrow); |
| 1783 |
|
| 1784 |
globals.cursor.drag_h = XCreateFontCursor(DISP, XC_sb_h_double_arrow); |
| 1785 |
|
| 1786 |
globals.cursor.drag_a = XCreateFontCursor(DISP, XC_fleur); |
| 1787 |
|
| 1788 |
#ifdef VMS |
| 1789 |
globals.cursor.link = globals.cursor.ready; |
| 1790 |
globals.cursor.mode2 = globals.cursor.ready; |
| 1791 |
globals.cursor.mode3 = globals.cursor.ready; |
| 1792 |
#else |
| 1793 |
globals.cursor.link = XCreateFontCursor(DISP, XC_hand2); |
| 1794 |
globals.cursor.mode2 = XCreateFontCursor(DISP, resource.mouse_mode2_cursor); |
| 1795 |
globals.cursor.mode3 = XCreateFontCursor(DISP, resource.mouse_mode3_cursor); |
| 1796 |
/* globals.cursor.text = XCreateFontCursor(DISP, XC_tcross); */ |
| 1797 |
#endif |
| 1798 |
} |
| 1799 |
|
| 1800 |
/* Initialize a forward search if the source_position argument is not NULL. */ |
| 1801 |
static void |
| 1802 |
do_forward_search(const char *source_position) |
| 1803 |
{ |
| 1804 |
/* parse the special to expand the filename */ |
| 1805 |
struct src_parsed_special data; |
| 1806 |
char *new_special = NULL; |
| 1807 |
char *expanded_filename = NULL; |
| 1808 |
|
| 1809 |
if (source_position == NULL) /* nothing to do */ |
| 1810 |
return; |
| 1811 |
|
| 1812 |
data.filename_len = 0; |
| 1813 |
data.filename = NULL; |
| 1814 |
|
| 1815 |
src_parse(source_position, strlen(source_position), &data); |
| 1816 |
|
| 1817 |
if (data.filename_len == 0) { /* malformed argument: tell user, and ignore it */ |
| 1818 |
popup_message(globals.widgets.top_level, |
| 1819 |
MSG_ERR, |
| 1820 |
/* helptext */ |
| 1821 |
"The format of the -sourceposition argument should be:\n" |
| 1822 |
"-sourceposition '<nn>[ ]*<filename'\n" |
| 1823 |
"with <nn> = linenumber, [ ]* = an arbitrary number of spaces, " |
| 1824 |
"and <filename> = TeX source file.", |
| 1825 |
/* error message */ |
| 1826 |
"Filename missing in `-sourceposition' argument \"%s\". " |
| 1827 |
"Could not perform forward search.", |
| 1828 |
source_position); |
| 1829 |
} |
| 1830 |
else { |
| 1831 |
TRACE_CLIENT((stderr, "got data: line %d, col %d, file |%s|, len %lu\n", |
| 1832 |
data.line, data.col, data.filename, (unsigned long)data.filename_len)); |
| 1833 |
|
| 1834 |
/* expand -sourceposition argument if it contains a path component, like above */ |
| 1835 |
if (strchr(data.filename, '/') != NULL |
| 1836 |
&& (expanded_filename = expand_filename(data.filename, USE_CWD_PATH)) != NULL) { |
| 1837 |
char *tmp = canonicalize_path(expanded_filename); |
| 1838 |
free(data.filename); |
| 1839 |
free(expanded_filename); |
| 1840 |
expanded_filename = tmp; |
| 1841 |
} |
| 1842 |
else |
| 1843 |
expanded_filename = data.filename; |
| 1844 |
|
| 1845 |
TRACE_CLIENT((stderr, "expanded source_position: |%s|\n", expanded_filename)); |
| 1846 |
|
| 1847 |
new_special = xmalloc(2 * LENGTH_OF_INT + 2 /* 2 for `:' and separating space */ |
| 1848 |
+ strlen(expanded_filename) + 1); |
| 1849 |
sprintf(new_special, "%d:%d %s", data.line, data.col, expanded_filename); |
| 1850 |
free(expanded_filename); |
| 1851 |
globals.src.fwd_string = new_special; |
| 1852 |
globals.ev.flags |= EV_SRC; |
| 1853 |
} |
| 1854 |
} |
| 1855 |
|
| 1856 |
|
| 1857 |
/* |
| 1858 |
* Routines for compile_mouse_actions |
| 1859 |
*/ |
| 1860 |
|
| 1861 |
struct modifierinf { |
| 1862 |
int len; |
| 1863 |
const char *name; |
| 1864 |
Modifiers mask; |
| 1865 |
KeySym keysym; |
| 1866 |
}; |
| 1867 |
|
| 1868 |
/* Allowed modifiers, sorted by length and then lexicographically. */ |
| 1869 |
|
| 1870 |
static struct modifierinf modifiers[] = { |
| 1871 |
{1, "a", 0, XK_Alt_L}, |
| 1872 |
{1, "c", ControlMask, 0}, |
| 1873 |
{1, "h", 0, XK_Hyper_L}, |
| 1874 |
{1, "l", LockMask, 0}, |
| 1875 |
{1, "m", 0, XK_Meta_L}, |
| 1876 |
{1, "s", ShiftMask, 0}, |
| 1877 |
{2, "su", 0, XK_Super_L}, |
| 1878 |
{3, "Alt", 0, XK_Alt_L}, |
| 1879 |
{4, "Ctrl", ControlMask, 0}, |
| 1880 |
{4, "Lock", LockMask, 0}, |
| 1881 |
{4, "Meta", 0, XK_Meta_L}, |
| 1882 |
{4, "Mod1", Mod1Mask, 0}, |
| 1883 |
{4, "Mod2", Mod2Mask, 0}, |
| 1884 |
{4, "Mod3", Mod3Mask, 0}, |
| 1885 |
{4, "Mod4", Mod4Mask, 0}, |
| 1886 |
{4, "Mod5", Mod5Mask, 0}, |
| 1887 |
{5, "Hyper", 0, XK_Hyper_L}, |
| 1888 |
{5, "Shift", ShiftMask, 0}, |
| 1889 |
{5, "Super", 0, XK_Super_L}, |
| 1890 |
{7, "Button1", Button1Mask, 0}, |
| 1891 |
{7, "Button2", Button2Mask, 0}, |
| 1892 |
{7, "Button3", Button3Mask, 0}, |
| 1893 |
{7, "Button4", Button4Mask, 0}, |
| 1894 |
{7, "Button5", Button5Mask, 0}, |
| 1895 |
}; |
| 1896 |
|
| 1897 |
#define MODSCTRLINDEX 1 /* index of "c" in the above array */ |
| 1898 |
#define MODSMETAINDEX 4 /* index of "m" */ |
| 1899 |
|
| 1900 |
|
| 1901 |
static Boolean |
| 1902 |
compile_modifiers(const char **pp, struct mouse_acts *mactp) |
| 1903 |
{ |
| 1904 |
const char *p = *pp; |
| 1905 |
const char *p1; |
| 1906 |
LateBindingsPtr latep = NULL; |
| 1907 |
int nlate = 3; |
| 1908 |
|
| 1909 |
while (*p == ' ' || *p == '\t') |
| 1910 |
++p; |
| 1911 |
|
| 1912 |
p1 = p; |
| 1913 |
while (isalpha((int) *p1)) |
| 1914 |
++p1; |
| 1915 |
|
| 1916 |
if (p1 - p == 3 && memcmp(p, "Any", 3) == 0) { |
| 1917 |
mactp->mask = mactp->value = 0; |
| 1918 |
p = p1; |
| 1919 |
while (*p == ' ' || *p == '\t') |
| 1920 |
++p; |
| 1921 |
if (*p != '<') |
| 1922 |
return False; |
| 1923 |
} |
| 1924 |
else if (p1 - p == 4 && memcmp(p, "None", 4) == 0) { |
| 1925 |
mactp->mask = ~0; |
| 1926 |
mactp->value = 0; |
| 1927 |
p = p1; |
| 1928 |
while (*p == ' ' || *p == '\t') |
| 1929 |
++p; |
| 1930 |
if (*p != '<') |
| 1931 |
return False; |
| 1932 |
} |
| 1933 |
else { |
| 1934 |
if (*p == '!') { |
| 1935 |
do { |
| 1936 |
++p; |
| 1937 |
} while (*p == ' ' || *p == '\t'); |
| 1938 |
} |
| 1939 |
|
| 1940 |
for (;;) { |
| 1941 |
Boolean negated = False; |
| 1942 |
struct modifierinf *mp; |
| 1943 |
|
| 1944 |
if (*p == '<') |
| 1945 |
break; |
| 1946 |
|
| 1947 |
if (*p == '~') { |
| 1948 |
negated = True; |
| 1949 |
++p; |
| 1950 |
} |
| 1951 |
|
| 1952 |
if (*p == '^') { |
| 1953 |
mp = &modifiers[MODSCTRLINDEX]; |
| 1954 |
++p; |
| 1955 |
} |
| 1956 |
else if (*p == '$') { |
| 1957 |
mp = &modifiers[MODSMETAINDEX]; |
| 1958 |
++p; |
| 1959 |
} |
| 1960 |
else { |
| 1961 |
int min, max; |
| 1962 |
|
| 1963 |
p1 = p; |
| 1964 |
while (isalnum((int) *p)) |
| 1965 |
++p; |
| 1966 |
|
| 1967 |
/* do binary search */ |
| 1968 |
min = -1; |
| 1969 |
max = XtNumber(modifiers); |
| 1970 |
for (;;) { |
| 1971 |
int i, diff; |
| 1972 |
|
| 1973 |
i = (min + max) / 2; |
| 1974 |
if (i == min) |
| 1975 |
return False; /* if not found */ |
| 1976 |
mp = &modifiers[i]; |
| 1977 |
|
| 1978 |
diff = (p - p1) - mp->len; |
| 1979 |
if (diff == 0) |
| 1980 |
diff = memcmp(p1, mp->name, p - p1); |
| 1981 |
|
| 1982 |
if (diff == 0) |
| 1983 |
break; |
| 1984 |
if (diff > 0) min = i; |
| 1985 |
else max = i; |
| 1986 |
} |
| 1987 |
} |
| 1988 |
if (mp->mask) { |
| 1989 |
mactp->mask |= mp->mask; |
| 1990 |
if (!negated) mactp->value |= mp->mask; |
| 1991 |
} |
| 1992 |
else { |
| 1993 |
LateBindingsPtr lp1; |
| 1994 |
|
| 1995 |
if (latep == NULL) { |
| 1996 |
/* nlate = 3; (done earlier to avoid compiler warning) */ |
| 1997 |
latep = xmalloc(3 * sizeof(LateBindings)); |
| 1998 |
latep->ref_count = 1; |
| 1999 |
} |
| 2000 |
else { |
| 2001 |
nlate += 2; |
| 2002 |
latep = xrealloc(latep, nlate * sizeof(LateBindings)); |
| 2003 |
} |
| 2004 |
lp1 = &latep[nlate - 3]; |
| 2005 |
lp1->knot = lp1[1].knot = negated; |
| 2006 |
lp1->pair = True; |
| 2007 |
lp1->keysym = mp->keysym; |
| 2008 |
++lp1; |
| 2009 |
lp1->pair = False; |
| 2010 |
lp1->ref_count = 0; |
| 2011 |
lp1->keysym = mp->keysym + 1; |
| 2012 |
++lp1; |
| 2013 |
lp1->knot = lp1->pair = False; |
| 2014 |
lp1->ref_count = 0; |
| 2015 |
lp1->keysym = 0; |
| 2016 |
} |
| 2017 |
|
| 2018 |
while (*p == ' ' || *p == '\t') |
| 2019 |
++p; |
| 2020 |
} |
| 2021 |
} |
| 2022 |
|
| 2023 |
mactp->late_bindings = latep; |
| 2024 |
*pp = p; |
| 2025 |
|
| 2026 |
return True; |
| 2027 |
} |
| 2028 |
|
| 2029 |
static Boolean |
| 2030 |
compile_evtype(const char **pp, unsigned int *buttonp) |
| 2031 |
{ |
| 2032 |
const char *p = *pp; |
| 2033 |
const char *p0; |
| 2034 |
|
| 2035 |
++p; /* already assumed to be '<' */ |
| 2036 |
while (*p == ' ' || *p == '\t') |
| 2037 |
++p; |
| 2038 |
|
| 2039 |
p0 = p; |
| 2040 |
while (isalpha((int) *p) && p - p0 < 3) |
| 2041 |
++p; |
| 2042 |
|
| 2043 |
if (p - p0 != 3 || memcmp(p0, "Btn", 3) != 0) |
| 2044 |
return False; |
| 2045 |
|
| 2046 |
if (*p >= '1' && *p <= '9') { |
| 2047 |
unsigned int n = *p - '0'; |
| 2048 |
|
| 2049 |
while (*++p >= '0' && *p <= '9') |
| 2050 |
n = n * 10 + (*p - '0'); |
| 2051 |
|
| 2052 |
*buttonp = n; |
| 2053 |
} |
| 2054 |
|
| 2055 |
p0 = p; |
| 2056 |
while (isalpha((int) *p)) |
| 2057 |
++p; |
| 2058 |
|
| 2059 |
if (p - p0 != 4 || memcmp(p0, "Down", 4) != 0) |
| 2060 |
return False; |
| 2061 |
|
| 2062 |
while (*p == ' ' || *p == '\t') |
| 2063 |
++p; |
| 2064 |
|
| 2065 |
if (*p++ != '>') |
| 2066 |
return False; |
| 2067 |
|
| 2068 |
while (*p == ' ' || *p == '\t') |
| 2069 |
++p; |
| 2070 |
|
| 2071 |
if (*p++ != ':') |
| 2072 |
return False; |
| 2073 |
|
| 2074 |
*pp = p; |
| 2075 |
|
| 2076 |
return True; |
| 2077 |
} |
| 2078 |
|
| 2079 |
static void |
| 2080 |
compile_mouse_actions(void) |
| 2081 |
{ |
| 2082 |
struct mouse_acts **mactpp; |
| 2083 |
struct mouse_acts *mactp; |
| 2084 |
const char *p = resource.mouse_translations; |
| 2085 |
const char *p_end; |
| 2086 |
const char *p_base = base_mouse_translations; |
| 2087 |
struct mouse_acts mact; |
| 2088 |
|
| 2089 |
mactpp = &mouse_actions; |
| 2090 |
|
| 2091 |
if (p == NULL) { |
| 2092 |
p = p_base; |
| 2093 |
p_base = NULL; |
| 2094 |
} |
| 2095 |
|
| 2096 |
do { /* loop over translations strings */ |
| 2097 |
p_end = p + strlen(p); |
| 2098 |
for (;;) { |
| 2099 |
while (*p == ' ' || *p == '\t') |
| 2100 |
++p; |
| 2101 |
|
| 2102 |
if (*p == '\n') continue; |
| 2103 |
if (*p == '\0') break; |
| 2104 |
|
| 2105 |
mact.mask = mact.value = 0; |
| 2106 |
mact.button = 0; |
| 2107 |
|
| 2108 |
if (!compile_modifiers(&p, &mact) |
| 2109 |
|| !compile_evtype(&p, &mact.button)) { |
| 2110 |
XDVI_WARNING((stderr, "syntax error in wheel translations")); |
| 2111 |
} |
| 2112 |
else if (compile_action(p, &mact.action) || mact.action != NULL) { |
| 2113 |
mactp = xmalloc(sizeof(struct mouse_acts)); |
| 2114 |
*mactp = mact; |
| 2115 |
|
| 2116 |
*mactpp = mactp; |
| 2117 |
mactpp = &mactp->next; |
| 2118 |
} |
| 2119 |
|
| 2120 |
p = memchr(p, '\n', p_end - p); |
| 2121 |
if (p == NULL) break; |
| 2122 |
++p; |
| 2123 |
} |
| 2124 |
|
| 2125 |
p = p_base; |
| 2126 |
p_base = NULL; |
| 2127 |
} |
| 2128 |
while (p != NULL); |
| 2129 |
|
| 2130 |
*mactpp = NULL; |
| 2131 |
} |
| 2132 |
|
| 2133 |
|
| 2134 |
#if HAVE_XI21 |
| 2135 |
|
| 2136 |
void |
| 2137 |
xi2_init_valuators(struct xi2_slave *sp, XIAnyClassInfo **classes, |
| 2138 |
int num_classes) |
| 2139 |
{ |
| 2140 |
unsigned int flags; |
| 2141 |
int i; |
| 2142 |
|
| 2143 |
sp->flags = flags = 0; |
| 2144 |
sp->btn_mask = 0; |
| 2145 |
sp->vert.number = sp->horiz.number = -1; |
| 2146 |
|
| 2147 |
for (i = 0; i < num_classes; ++i) |
| 2148 |
if (classes[i]->type == XIScrollClass) { |
| 2149 |
XIScrollClassInfo *scroll = (XIScrollClassInfo *) classes[i]; |
| 2150 |
|
| 2151 |
if (scroll->scroll_type == XIScrollTypeVertical) { |
| 2152 |
sp->vert.number = scroll->number; |
| 2153 |
sp->vert.increment = scroll->increment; |
| 2154 |
flags |= XI2_SLAVE_VERT; |
| 2155 |
} |
| 2156 |
else if (scroll->scroll_type == XIScrollTypeHorizontal) { |
| 2157 |
sp->horiz.number = scroll->number; |
| 2158 |
sp->horiz.increment = scroll->increment; |
| 2159 |
flags |= XI2_SLAVE_HORIZ; |
| 2160 |
} |
| 2161 |
} |
| 2162 |
|
| 2163 |
if (flags == 0) { |
| 2164 |
TRACE_EVENTS((stderr, |
| 2165 |
"No scroll valuators found for slave device %d", sp->id)); |
| 2166 |
return; |
| 2167 |
} |
| 2168 |
|
| 2169 |
TRACE_EVENTS((stderr, |
| 2170 |
"Found XI2 device %d with one or more scroll valuators:", sp->id)); |
| 2171 |
if (flags & XI2_SLAVE_VERT) |
| 2172 |
TRACE_EVENTS((stderr, " Vertical valuator %d has increment %.2f", |
| 2173 |
sp->vert.number, sp->vert.increment)); |
| 2174 |
if (flags & XI2_SLAVE_HORIZ) |
| 2175 |
TRACE_EVENTS((stderr, " Horizontal valuator %d has increment %.2f", |
| 2176 |
sp->horiz.number, sp->horiz.increment)); |
| 2177 |
|
| 2178 |
for (i = 0; i < num_classes; ++i) |
| 2179 |
if (classes[i]->type == XIValuatorClass) { |
| 2180 |
XIValuatorClassInfo *valuator; |
| 2181 |
valuator = (XIValuatorClassInfo *) classes[i]; |
| 2182 |
|
| 2183 |
/* The min and max fields have been seen to be 0 and -1, */ |
| 2184 |
/* respectively (what do those mean)? */ |
| 2185 |
if (flags & XI2_SLAVE_VERT |
| 2186 |
&& valuator->number == sp->vert.number) { |
| 2187 |
sp->vert.lastval = valuator->value; |
| 2188 |
sp->vert.lastexact = valuator->value; |
| 2189 |
sp->vert.factor = 0; |
| 2190 |
sp->vert.serial = LastKnownRequestProcessed(DISP); |
| 2191 |
sp->flags |= XI2_SLAVE_VERT; |
| 2192 |
sp->btn_mask |= (1<<4) | (1<<5); |
| 2193 |
} |
| 2194 |
else if (flags & XI2_SLAVE_HORIZ |
| 2195 |
&& valuator->number == sp->horiz.number) { |
| 2196 |
sp->horiz.lastval = valuator->value; |
| 2197 |
sp->horiz.lastexact = valuator->value; |
| 2198 |
sp->horiz.factor = 0; |
| 2199 |
sp->horiz.serial = LastKnownRequestProcessed(DISP); |
| 2200 |
sp->flags |= XI2_SLAVE_HORIZ; |
| 2201 |
sp->btn_mask |= (1<<6) | (1<<7); |
| 2202 |
} |
| 2203 |
} |
| 2204 |
|
| 2205 |
if (sp->flags != flags) |
| 2206 |
TRACE_EVENTS((stderr, |
| 2207 |
"For slave device %d, valuator class(es) missing (%x vs. %x)", |
| 2208 |
sp->id, sp->flags, flags)); |
| 2209 |
} |
| 2210 |
|
| 2211 |
void |
| 2212 |
xi2_activate(void) |
| 2213 |
{ |
| 2214 |
XIEventMask eventmask; |
| 2215 |
unsigned char mask[2] = {0, 0}; /* the actual event mask */ |
| 2216 |
struct xi2_master *mp; |
| 2217 |
|
| 2218 |
mask[0] = mask[1] = 0; |
| 2219 |
eventmask.mask = mask; |
| 2220 |
eventmask.mask_len = sizeof mask; |
| 2221 |
XISetMask(mask, XI_Motion); |
| 2222 |
XISetMask(mask, XI_Enter); |
| 2223 |
|
| 2224 |
for (mp = xi2_masters; mp != NULL; mp = mp->next) { |
| 2225 |
eventmask.deviceid = mp->id; |
| 2226 |
XISelectEvents(DISP, XtWindow(globals.widgets.draw_widget), |
| 2227 |
&eventmask, 1); |
| 2228 |
# if MOTIF |
| 2229 |
XISelectEvents(DISP, XtWindow(globals.widgets.clip_widget), |
| 2230 |
&eventmask, 1); |
| 2231 |
# endif |
| 2232 |
} |
| 2233 |
|
| 2234 |
xi2_active = True; |
| 2235 |
xi2_current = xi2_masters; /* this is just an optimization */ |
| 2236 |
} |
| 2237 |
|
| 2238 |
static void |
| 2239 |
xi2_init(void) |
| 2240 |
{ |
| 2241 |
int event, error; |
| 2242 |
int major, minor; |
| 2243 |
XIEventMask eventmask; |
| 2244 |
unsigned char mask[2] = {0, 0}; /* the actual event mask */ |
| 2245 |
XIDeviceInfo *info; |
| 2246 |
int ndevices; |
| 2247 |
struct xi2_master **mpp; |
| 2248 |
struct xi2_master *mp; |
| 2249 |
struct xi2_slave **spp; |
| 2250 |
struct xi2_slave *sp; |
| 2251 |
unsigned int all_flags; |
| 2252 |
int i; |
| 2253 |
|
| 2254 |
/* Check for user turning it off */ |
| 2255 |
|
| 2256 |
if (!resource.xi2scrolling) { |
| 2257 |
TRACE_EVENTS((stderr, |
| 2258 |
"X Input extension turned off at user request.")); |
| 2259 |
return; |
| 2260 |
} |
| 2261 |
|
| 2262 |
/* Check for extension */ |
| 2263 |
|
| 2264 |
if (!XQueryExtension(DISP, "XInputExtension", &xi2_opcode, &event, |
| 2265 |
&error)) { |
| 2266 |
TRACE_EVENTS((stderr, "X Input extension not available.")); |
| 2267 |
return; |
| 2268 |
} |
| 2269 |
|
| 2270 |
/* Check XI2 version number */ |
| 2271 |
major = 2; |
| 2272 |
minor = 1; |
| 2273 |
if (XIQueryVersion(DISP, &major, &minor) == BadRequest) { |
| 2274 |
TRACE_EVENTS((stderr, "XI2 not available.")); |
| 2275 |
return; |
| 2276 |
} |
| 2277 |
if (major == 2 && minor < 1) { |
| 2278 |
TRACE_EVENTS((stderr, "XI2 version 2.1 is not supported.")); |
| 2279 |
return; |
| 2280 |
} |
| 2281 |
|
| 2282 |
TRACE_EVENTS((stderr, "Found XI2 extension version %d.%d.", |
| 2283 |
major, minor)); |
| 2284 |
|
| 2285 |
XISetMask(mask, XI_HierarchyChanged); |
| 2286 |
XISetMask(mask, XI_DeviceChanged); |
| 2287 |
eventmask.deviceid = XIAllDevices; |
| 2288 |
eventmask.mask_len = sizeof(mask); |
| 2289 |
eventmask.mask = mask; |
| 2290 |
|
| 2291 |
XISelectEvents(DISP, DefaultRootWindow(DISP), &eventmask, 1); |
| 2292 |
|
| 2293 |
info = XIQueryDevice(DISP, XIAllDevices, &ndevices); |
| 2294 |
|
| 2295 |
# if XIAllDevices != 0 |
| 2296 |
xi2_no_slave.id = XIAllDevices; |
| 2297 |
# endif |
| 2298 |
|
| 2299 |
/* Find slave devices */ |
| 2300 |
|
| 2301 |
all_flags = 0; |
| 2302 |
spp = &xi2_slaves; /* link for next slave device */ |
| 2303 |
|
| 2304 |
for (i = 0; i < ndevices; ++i) |
| 2305 |
if (info[i].use == XISlavePointer || info[i].use == XIFloatingSlave) |
| 2306 |
{ |
| 2307 |
sp = xmalloc(sizeof (struct xi2_slave)); |
| 2308 |
sp->id = info[i].deviceid; |
| 2309 |
sp->enabled = info[i].enabled; |
| 2310 |
xi2_init_valuators(sp, info[i].classes, info[i].num_classes); |
| 2311 |
all_flags |= sp->flags; |
| 2312 |
*spp = sp; |
| 2313 |
spp = &sp->next; |
| 2314 |
} |
| 2315 |
*spp = NULL; |
| 2316 |
|
| 2317 |
/* Find master devices */ |
| 2318 |
|
| 2319 |
mpp = &xi2_masters; /* link for next master device */ |
| 2320 |
|
| 2321 |
for (i = 0; i < ndevices; ++i) |
| 2322 |
if (info[i].use == XIMasterPointer |
| 2323 |
|| info[i].use == XIMasterKeyboard) { |
| 2324 |
mp = xmalloc(sizeof (struct xi2_master)); |
| 2325 |
mp->id = info[i].deviceid; |
| 2326 |
mp->slave = &xi2_no_slave; |
| 2327 |
*mpp = mp; |
| 2328 |
mpp = &mp->next; |
| 2329 |
} |
| 2330 |
*mpp = NULL; |
| 2331 |
|
| 2332 |
XIFreeDeviceInfo(info); |
| 2333 |
|
| 2334 |
if (xi2_masters == NULL) { |
| 2335 |
TRACE_EVENTS((stderr, |
| 2336 |
"No master pointers found (!!); not using XI2.")); |
| 2337 |
return; |
| 2338 |
} |
| 2339 |
|
| 2340 |
if (!all_flags) { |
| 2341 |
TRACE_EVENTS((stderr, |
| 2342 |
"No scroll valuators found; not using XI2 (for now).")); |
| 2343 |
return; |
| 2344 |
} |
| 2345 |
|
| 2346 |
xi2_activate(); |
| 2347 |
} |
| 2348 |
|
| 2349 |
#endif /* HAVE_XI21 */ |
| 2350 |
|
| 2351 |
|
| 2352 |
static void |
| 2353 |
create_colormaps(void) |
| 2354 |
{ |
| 2355 |
#ifdef GREY |
| 2356 |
G_depth = (unsigned int)DefaultDepthOfScreen(SCRN); |
| 2357 |
G_visual = DefaultVisualOfScreen(SCRN); |
| 2358 |
G_colormap = DefaultColormapOfScreen(SCRN); |
| 2359 |
#ifdef XSERVER_INFO |
| 2360 |
if (globals.debug & DBG_ALL) |
| 2361 |
fprintf(stdout, "--- G_depth: %d\n", G_depth); |
| 2362 |
#endif |
| 2363 |
|
| 2364 |
if (resource.install != False && G_visual->class == PseudoColor) { |
| 2365 |
/* look for a TrueColor visual with more bits */ |
| 2366 |
XVisualInfo template; |
| 2367 |
XVisualInfo *list; |
| 2368 |
int nitems_return; |
| 2369 |
#ifdef XSERVER_INFO |
| 2370 |
if (globals.debug & DBG_ALL) |
| 2371 |
fprintf(stdout, "--- looking for a better TrueColor visual\n"); |
| 2372 |
#endif |
| 2373 |
|
| 2374 |
template.screen = XScreenNumberOfScreen(SCRN); |
| 2375 |
template.class = TrueColor; |
| 2376 |
list = XGetVisualInfo(DISP, VisualScreenMask | VisualClassMask, |
| 2377 |
&template, &nitems_return); |
| 2378 |
if (list != NULL) { |
| 2379 |
XVisualInfo *list1; |
| 2380 |
XVisualInfo *best = NULL; |
| 2381 |
|
| 2382 |
for (list1 = list; list1 < list + nitems_return; ++list1) { |
| 2383 |
#ifdef XSERVER_INFO |
| 2384 |
if (globals.debug & DBG_ALL) |
| 2385 |
fprintf(stdout, "--- checking %d\n", list1->depth); |
| 2386 |
#endif |
| 2387 |
if ((unsigned int)list1->depth > G_depth |
| 2388 |
# if PS_GS |
| 2389 |
/* patch by Toni Ronkko <[email protected]>, fixes bug #458057: |
| 2390 |
* SGI supports additional depths of 12 and 30, but |
| 2391 |
* these are not supported by ghostscript (see |
| 2392 |
* xdev->vinfo->depth in gdevxcmp.c (ghostscript-6.51)), |
| 2393 |
* so we restrict the values to those supported by gs. |
| 2394 |
*/ |
| 2395 |
&& (list1->depth == 1 || list1->depth == 2 |
| 2396 |
|| list1->depth == 4 || list1->depth == 8 |
| 2397 |
|| list1->depth == 15 || list1->depth == 16 |
| 2398 |
|| list1->depth == 24 || list1->depth == 32) |
| 2399 |
# endif |
| 2400 |
&& (best == NULL || list1->depth > best->depth)) |
| 2401 |
best = list1; |
| 2402 |
} |
| 2403 |
if (best != NULL) { |
| 2404 |
#ifdef XSERVER_INFO |
| 2405 |
if (globals.debug & DBG_ALL) |
| 2406 |
fprintf(stdout, "--- best depth: %d\n", best->depth); |
| 2407 |
#endif |
| 2408 |
G_depth = best->depth; |
| 2409 |
G_visual = best->visual; |
| 2410 |
G_colormap = XCreateColormap(DISP, |
| 2411 |
RootWindowOfScreen(SCRN), |
| 2412 |
G_visual, AllocNone); |
| 2413 |
XInstallColormap(DISP, G_colormap); |
| 2414 |
temp_args1[0].value = (XtArgVal) G_depth; |
| 2415 |
temp_args1[1].value = (XtArgVal) G_visual; |
| 2416 |
temp_args1[2].value = (XtArgVal) G_colormap; |
| 2417 |
XtSetValues(globals.widgets.top_level, temp_args1, XtNumber(temp_args1)); |
| 2418 |
XtSetTypeConverter(XtRString, XtRPixel, |
| 2419 |
XdviCvtStringToPixel, |
| 2420 |
(XtConvertArgList) colorConvertArgs, 2, |
| 2421 |
XtCacheByDisplay, NULL); |
| 2422 |
{ |
| 2423 |
/* This is needed so that popup windows have the right |
| 2424 |
visual and colormap. It is unnecessary for newer |
| 2425 |
versions of Motif (Motif 2.1.0, Solaris 9) but |
| 2426 |
needed for older versions (Motif 1.2.5, Solaris 2.6), |
| 2427 |
and for Xaw. |
| 2428 |
*/ |
| 2429 |
XrmDatabase db = XtScreenDatabase(SCRN); |
| 2430 |
XrmValue val; |
| 2431 |
|
| 2432 |
val.size = sizeof G_visual; |
| 2433 |
val.addr = (XtPointer) &G_visual; |
| 2434 |
XrmPutResource(&db, "XDvi*visual", XtRVisual, &val); |
| 2435 |
|
| 2436 |
val.size = sizeof G_colormap; |
| 2437 |
val.addr = (XtPointer) &G_colormap; |
| 2438 |
XrmPutResource(&db, "XDvi*colormap", XtRColormap, &val); |
| 2439 |
} |
| 2440 |
} |
| 2441 |
XFree(list); |
| 2442 |
} |
| 2443 |
} |
| 2444 |
|
| 2445 |
#ifdef MOTIF |
| 2446 |
if (globals.debug & DBG_GUI) { |
| 2447 |
printf("Compiled with %s, runtime version %d.%d\n", |
| 2448 |
/* XmVERSION, XmREVISION, XmUPDATE_LEVEL, */ |
| 2449 |
XmVERSION_STRING, |
| 2450 |
xmUseVersion / 1000, xmUseVersion % 1000); |
| 2451 |
} |
| 2452 |
#endif |
| 2453 |
|
| 2454 |
if (resource.install == True && G_visual->class == PseudoColor) { |
| 2455 |
XColor tmp_color; |
| 2456 |
#ifdef XSERVER_INFO |
| 2457 |
if (globals.debug & DBG_ALL) |
| 2458 |
fprintf(stdout, "--- PseudoColor, trying to install colormap\n"); |
| 2459 |
#endif |
| 2460 |
|
| 2461 |
/* This next bit makes sure that the standard black and white pixels |
| 2462 |
are allocated in the new colormap. */ |
| 2463 |
tmp_color.pixel = BlackPixelOfScreen(SCRN); |
| 2464 |
XQueryColor(DISP, G_colormap, &tmp_color); |
| 2465 |
XAllocColor(DISP, G_colormap, &tmp_color); |
| 2466 |
|
| 2467 |
tmp_color.pixel = WhitePixelOfScreen(SCRN); |
| 2468 |
XQueryColor(DISP, G_colormap, &tmp_color); |
| 2469 |
XAllocColor(DISP, G_colormap, &tmp_color); |
| 2470 |
|
| 2471 |
G_colormap = XCopyColormapAndFree(DISP, G_colormap); |
| 2472 |
temp_args1[2].value = (XtArgVal) G_colormap; |
| 2473 |
XtSetValues(globals.widgets.top_level, temp_args1 + 2, 1); |
| 2474 |
} |
| 2475 |
|
| 2476 |
XtGetApplicationResources(globals.widgets.top_level, (XtPointer)&resource, |
| 2477 |
app_pixel_resources, XtNumber(app_pixel_resources), |
| 2478 |
(ArgList)NULL, 0); |
| 2479 |
|
| 2480 |
#endif /* GREY */ |
| 2481 |
|
| 2482 |
globals.gc.do_copy = resource.copy; |
| 2483 |
|
| 2484 |
#if GREY || COLOR |
| 2485 |
color_data[0].pixel = resource.fore_Pixel; |
| 2486 |
color_data[1].pixel = resource.back_Pixel; |
| 2487 |
XQueryColors(DISP, G_colormap, color_data, 2); |
| 2488 |
#endif |
| 2489 |
|
| 2490 |
#if COLOR |
| 2491 |
fg_initial.r = color_data[0].red; |
| 2492 |
fg_initial.g = color_data[0].green; |
| 2493 |
fg_initial.b = color_data[0].blue; |
| 2494 |
bg_initial.r = color_data[1].red; |
| 2495 |
bg_initial.g = color_data[1].green; |
| 2496 |
bg_initial.b = color_data[1].blue; |
| 2497 |
|
| 2498 |
#endif |
| 2499 |
|
| 2500 |
#if GREY |
| 2501 |
if (G_depth == 1) { |
| 2502 |
#ifdef XSERVER_INFO |
| 2503 |
if (globals.debug & DBG_ALL) |
| 2504 |
fprintf(stdout, "--- using depth 1\n"); |
| 2505 |
#endif |
| 2506 |
resource.use_grey = False; |
| 2507 |
} |
| 2508 |
if (resource.use_grey && G_visual->class != TrueColor) { |
| 2509 |
#ifdef XSERVER_INFO |
| 2510 |
if (globals.debug & DBG_ALL) |
| 2511 |
fprintf(stdout, "--- using grey, but not TrueColor\n"); |
| 2512 |
#endif |
| 2513 |
init_plane_masks(); |
| 2514 |
if (!globals.gc.do_copy) { |
| 2515 |
/* Retain color_data[1].pixel for psgs.c. */ |
| 2516 |
XColor tmp_color; |
| 2517 |
#ifdef XSERVER_INFO |
| 2518 |
if (globals.debug & DBG_ALL) |
| 2519 |
fprintf(stdout, "--- not using copy\n"); |
| 2520 |
#endif |
| 2521 |
|
| 2522 |
tmp_color = color_data[1]; |
| 2523 |
tmp_color.pixel = resource.back_Pixel; |
| 2524 |
XStoreColor(DISP, G_colormap, &tmp_color); |
| 2525 |
} |
| 2526 |
} |
| 2527 |
#endif |
| 2528 |
} |
| 2529 |
|
| 2530 |
static void |
| 2531 |
create_widgets( |
| 2532 |
#ifdef MOTIF |
| 2533 |
Widget tool_bar, Widget form, |
| 2534 |
#endif |
| 2535 |
int *add_w, int *add_h) |
| 2536 |
{ |
| 2537 |
|
| 2538 |
#ifdef MOTIF |
| 2539 |
Widget status_line; |
| 2540 |
|
| 2541 |
#if 0 |
| 2542 |
{ |
| 2543 |
int i, n, longest_page = 0; |
| 2544 |
Dimension width, height; |
| 2545 |
char tmpbuf[1024]; |
| 2546 |
char *fontname; |
| 2547 |
XmString tmpstring; |
| 2548 |
Widget dummy_list; |
| 2549 |
XmRendition rendition; |
| 2550 |
XmRenderTable rtable; |
| 2551 |
Arg args[10]; |
| 2552 |
/* |
| 2553 |
* Try to determine width of longest page string: |
| 2554 |
*/ |
| 2555 |
for (i = 0; i < total_pages; i++) { |
| 2556 |
int curr = abs(pageinfo_get_number(i)); |
| 2557 |
if (curr > longest_page) |
| 2558 |
longest_page = curr; |
| 2559 |
} |
| 2560 |
fprintf(stderr, "longest page number: %d\n", longest_page); |
| 2561 |
sprintf(tmpbuf, "* %d", longest_page); |
| 2562 |
tmpstring = XmStringCreateLocalized(tmpbuf); |
| 2563 |
dummy_list = XtCreateWidget("PageList", xmListWidgetClass, form, NULL, 0); |
| 2564 |
fprintf(stderr, "rendition table\n"); |
| 2565 |
n = 0; |
| 2566 |
/* XtVaGetValues(globals.widgets.top_level, XmNfontList, &fontname, NULL); */ |
| 2567 |
/* fprintf(stderr, "fontname: |%s|\n", fontname); */ |
| 2568 |
XtSetArg(args[n], XmNfontName, "8x16"); n++; |
| 2569 |
XtSetArg(args[n], XmNfontType, XmFONT_IS_FONT); n++; |
| 2570 |
rendition = XmRenditionCreate(dummy_list, XmFONTLIST_DEFAULT_TAG, args, n); |
| 2571 |
rtable = XmRenderTableAddRenditions(NULL, &rendition, 1, XmMERGE_REPLACE); |
| 2572 |
XtVaSetValues(dummy_list, XmNrenderTable, rtable, NULL); |
| 2573 |
|
| 2574 |
/* rendition = XmRenditionCreate(globals.widgets.top_level, XmFONTLIST_DEFAULT_TAG, NULL, 0); */ |
| 2575 |
fprintf(stderr, "extent\n"); |
| 2576 |
XmStringExtent(rtable, tmpstring, &width, &height); |
| 2577 |
fprintf(stderr, "string %s has width %d, height %d\n", tmpbuf, width, height); |
| 2578 |
XtDestroyWidget(dummy_list); |
| 2579 |
XmRenditionFree(rendition); |
| 2580 |
XmStringFree(tmpstring); |
| 2581 |
} |
| 2582 |
#endif |
| 2583 |
{ |
| 2584 |
#define ARG_LEN 20 |
| 2585 |
int n = 0; |
| 2586 |
Arg list_args[ARG_LEN]; |
| 2587 |
|
| 2588 |
XtSetArg(list_args[n], XmNlistSizePolicy, XmVARIABLE); n++; |
| 2589 |
XtSetArg(list_args[n], XmNwidth, resource.pagelist_width); n++; |
| 2590 |
#if defined(USE_PANNER) && USE_XAW_PANNER |
| 2591 |
XtSetArg(list_args[n], XmNheight, globals.page.h - 62); n++; |
| 2592 |
#else |
| 2593 |
XtSetArg(list_args[n], XmNheight, globals.page.h); n++; |
| 2594 |
#endif |
| 2595 |
/* XtSetArg(list_args[n], XmNspacing, 10); n++; */ |
| 2596 |
#if defined(USE_PANNER) && USE_XAW_PANNER |
| 2597 |
XtSetArg(list_args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; |
| 2598 |
XtSetArg(list_args[n], XmNtopWidget, panner); n++; |
| 2599 |
#else |
| 2600 |
XtSetArg(list_args[n], XmNtopAttachment, XmATTACH_FORM); n++; |
| 2601 |
#endif |
| 2602 |
XtSetArg(list_args[n], XmNbottomAttachment, XmATTACH_FORM); n++; |
| 2603 |
XtSetArg(list_args[n], XmNleftAttachment, XmATTACH_FORM); n++; |
| 2604 |
XtSetArg(list_args[n], XmNrightAttachment, XmATTACH_OPPOSITE_FORM); n++; |
| 2605 |
XtSetArg(list_args[n], XmNrightOffset, -resource.pagelist_width); n++; |
| 2606 |
XtSetArg(list_args[n], XmNresizable, True); n++; |
| 2607 |
XtSetArg(list_args[n], XmNtopOffset, 2); n++; |
| 2608 |
XtSetArg(list_args[n], XmNleftOffset, 2); n++; |
| 2609 |
ASSERT(n < ARG_LEN, "list_args too short"); |
| 2610 |
#undef ARG_LEN |
| 2611 |
/* TODO: Find a smart way to determine size of pagelist instead of using resource.pagelist_width, |
| 2612 |
and find a smart way of resizing it when switching to a file with larger page numbers! |
| 2613 |
*/ |
| 2614 |
page_list = XmCreateScrolledList(form, "PageList", list_args, n); |
| 2615 |
} |
| 2616 |
|
| 2617 |
if (resource.expert_mode == XPRT_SHOW_NONE) { |
| 2618 |
XtUnmanageChild(XtParent(page_list)); |
| 2619 |
XtUnmanageChild(page_list); |
| 2620 |
} |
| 2621 |
|
| 2622 |
globals.widgets.main_window = XtVaCreateManagedWidget("mainWindow", |
| 2623 |
xmScrolledWindowWidgetClass, form, |
| 2624 |
XmNscrollingPolicy, XmAUTOMATIC, |
| 2625 |
XmNleftAttachment, XmATTACH_WIDGET, |
| 2626 |
/* lesstif balks if we just use page_list, so use its parent, |
| 2627 |
the xmScrolledWindow, for alignment: */ |
| 2628 |
XmNleftWidget, XtParent(page_list), |
| 2629 |
XmNallowResize, True, |
| 2630 |
/* XmNtopOffset, 2, */ |
| 2631 |
XmNtopAttachment, XmATTACH_FORM, |
| 2632 |
XmNbottomAttachment, XmATTACH_FORM, |
| 2633 |
XmNrightAttachment, XmATTACH_FORM, |
| 2634 |
/* XmNleftOffset, 10, */ |
| 2635 |
XmNresizable, True, |
| 2636 |
XmNborderWidth, 0, |
| 2637 |
NULL); |
| 2638 |
XtManageChild(form); |
| 2639 |
|
| 2640 |
globals.widgets.x_bar = XtNameToWidget(globals.widgets.main_window, "HorScrollBar"); |
| 2641 |
globals.widgets.y_bar = XtNameToWidget(globals.widgets.main_window, "VertScrollBar"); |
| 2642 |
|
| 2643 |
|
| 2644 |
#ifdef TEST_SCROLLING |
| 2645 |
/* TODO: try the following to prevent `flashing' effect - still breaks |
| 2646 |
scrolling in its current form though */ |
| 2647 |
globals.widgets.draw_background = XtVaCreateManagedWidget("drawing_bg", |
| 2648 |
xmFormWidgetClass, globals.widgets.main_window, |
| 2649 |
XmNwidth, globals.page.w, |
| 2650 |
XmNheight, globals.page.h, |
| 2651 |
XmNtopAttachment, XmATTACH_FORM, |
| 2652 |
XmNbottomAttachment, XmATTACH_FORM, |
| 2653 |
XmNrightAttachment, XmATTACH_FORM, |
| 2654 |
XmNleftAttachment, XmATTACH_FORM, |
| 2655 |
XmNhighlightThickness, 0, |
| 2656 |
XmNbackground, resource.back_Pixel, |
| 2657 |
XmNrubberPositioning, True, |
| 2658 |
NULL); |
| 2659 |
#endif |
| 2660 |
globals.widgets.draw_widget = XtVaCreateWidget("drawing", |
| 2661 |
xmDrawingAreaWidgetClass, |
| 2662 |
#ifdef TEST_SCROLLING |
| 2663 |
globals.widgets.draw_background, |
| 2664 |
#else |
| 2665 |
globals.widgets.main_window, |
| 2666 |
#endif |
| 2667 |
XmNwidth, globals.page.w, |
| 2668 |
XmNheight, globals.page.h, |
| 2669 |
XmNhighlightThickness, 0, |
| 2670 |
XmNrubberPositioning, True, |
| 2671 |
XtNbackground, resource.back_Pixel, |
| 2672 |
NULL); |
| 2673 |
|
| 2674 |
#if !FIXED_FLUSHING_PAGING |
| 2675 |
ASSERT(XtParent(globals.widgets.draw_widget) != NULL, ""); |
| 2676 |
XtVaSetValues(XtParent(globals.widgets.draw_widget), XtNbackground, resource.back_Pixel, NULL); |
| 2677 |
#endif |
| 2678 |
|
| 2679 |
#ifdef TEST_SCROLLING |
| 2680 |
fprintf(stderr, "globals.widgets.draw_widget is: %p\n", globals.widgets.draw_widget); |
| 2681 |
#endif |
| 2682 |
XtVaGetValues(globals.widgets.main_window, XmNclipWindow, &globals.widgets.clip_widget, NULL); |
| 2683 |
|
| 2684 |
XtVaSetValues(globals.widgets.main_row, |
| 2685 |
XmNmenuBar, globals.widgets.menu_bar, |
| 2686 |
XmNcommandWindow, XtParent(tool_bar), |
| 2687 |
XmNworkWindow, form, |
| 2688 |
NULL); |
| 2689 |
|
| 2690 |
XtVaSetValues(globals.widgets.main_window, |
| 2691 |
XmNworkWindow, globals.widgets.draw_widget, |
| 2692 |
NULL); |
| 2693 |
|
| 2694 |
XtManageChild(globals.widgets.draw_widget); |
| 2695 |
|
| 2696 |
status_line = create_statusline(globals.widgets.main_row); |
| 2697 |
XtVaSetValues(globals.widgets.main_row, |
| 2698 |
XmNmessageWindow, status_line, |
| 2699 |
NULL); |
| 2700 |
if ((resource.expert_mode & XPRT_SHOW_STATUSLINE) == 0) { |
| 2701 |
XtUnmanageChild(status_line); |
| 2702 |
} |
| 2703 |
|
| 2704 |
XtManageChild(globals.widgets.main_row); |
| 2705 |
|
| 2706 |
if ((resource.expert_mode & XPRT_SHOW_TOOLBAR) != 0) { |
| 2707 |
if (resource.toolbar_unusable) |
| 2708 |
statusline_error(STATUS_LONG, |
| 2709 |
"Error creating the toolbar pixmaps - toolbar is disabled!"); |
| 2710 |
else |
| 2711 |
XtManageChild(XtParent(tool_bar)); |
| 2712 |
} |
| 2713 |
|
| 2714 |
if ((resource.expert_mode & XPRT_SHOW_MENUBAR) != 0) |
| 2715 |
XtManageChild(globals.widgets.menu_bar); |
| 2716 |
|
| 2717 |
XmAddTabGroup(globals.widgets.draw_widget); |
| 2718 |
|
| 2719 |
/* |
| 2720 |
note: a few more custom translations for page_list are defined in |
| 2721 |
pagesel.c, since the actions are only known there. |
| 2722 |
*/ |
| 2723 |
{ |
| 2724 |
XtTranslations xlats; |
| 2725 |
|
| 2726 |
xlats = XtParseTranslationTable(base_key_translations); |
| 2727 |
|
| 2728 |
XtOverrideTranslations(globals.widgets.main_row, xlats); |
| 2729 |
/* XtOverrideTranslations(globals.widgets.menu_bar, xlats); */ |
| 2730 |
XtOverrideTranslations(tool_bar, xlats); |
| 2731 |
XtOverrideTranslations(page_list, xlats); |
| 2732 |
XtOverrideTranslations(globals.widgets.main_window, xlats); |
| 2733 |
XtOverrideTranslations(globals.widgets.clip_widget, xlats); |
| 2734 |
XtOverrideTranslations(globals.widgets.draw_widget, xlats); |
| 2735 |
|
| 2736 |
xlats = XtParseTranslationTable("<BtnDown>: press()\n" |
| 2737 |
"<Motion>: motion()\n" |
| 2738 |
"<BtnUp>: release()\n"); |
| 2739 |
|
| 2740 |
XtOverrideTranslations(globals.widgets.clip_widget, xlats); |
| 2741 |
XtOverrideTranslations(globals.widgets.draw_widget, xlats); |
| 2742 |
} |
| 2743 |
|
| 2744 |
if (resource.main_translations != NULL) { |
| 2745 |
XtTranslations xlats = XtParseTranslationTable(resource.main_translations); |
| 2746 |
XtOverrideTranslations(globals.widgets.draw_widget, xlats); |
| 2747 |
XtOverrideTranslations(globals.widgets.clip_widget, xlats); |
| 2748 |
XtOverrideTranslations(globals.widgets.main_row, xlats); |
| 2749 |
XtOverrideTranslations(globals.widgets.menu_bar, xlats); |
| 2750 |
XtOverrideTranslations(globals.widgets.main_window, xlats); |
| 2751 |
/* don't do it for the page list, otherwise mouse customizations will |
| 2752 |
break the default list bindings too. */ |
| 2753 |
/* XtOverrideTranslations(page_list, xlats); */ |
| 2754 |
} |
| 2755 |
|
| 2756 |
compile_mouse_actions(); |
| 2757 |
|
| 2758 |
#else /* MOTIF */ |
| 2759 |
|
| 2760 |
globals.widgets.form_widget = XtVaCreateManagedWidget("form", formWidgetClass, globals.widgets.top_level, |
| 2761 |
XtNdefaultDistance, 0, |
| 2762 |
NULL); |
| 2763 |
globals.widgets.vport_widget = XtVaCreateManagedWidget("vport", viewportWidgetClass, |
| 2764 |
globals.widgets.form_widget, |
| 2765 |
XtNborderWidth, 0, |
| 2766 |
XtNtop, XtChainTop, |
| 2767 |
XtNbottom, XtChainBottom, |
| 2768 |
XtNleft, XtChainLeft, |
| 2769 |
XtNright, XtChainRight, |
| 2770 |
XtNallowHoriz, True, |
| 2771 |
XtNallowVert, True, |
| 2772 |
NULL); |
| 2773 |
globals.widgets.clip_widget = XtNameToWidget(globals.widgets.vport_widget, "clip"); |
| 2774 |
|
| 2775 |
globals.widgets.draw_widget = XtVaCreateManagedWidget("drawing", drawWidgetClass, globals.widgets.vport_widget, |
| 2776 |
XtNwidth, globals.page.w, |
| 2777 |
XtNheight, globals.page.h, |
| 2778 |
XtNx, 0, |
| 2779 |
XtNy, 0, |
| 2780 |
XtNlabel, "", |
| 2781 |
NULL); |
| 2782 |
|
| 2783 |
XtOverrideTranslations(globals.widgets.form_widget, XtParseTranslationTable(base_key_translations)); |
| 2784 |
|
| 2785 |
if (resource.main_translations != NULL) { |
| 2786 |
XtOverrideTranslations(globals.widgets.form_widget, XtParseTranslationTable(resource.main_translations)); |
| 2787 |
} |
| 2788 |
|
| 2789 |
{ |
| 2790 |
XtTranslations xlats = XtParseTranslationTable("<BtnDown>: press()\n" |
| 2791 |
"<Motion>: motion()\n" |
| 2792 |
"<BtnUp>: release()\n"); |
| 2793 |
XtOverrideTranslations(globals.widgets.form_widget, xlats); |
| 2794 |
XtOverrideTranslations(globals.widgets.draw_widget, xlats); |
| 2795 |
} |
| 2796 |
|
| 2797 |
compile_mouse_actions(); |
| 2798 |
|
| 2799 |
|
| 2800 |
/* set background colors of the drawing widget */ |
| 2801 |
XtVaSetValues(globals.widgets.draw_widget, XtNbackground, resource.back_Pixel, NULL); |
| 2802 |
|
| 2803 |
#if !FIXED_FLUSHING_PAGING |
| 2804 |
XtVaSetValues(globals.widgets.clip_widget, XtNbackground, resource.back_Pixel, NULL); |
| 2805 |
#endif |
| 2806 |
|
| 2807 |
/* initialize add_w with width of button panel */ |
| 2808 |
create_menu_buttons(globals.widgets.form_widget, add_w); |
| 2809 |
|
| 2810 |
#endif /* MOTIF */ |
| 2811 |
|
| 2812 |
/* activate expert mode and related settings */ |
| 2813 |
toggle_statusline(); |
| 2814 |
toggle_scrollbars(); |
| 2815 |
#ifdef MOTIF |
| 2816 |
toggle_pagelist(); |
| 2817 |
toggle_toolbar(); |
| 2818 |
toggle_menubar(); |
| 2819 |
#else |
| 2820 |
if ((resource.expert_mode & XPRT_SHOW_BUTTONS) == 0) |
| 2821 |
toggle_buttons(); |
| 2822 |
#endif |
| 2823 |
|
| 2824 |
*add_h = 0; |
| 2825 |
#ifdef MOTIF |
| 2826 |
*add_w = 0; |
| 2827 |
if (resource.expert_mode & XPRT_SHOW_PAGELIST) |
| 2828 |
*add_w += xm_get_width(page_list); |
| 2829 |
/* if (globals.widgets.y_bar != NULL) */ |
| 2830 |
/* add_w += xm_get_width(globals.widgets.y_bar); */ |
| 2831 |
/* if (globals.widgets.x_bar != NULL) */ |
| 2832 |
/* add_h += xm_get_width(globals.widgets.x_bar); */ |
| 2833 |
if (resource.expert_mode & XPRT_SHOW_MENUBAR) |
| 2834 |
*add_h += xm_get_height(globals.widgets.menu_bar); |
| 2835 |
if (resource.expert_mode & XPRT_SHOW_TOOLBAR) |
| 2836 |
*add_h += xm_get_height(tool_bar); |
| 2837 |
if (resource.expert_mode & XPRT_SHOW_STATUSLINE) |
| 2838 |
*add_h += xm_get_height(status_line); |
| 2839 |
#else |
| 2840 |
/* add_w has been initialized by create_menu_buttons() call above. |
| 2841 |
Reset to 0 if we're in expert mode. */ |
| 2842 |
if (!(resource.expert_mode & XPRT_SHOW_BUTTONS)) { |
| 2843 |
*add_w = 0; |
| 2844 |
} |
| 2845 |
if (resource.expert_mode & XPRT_SHOW_STATUSLINE) { |
| 2846 |
/* FIXME: Unfortunately the statusline hasn't been created at this point for Xaw, |
| 2847 |
so the value is still the built-in default. |
| 2848 |
*/ |
| 2849 |
*add_h += get_statusline_height(); |
| 2850 |
} |
| 2851 |
#endif |
| 2852 |
} |
| 2853 |
|
| 2854 |
|
| 2855 |
static void |
| 2856 |
realize_widgets(Dimension main_win_w, Dimension main_win_h, int add_w) |
| 2857 |
{ |
| 2858 |
/* |
| 2859 |
* Realize the widgets (or windows). |
| 2860 |
*/ |
| 2861 |
|
| 2862 |
#ifndef MOTIF |
| 2863 |
realize_button_panel(main_win_h); |
| 2864 |
#endif |
| 2865 |
|
| 2866 |
XtAddEventHandler( |
| 2867 |
#ifdef MOTIF |
| 2868 |
globals.widgets.clip_widget, |
| 2869 |
#else |
| 2870 |
globals.widgets.vport_widget, |
| 2871 |
#endif |
| 2872 |
StructureNotifyMask, False, |
| 2873 |
handle_resize, (XtPointer) NULL); |
| 2874 |
|
| 2875 |
XtAddEventHandler(globals.widgets.top_level, PropertyChangeMask, False, |
| 2876 |
handle_property_change, (XtPointer) NULL); |
| 2877 |
XtAddEventHandler(globals.widgets.draw_widget, ExposureMask, False, handle_expose, |
| 2878 |
(XtPointer) &mane); |
| 2879 |
XtRealizeWidget(globals.widgets.top_level); |
| 2880 |
|
| 2881 |
mainDeleteWindow = XInternAtom(DISP, "WM_DELETE_WINDOW", False); |
| 2882 |
|
| 2883 |
#ifdef MOTIF |
| 2884 |
/* for Xaw, event handlers for scrollbars are added inside get_geom(), events.c */ |
| 2885 |
ASSERT(globals.widgets.x_bar != NULL, ""); |
| 2886 |
ASSERT(globals.widgets.y_bar != NULL, ""); |
| 2887 |
#ifdef USE_PANNER |
| 2888 |
XtAddEventHandler(globals.widgets.x_bar, ButtonPressMask | ButtonReleaseMask, False, handle_x_scroll, NULL); |
| 2889 |
XtAddEventHandler(globals.widgets.y_bar, ButtonPressMask | ButtonReleaseMask, False, handle_y_scroll, NULL); |
| 2890 |
#endif |
| 2891 |
XmAddWMProtocolCallback(globals.widgets.top_level, mainDeleteWindow, xdvi_exit_callback, NULL); |
| 2892 |
#else |
| 2893 |
wmProtocols = XInternAtom(DISP, "WM_PROTOCOLS", False); |
| 2894 |
XSetWMProtocols(DISP, XtWindow(globals.widgets.top_level), &mainDeleteWindow, 1); |
| 2895 |
XtAddEventHandler(globals.widgets.top_level, NoEventMask, True, handle_delete_message, NULL); |
| 2896 |
#endif |
| 2897 |
|
| 2898 |
/* check whether we want to run in fullscreen mode */ |
| 2899 |
if (resource.fullscreen) { |
| 2900 |
reconfigure_window(resource.fullscreen, main_win_w + add_w, main_win_h, False); |
| 2901 |
} |
| 2902 |
|
| 2903 |
#ifdef MOTIF |
| 2904 |
XmProcessTraversal(globals.widgets.draw_widget, XmTRAVERSE_CURRENT); |
| 2905 |
TRACE_GUI((stderr, "toplevel: %p", (void *)globals.widgets.top_level)); |
| 2906 |
create_tips(globals.widgets.top_level); |
| 2907 |
#else |
| 2908 |
if ((resource.expert_mode & XPRT_SHOW_STATUSLINE) != 0) { |
| 2909 |
create_statusline(); |
| 2910 |
} |
| 2911 |
#endif |
| 2912 |
|
| 2913 |
currwin.win = mane.win = XtWindow(globals.widgets.draw_widget); |
| 2914 |
|
| 2915 |
{ |
| 2916 |
XWindowAttributes attrs; |
| 2917 |
|
| 2918 |
(void)XGetWindowAttributes(DISP, mane.win, &attrs); |
| 2919 |
G_backing_store = attrs.backing_store; |
| 2920 |
} |
| 2921 |
|
| 2922 |
#ifdef HAVE_X11_XMU_EDITRES_H |
| 2923 |
/* |
| 2924 |
* Enable editres protocol (see "man editres"). |
| 2925 |
* Usually will need to add -lXmu to the linker line as well. |
| 2926 |
*/ |
| 2927 |
XtAddEventHandler(globals.widgets.top_level, (EventMask)0, True, _XEditResCheckMessages, |
| 2928 |
(XtPointer)NULL); |
| 2929 |
#endif |
| 2930 |
} |
| 2931 |
|
| 2932 |
/* |
| 2933 |
* Create colors and GCs. |
| 2934 |
* In color mode, color changes affect globals.gc.fore, globals.gc.fore2, |
| 2935 |
* and globals.gc.rule, but not globals.gc.copy or globals.gc.high. |
| 2936 |
*/ |
| 2937 |
static void |
| 2938 |
create_gcs(void) |
| 2939 |
{ |
| 2940 |
|
| 2941 |
#if GREY |
| 2942 |
if (resource.gamma == 0.0) |
| 2943 |
resource.gamma = 1.0; |
| 2944 |
#endif |
| 2945 |
|
| 2946 |
if (!resource.rule_color) |
| 2947 |
resource.rule_pixel = resource.fore_Pixel; |
| 2948 |
|
| 2949 |
#if !COLOR |
| 2950 |
|
| 2951 |
#if GREY |
| 2952 |
if (resource.use_grey) |
| 2953 |
init_pix(); |
| 2954 |
else |
| 2955 |
#endif |
| 2956 |
{ /* not #defined GREY, or not resource.use_grey */ |
| 2957 |
XGCValues values; |
| 2958 |
Pixel set_bits = (Pixel) (resource.fore_Pixel & ~resource.back_Pixel); |
| 2959 |
Pixel clr_bits = (Pixel) (resource.back_Pixel & ~resource.fore_Pixel); |
| 2960 |
Boolean copy_tmp = resource.copy; |
| 2961 |
|
| 2962 |
globals.gc.copy = set_or_make_gc(NULL, GXcopy, resource.fore_Pixel, resource.back_Pixel); |
| 2963 |
if (copy_tmp || (set_bits && clr_bits)) { |
| 2964 |
globals.gc.rule = globals.gc.copy; |
| 2965 |
if (!resource.thorough) |
| 2966 |
copy_tmp = True; |
| 2967 |
} |
| 2968 |
if (copy_tmp) { |
| 2969 |
globals.gc.fore = globals.gc.rule; |
| 2970 |
if (!resource.copy) { |
| 2971 |
warn_overstrike(); |
| 2972 |
} |
| 2973 |
} |
| 2974 |
else { |
| 2975 |
if (set_bits) { |
| 2976 |
globals.gc.fore = set_or_make_gc(NULL, GXor, set_bits, 0); |
| 2977 |
} |
| 2978 |
if (clr_bits || !set_bits) |
| 2979 |
*(globals.gc.fore ? &globals.gc.fore2 : &globals.gc.fore) = set_or_make_gc(NULL, GXandInverted, clr_bits, 0); |
| 2980 |
if (!globals.gc.rule) |
| 2981 |
globals.gc.rule = globals.gc.fore; |
| 2982 |
} |
| 2983 |
} |
| 2984 |
#endif /* !COLOR */ |
| 2985 |
|
| 2986 |
{ |
| 2987 |
Pixel link_pix, visited_link_pix; |
| 2988 |
get_link_colors(&link_pix, &visited_link_pix); |
| 2989 |
globals.gc.linkcolor = set_or_make_gc(NULL, GXcopy, link_pix, resource.back_Pixel); |
| 2990 |
globals.gc.visited_linkcolor = set_or_make_gc(NULL, GXcopy, visited_link_pix, resource.back_Pixel); |
| 2991 |
} |
| 2992 |
|
| 2993 |
#if COLOR |
| 2994 |
/* Not affected by color changes. */ |
| 2995 |
globals.gc.copy = set_or_make_gc(NULL, GXcopy, resource.fore_Pixel, resource.back_Pixel); |
| 2996 |
#endif |
| 2997 |
globals.gc.high = set_or_make_gc(NULL, GXcopy, resource.hl_Pixel, resource.back_Pixel); |
| 2998 |
|
| 2999 |
globals.gc.ruler = set_or_make_gc(NULL, GXcopy, resource.rule_pixel, resource.fore_Pixel); |
| 3000 |
|
| 3001 |
#if XAW |
| 3002 |
/* |
| 3003 |
* There's a bug in the Xaw toolkit, in which it uses the |
| 3004 |
* DefaultGCOfScreen to do vertical scrolling in the Text widget. |
| 3005 |
* This leads to a BadMatch error if our visual is not the default one. |
| 3006 |
* The following kludge works around this. |
| 3007 |
*/ |
| 3008 |
DefaultGCOfScreen(SCRN) = globals.gc.copy; |
| 3009 |
#endif |
| 3010 |
} |
| 3011 |
|
| 3012 |
static void |
| 3013 |
do_fork(void) |
| 3014 |
{ |
| 3015 |
TRACE_CLIENT((stderr, "no other instance of xdvi found, forking ...")); |
| 3016 |
/* |
| 3017 |
* No suitable xdvi found, so we start one by |
| 3018 |
* self-backgrounding. |
| 3019 |
*/ |
| 3020 |
/* flush output buffers to avoid double buffering (i.e. data |
| 3021 |
waiting in the output buffer being written twice, by the parent |
| 3022 |
and the child) */ |
| 3023 |
fflush(stdout); |
| 3024 |
fflush(stderr); |
| 3025 |
XFlush(DISP); |
| 3026 |
if (fork()) /* if initial process (do NOT use vfork()!) */ |
| 3027 |
_exit(0); |
| 3028 |
} |
| 3029 |
|
| 3030 |
#if defined(MOTIF) && defined(USE_PANNER) && USE_XAW_PANNER |
| 3031 |
static void |
| 3032 |
panner_cb(Widget widget, XtPointer closure, XtPointer report_ptr) |
| 3033 |
{ |
| 3034 |
fprintf(stderr, "panner_cb called!\n"); |
| 3035 |
} |
| 3036 |
#endif |
| 3037 |
|
| 3038 |
#if !DELAYED_MKTEXPK |
| 3039 |
|
| 3040 |
static XtIntervalId m_font_popup_id = 0; |
| 3041 |
static Widget m_font_popup = 0; |
| 3042 |
|
| 3043 |
static void |
| 3044 |
remove_font_popup(XtPointer client_data, XtIntervalId *id) |
| 3045 |
{ |
| 3046 |
UNUSED(client_data); |
| 3047 |
UNUSED(id); |
| 3048 |
|
| 3049 |
if (m_font_popup != 0) { |
| 3050 |
kill_message_window(m_font_popup); |
| 3051 |
} |
| 3052 |
} |
| 3053 |
|
| 3054 |
static void |
| 3055 |
remove_font_popup_exit_cb(XtPointer arg) |
| 3056 |
{ |
| 3057 |
UNUSED(arg); |
| 3058 |
xdvi_exit(EXIT_SUCCESS); |
| 3059 |
} |
| 3060 |
|
| 3061 |
static void |
| 3062 |
create_font_popup(XtPointer client_data, XtIntervalId *id) |
| 3063 |
{ |
| 3064 |
int *curr_timeout = (int *)client_data; |
| 3065 |
static int new_timeout = 0; |
| 3066 |
|
| 3067 |
UNUSED(client_data); |
| 3068 |
UNUSED(id); |
| 3069 |
|
| 3070 |
/* fprintf(stderr, "+++++++++++++++ create_font_popup\n"); */ |
| 3071 |
|
| 3072 |
if (m_font_popup_id) { |
| 3073 |
if (*curr_timeout > 0) { |
| 3074 |
XtRemoveTimeOut(m_font_popup_id); |
| 3075 |
m_font_popup_id = XtAppAddTimeOut(globals.app, *curr_timeout, create_font_popup, (XtPointer)&new_timeout); |
| 3076 |
} |
| 3077 |
else { |
| 3078 |
m_font_popup = choice_dialog(globals.widgets.top_level, |
| 3079 |
MSG_INFO, NULL, |
| 3080 |
#ifndef MOTIF |
| 3081 |
NULL, |
| 3082 |
#endif |
| 3083 |
NULL, NULL, /* no pre_callbacks */ |
| 3084 |
NULL, NULL, NULL, /* default arguments for `OK' */ |
| 3085 |
"Exit Xdvi", remove_font_popup_exit_cb, (XtPointer)NULL, |
| 3086 |
"Loading %s\n(may take some time creating fonts ...)", |
| 3087 |
globals.dvi_name); |
| 3088 |
} |
| 3089 |
} |
| 3090 |
} |
| 3091 |
|
| 3092 |
void |
| 3093 |
register_font_popup(void) |
| 3094 |
{ |
| 3095 |
/* Use a two-step process, so that when the timeout is removed by unregister_font_popup(), |
| 3096 |
it will occur before new_timeout. create_font_popup() will call XtAppAddTimeOut() again |
| 3097 |
with new_timeout = 0. |
| 3098 |
*/ |
| 3099 |
static int new_timeout = 50; |
| 3100 |
/* fprintf(stderr, "+++++++++++++++ registered font popup\n"); */ |
| 3101 |
m_font_popup_id = XtAppAddTimeOut(globals.app, 100, create_font_popup, (XtPointer)&new_timeout); |
| 3102 |
} |
| 3103 |
|
| 3104 |
void |
| 3105 |
unregister_font_popup(void) |
| 3106 |
{ |
| 3107 |
/* fprintf(stderr, "+++++++++++++++ unregister_font_popup\n"); */ |
| 3108 |
if (m_font_popup_id) { |
| 3109 |
XtRemoveTimeOut(m_font_popup_id); |
| 3110 |
m_font_popup_id = 0; |
| 3111 |
/* FIXME: calling this directly crashes xdvi?? */ |
| 3112 |
/* m_font_popup_id = XtAppAddTimeOut(globals.app, 1, remove_font_popup, (XtPointer)NULL); */ |
| 3113 |
remove_font_popup(NULL, NULL); |
| 3114 |
} |
| 3115 |
} |
| 3116 |
#endif /* !DELAYED_MKTEXPK */ |
| 3117 |
|
| 3118 |
/* revert resources */ |
| 3119 |
void |
| 3120 |
load_app_resources(Boolean also_pixels) |
| 3121 |
{ |
| 3122 |
/* /\* reset some resources to built-in defaults *\/ */ |
| 3123 |
/* resource.browser = NULL; */ |
| 3124 |
/* resource.editor = NULL; */ |
| 3125 |
/* resource.gamma = 1; */ |
| 3126 |
/* resource.link_style = 3; */ |
| 3127 |
/* resource.link_color = LINK_COLOR_FALLBACK; */ |
| 3128 |
/* resource.visited_link_color = VISITED_LINK_COLOR_FALLBACK; */ |
| 3129 |
/* resource.expert_mode = 31; */ |
| 3130 |
/* resource.use_color = True; */ |
| 3131 |
/* resource.match_highlight_inverted = True; */ |
| 3132 |
|
| 3133 |
XtGetApplicationResources(globals.widgets.top_level, (XtPointer)&resource, |
| 3134 |
application_resources, XtNumber(application_resources), |
| 3135 |
(ArgList)NULL, 0); |
| 3136 |
|
| 3137 |
if (also_pixels) { |
| 3138 |
XtGetApplicationResources(globals.widgets.top_level, (XtPointer)&resource, |
| 3139 |
app_pixel_resources, XtNumber(app_pixel_resources), |
| 3140 |
(ArgList)NULL, 0); |
| 3141 |
} |
| 3142 |
/* fprintf(stderr, "gamma: %f\n", resource.gamma); */ |
| 3143 |
} |
| 3144 |
|
| 3145 |
/* |
| 3146 |
* Unfortunately this must be a callback, for the file selector ... |
| 3147 |
* This is the second part of Main: Create all widgets, initialize the DVI file, |
| 3148 |
* and enter the main event loop. |
| 3149 |
*/ |
| 3150 |
void |
| 3151 |
run_dvi_file(const char *filename, void *data) |
| 3152 |
{ |
| 3153 |
Boolean tried_dvi_ext = False; |
| 3154 |
struct startup_info *cb = (struct startup_info *)data; |
| 3155 |
|
| 3156 |
#ifdef MOTIF |
| 3157 |
Widget tool_bar = 0; |
| 3158 |
Widget form = 0; |
| 3159 |
#endif |
| 3160 |
|
| 3161 |
char *title_name = NULL; |
| 3162 |
char *icon_name = NULL; |
| 3163 |
dviErrFlagT errflag = NO_ERROR; |
| 3164 |
|
| 3165 |
int add_w = 0, add_h = 0; |
| 3166 |
Dimension main_win_w, main_win_h; |
| 3167 |
|
| 3168 |
UNUSED(data); |
| 3169 |
ASSERT(filename != NULL, "filename must have been initialized here!"); |
| 3170 |
|
| 3171 |
globals.dvi_name = xstrdup(filename); |
| 3172 |
file_history_push(globals.dvi_name); |
| 3173 |
|
| 3174 |
TRACE_FILES((stderr, "globals.dvi_name is: |%s| %p\n", globals.dvi_name, globals.dvi_name)); |
| 3175 |
|
| 3176 |
globals.dvi_file.dirname = get_dir_component(globals.dvi_name); |
| 3177 |
xdvi_assert(XDVI_VERSION_INFO, __FILE__, __LINE__, |
| 3178 |
globals.dvi_file.dirname != NULL, |
| 3179 |
"globals.dvi_name (%s) must contain a dir component", |
| 3180 |
globals.dvi_name); |
| 3181 |
globals.dvi_file.dirlen = strlen(globals.dvi_file.dirname); |
| 3182 |
|
| 3183 |
form_dvi_property(); |
| 3184 |
|
| 3185 |
/* |
| 3186 |
If `unique' is active, we may need to pass the file to a different instance of xdvi: |
| 3187 |
*/ |
| 3188 |
if (resource.unique) { |
| 3189 |
Window w1 = 0, w2 = 0; |
| 3190 |
if ((w1 = get_xdvi_window_id(True, NULL)) != 0 || (w2 = get_xdvi_window_id(False, NULL)) != 0) { |
| 3191 |
if (w1 != 0) { /* another xdvi instance, same file: reload */ |
| 3192 |
w2 = w1; |
| 3193 |
set_string_property("", atom_reload(), w2); |
| 3194 |
} |
| 3195 |
else { /* another xdvi instance, different file: load new file */ |
| 3196 |
set_string_property(globals.dvi_name, atom_newdoc(), w2); |
| 3197 |
} |
| 3198 |
if (cb->page_arg != NULL) { /* switch to different page */ |
| 3199 |
if (strlen(cb->page_arg) == 0) { /* special case: treat `+' as last page */ |
| 3200 |
set_string_property("+", atom_newpage(), w2); |
| 3201 |
} |
| 3202 |
else { |
| 3203 |
set_string_property(cb->page_arg, atom_newpage(), w2); |
| 3204 |
} |
| 3205 |
} |
| 3206 |
else { |
| 3207 |
/* if page_arg is empty, go to 1st page so that this page is |
| 3208 |
inserted into the page history (fix for #1044891) */ |
| 3209 |
set_string_property("1", atom_newpage(), w2); |
| 3210 |
} |
| 3211 |
/* in all cases, raise the window of the other instance */ |
| 3212 |
set_string_property("", atom_raise(), w2); |
| 3213 |
xdvi_exit(EXIT_SUCCESS); |
| 3214 |
} |
| 3215 |
else if (resource.src_fork) { |
| 3216 |
do_fork(); |
| 3217 |
} |
| 3218 |
} |
| 3219 |
|
| 3220 |
/* |
| 3221 |
Similar for forward search or string search: |
| 3222 |
*/ |
| 3223 |
if (resource.src_pos != NULL || resource.find_string != NULL) { |
| 3224 |
Window w; |
| 3225 |
if ((w = get_xdvi_window_id(True, NULL)) != 0) { |
| 3226 |
/* another instance of xdvi running, displaying the same file */ |
| 3227 |
TRACE_CLIENT((stderr, "Match; changing property of client and exiting ...")); |
| 3228 |
if (resource.src_pos != NULL) |
| 3229 |
set_sourceposition_property(resource.src_pos, w); |
| 3230 |
else |
| 3231 |
set_stringsearch_property(resource.find_string, w); |
| 3232 |
xdvi_exit(EXIT_SUCCESS); |
| 3233 |
} |
| 3234 |
else if (resource.src_fork) { |
| 3235 |
do_fork(); |
| 3236 |
} |
| 3237 |
} |
| 3238 |
|
| 3239 |
/* Needed for source specials and for calling ghostscript. */ |
| 3240 |
xputenv("DISPLAY", XDisplayString(DISP)); |
| 3241 |
|
| 3242 |
|
| 3243 |
if (globals.debug) { |
| 3244 |
fprintf(stderr, "%s %s, kpathsea: %s\n", XDVIK_PROGNAME, XDVI_VERSION_INFO, kpathsea_version_string); |
| 3245 |
fprintf(stderr, |
| 3246 |
"configured with: ppi=%d shrink=%d mfmode=%s alt_font=%s paper=%s\n", |
| 3247 |
resource.pixels_per_inch, |
| 3248 |
currwin.shrinkfactor, |
| 3249 |
resource.mfmode ? resource.mfmode : "<NONE>", |
| 3250 |
resource.alt_font, |
| 3251 |
resource.paper); |
| 3252 |
} |
| 3253 |
|
| 3254 |
kpse_set_program_enabled(kpse_any_glyph_format, resource.makepk, kpse_src_compile); |
| 3255 |
/* janl 16/11/98: I have changed this. The above line used to |
| 3256 |
say the settings in resource.makepk was supplied on the |
| 3257 |
commandline, resulting in it overriding _all other_ |
| 3258 |
settings, derived from the environment or texmf.cnf, no |
| 3259 |
matter what the value. The value in resource.makepk could |
| 3260 |
be the compile-time default... |
| 3261 |
|
| 3262 |
Personaly I like the environment/texmf.cnf to override |
| 3263 |
resources and thus changed the 'level' of this setting to |
| 3264 |
kpse_src_compile so the environment/texmf.cnf will override |
| 3265 |
the values derived by Xt. |
| 3266 |
|
| 3267 |
Previous comment here: |
| 3268 |
|
| 3269 |
``Let true values as an X resource/command line override false |
| 3270 |
values in texmf.cnf/envvar.'' */ |
| 3271 |
|
| 3272 |
/* |
| 3273 |
* Step 2: Settle colormap issues. This should be done before |
| 3274 |
* other widgets are created, so that they get the right |
| 3275 |
* pixel values. (The top-level widget won't have the right |
| 3276 |
* values, but I don't think that makes any difference.) |
| 3277 |
*/ |
| 3278 |
|
| 3279 |
#ifdef XSERVER_INFO |
| 3280 |
print_xserver_info(); |
| 3281 |
#endif |
| 3282 |
|
| 3283 |
create_colormaps(); |
| 3284 |
|
| 3285 |
|
| 3286 |
#ifdef TESTING_OPEN_FILES |
| 3287 |
fprintf(stderr, "open_max: %ld\n", OPEN_MAX); |
| 3288 |
for (i = 0; i < OPEN_MAX - 10; i++) { |
| 3289 |
FILE *fp; |
| 3290 |
if ((fp = fopen("/tmp/foo", "r")) == NULL) { |
| 3291 |
perror("fopen"); |
| 3292 |
xdvi_exit(EXIT_FAILURE); |
| 3293 |
} |
| 3294 |
} |
| 3295 |
fprintf(stderr, "opened %d files.\n", i); |
| 3296 |
#endif |
| 3297 |
|
| 3298 |
|
| 3299 |
/* toolbar code may open files, but we have no check close_a_file() in |
| 3300 |
the toolbar code; so do this before prescan() possibly opens lots of files. |
| 3301 |
*/ |
| 3302 |
#ifdef MOTIF |
| 3303 |
globals.widgets.main_row = XmCreateMainWindow(globals.widgets.top_level, "main", NULL, 0); |
| 3304 |
|
| 3305 |
create_menu_buttons(globals.widgets.main_row, &globals.widgets.menu_bar); |
| 3306 |
|
| 3307 |
/* seems to be needed for enabling `XmNhighlightOnEnter' for the toolbar buttons |
| 3308 |
- is this the correct place to do it? */ |
| 3309 |
XtVaSetValues(globals.widgets.top_level, XmNkeyboardFocusPolicy, (XtArgVal)XmPOINTER, NULL); |
| 3310 |
|
| 3311 |
form = XtVaCreateWidget("form", xmFormWidgetClass, globals.widgets.main_row, |
| 3312 |
XmNshadowThickness, 0, |
| 3313 |
NULL); |
| 3314 |
|
| 3315 |
if (resource.main_translations != NULL) { |
| 3316 |
XtOverrideTranslations(form, XtParseTranslationTable(resource.main_translations)); |
| 3317 |
} |
| 3318 |
|
| 3319 |
|
| 3320 |
#if defined(USE_PANNER) && USE_XAW_PANNER |
| 3321 |
panner = XtVaCreateWidget("panner", pannerWidgetClass, form, |
| 3322 |
XmNtopAttachment, XmATTACH_FORM, |
| 3323 |
XmNleftAttachment, XmATTACH_FORM, |
| 3324 |
XmNleftOffset, 20, |
| 3325 |
XmNrightAttachment, XmATTACH_OPPOSITE_FORM, |
| 3326 |
XmNrightOffset, -resource.pagelist_width + 20, |
| 3327 |
XmNtopOffset, 2, |
| 3328 |
XmNleftOffset, 2, |
| 3329 |
XtNheight, 60, |
| 3330 |
XtNwidth, resource.pagelist_width - 50, |
| 3331 |
XtNsliderX, 5, |
| 3332 |
XtNsliderY, 7, |
| 3333 |
XtNinternalSpace, 0, |
| 3334 |
XtNshadowThickness, 0, |
| 3335 |
NULL); |
| 3336 |
#endif |
| 3337 |
#endif |
| 3338 |
|
| 3339 |
/* use bounding box for highlighting if our visual isn't TrueColor |
| 3340 |
(not worth the trouble ...) */ |
| 3341 |
if (G_visual->class != TrueColor) { |
| 3342 |
resource.match_highlight_inverted = False; |
| 3343 |
} |
| 3344 |
|
| 3345 |
/* |
| 3346 |
* Step 3: Initialize the dvi file and set titles. |
| 3347 |
*/ |
| 3348 |
|
| 3349 |
#if FREETYPE |
| 3350 |
/* |
| 3351 |
At this point DISP, G_visual, G_depth and G_colormap must |
| 3352 |
be defined. Also, init_t1_lookup() must go before internal_open_dvi(), |
| 3353 |
since read_postamble will define some fonts and insert them into |
| 3354 |
fontmaps_hash, but we need a clean fontmaps_hash for detecting |
| 3355 |
duplicate entries in the map file. |
| 3356 |
*/ |
| 3357 |
|
| 3358 |
if (resource.freetype) { |
| 3359 |
if (!init_t1_lookup()) { |
| 3360 |
/* nag 'em with a popup so that they'll do something about this */ |
| 3361 |
popup_message(globals.widgets.top_level, |
| 3362 |
MSG_ERR, |
| 3363 |
"Direct Type 1 font rendering via FreeType gives you " |
| 3364 |
"many benefits, such as:\n" |
| 3365 |
" - quicker startup time, since no bitmap fonts need " |
| 3366 |
"to be generated;\n" |
| 3367 |
" - saving disk space for storing the bitmap fonts.\n" |
| 3368 |
"To fix this error, check that the file `ps2pk.map' " |
| 3369 |
"is located somewhere in your XDVIINPUTS path. " |
| 3370 |
"Have a look at the xdvi wrapper shell script " |
| 3371 |
"(type \"which xdvi\" to locate that shell script) " |
| 3372 |
"for the current setting of XDVIINPUTS.", |
| 3373 |
"Could not load any of the map files listed in xdvi.cfg " |
| 3374 |
"- disabling FreeType."); |
| 3375 |
resource.freetype = False; |
| 3376 |
} |
| 3377 |
} |
| 3378 |
#endif /* FREETYPE */ |
| 3379 |
|
| 3380 |
#if DELAYED_MKTEXPK |
| 3381 |
/* Open and initialize the DVI file. First, disable creation of PK fonts |
| 3382 |
* so that we can count the missing fonts that are to be generated. */ |
| 3383 |
kpse_set_program_enabled(kpse_any_glyph_format, False, kpse_src_compile); |
| 3384 |
#endif |
| 3385 |
|
| 3386 |
setup_signal_handlers(False); |
| 3387 |
|
| 3388 |
#if !DELAYED_MKTEXPK |
| 3389 |
/* Notify users that fonts are being created. This is just a hack |
| 3390 |
and no replacement for true asynchronous font creation since it |
| 3391 |
doesn't give details (is just invoked if startup takes somewhat |
| 3392 |
longer) and freezes during font creation. |
| 3393 |
*/ |
| 3394 |
register_font_popup(); |
| 3395 |
#endif |
| 3396 |
|
| 3397 |
/* open and initialize the DVI file, but don't read the fonts yet */ |
| 3398 |
if (!internal_open_dvi(globals.dvi_name, &errflag, True |
| 3399 |
#if DELAYED_MKTEXPK |
| 3400 |
, False /* read fonts, but don't initialize data structures */ |
| 3401 |
#endif |
| 3402 |
)) { |
| 3403 |
if (tried_dvi_ext) { |
| 3404 |
XDVI_FATAL((stderr, "Could not open %s: %s, and %s.dvi doesn't exist either - exiting.", |
| 3405 |
globals.dvi_name, get_dvi_error(errflag), globals.dvi_name)); |
| 3406 |
} |
| 3407 |
else { |
| 3408 |
XDVI_FATAL((stderr, "Could not open %s: %s.", |
| 3409 |
globals.dvi_name, get_dvi_error(errflag))); |
| 3410 |
} |
| 3411 |
} |
| 3412 |
|
| 3413 |
#if DELAYED_MKTEXPK |
| 3414 |
fprintf(stderr, "after opening ...\n"); |
| 3415 |
/* Now re-enable PK creation and read the postamble for a second time. |
| 3416 |
* FIXME: Actually we don't need this re-reading, could as well read the |
| 3417 |
* entire thing in the first run, not quit early and correctly initialize |
| 3418 |
* the fonts without creating them. */ |
| 3419 |
kpse_set_program_enabled(kpse_any_glyph_format, resource.makepk, kpse_src_compile); |
| 3420 |
|
| 3421 |
if (!internal_open_dvi(globals.dvi_name, &errflag, True, True)) { |
| 3422 |
if (tried_dvi_ext) { |
| 3423 |
XDVI_FATAL((stderr, "Could not open %s: %s, and %s.dvi doesn't exist either - exiting.", |
| 3424 |
globals.dvi_name, get_dvi_error(errflag), globals.dvi_name)); |
| 3425 |
} |
| 3426 |
else { |
| 3427 |
XDVI_FATAL((stderr, "Could not open %s: %s.", |
| 3428 |
globals.dvi_name, get_dvi_error(errflag))); |
| 3429 |
} |
| 3430 |
} |
| 3431 |
#else |
| 3432 |
unregister_font_popup(); |
| 3433 |
#endif |
| 3434 |
|
| 3435 |
if (cb->page_arg != NULL) { |
| 3436 |
if (cb->page_arg[0] == '\0') { /* empty page_arg -> goto last page */ |
| 3437 |
current_page = total_pages - 1; |
| 3438 |
page_history_insert(current_page); |
| 3439 |
} |
| 3440 |
else { |
| 3441 |
char *testptr; |
| 3442 |
current_page = strtoul(cb->page_arg, &testptr, 10) - 1; |
| 3443 |
if (*testptr != '\0') { |
| 3444 |
XDVI_FATAL((stderr, "Invalid page number: `%s'.", cb->page_arg)); |
| 3445 |
} |
| 3446 |
current_page = check_goto_page(current_page, True); |
| 3447 |
} |
| 3448 |
} |
| 3449 |
else { |
| 3450 |
page_history_insert(current_page); |
| 3451 |
} |
| 3452 |
file_history_set_page(current_page); |
| 3453 |
|
| 3454 |
ASSERT(globals.dvi_file.bak_fp != NULL, "Backup file pointer must have been initialized here"); |
| 3455 |
if (resource.prescan) { |
| 3456 |
prescan(globals.dvi_file.bak_fp); |
| 3457 |
} |
| 3458 |
|
| 3459 |
globals.page.unshrunk_w = pageinfo_get_page_width(current_page); |
| 3460 |
globals.page.unshrunk_h = pageinfo_get_page_height(current_page); |
| 3461 |
TRACE_GUI((stderr, "globals.page.unshrunk_w: %d, h: %d; window: %d, %d", |
| 3462 |
globals.page.unshrunk_w, globals.page.unshrunk_h, |
| 3463 |
pageinfo_get_window_width(current_page), |
| 3464 |
pageinfo_get_window_height(current_page))); |
| 3465 |
|
| 3466 |
init_page(); |
| 3467 |
|
| 3468 |
/* |
| 3469 |
* Step 4: Create widgets, and set initial window size. |
| 3470 |
*/ |
| 3471 |
|
| 3472 |
/* currently these override expert mode - using this is deprecated |
| 3473 |
in favour of `-expertmode'; inform user about this: */ |
| 3474 |
if (resource.statusline) { |
| 3475 |
XDVI_WARNING((stderr, "The option/X resource `statusline' is obsolete; " |
| 3476 |
"use `-expertmode <flag>' instead, e.g. `-expertmode 1'\n" |
| 3477 |
"to switch on the status line, or `-expertmode 6'\n" |
| 3478 |
"to switch it off. See the xdvi man page for details.")); |
| 3479 |
resource.expert_mode |= XPRT_SHOW_STATUSLINE; |
| 3480 |
} |
| 3481 |
|
| 3482 |
/* XtRealizeWidget(globals.widgets.top_level); */ |
| 3483 |
|
| 3484 |
#ifdef MOTIF |
| 3485 |
tool_bar = create_toolbar(globals.widgets.main_row, globals.widgets.menu_bar); |
| 3486 |
if (resource.main_translations != NULL) { |
| 3487 |
XtOverrideTranslations(tool_bar, XtParseTranslationTable(resource.main_translations)); |
| 3488 |
} |
| 3489 |
#endif |
| 3490 |
|
| 3491 |
create_widgets( |
| 3492 |
#ifdef MOTIF |
| 3493 |
tool_bar, form, |
| 3494 |
#endif |
| 3495 |
&add_w, &add_h); |
| 3496 |
|
| 3497 |
TRACE_GUI((stderr, "add_w = %d, add_h = %d\n", add_w, add_h)); |
| 3498 |
/* fprintf(stderr, "geometry xdvirc: |%s|, orig: |%s|\n", resource.xdvirc_geometry, resource.geometry); */ |
| 3499 |
|
| 3500 |
/* |
| 3501 |
* Set initial window size. |
| 3502 |
* This needs to be done before colors are assigned because if |
| 3503 |
* -s 0 is specified, we need to compute the shrink factor |
| 3504 |
* (which in turn affects whether init_pix is called). |
| 3505 |
*/ |
| 3506 |
set_windowsize(&main_win_w, &main_win_h, add_w, add_h, False); |
| 3507 |
|
| 3508 |
realize_widgets(main_win_w, main_win_h, add_w); |
| 3509 |
|
| 3510 |
/* this needs to be done after total_pages is known (via internal_open_dvi) */ |
| 3511 |
get_icon_and_title(globals.dvi_name, &icon_name, &title_name); |
| 3512 |
add_icon(globals.widgets.top_level, title_name, icon_name); |
| 3513 |
/* this needs to be done after the widgets have been created */ |
| 3514 |
set_icon_and_title(icon_name, title_name); |
| 3515 |
free(icon_name); |
| 3516 |
free(title_name); |
| 3517 |
icon_name = title_name = NULL; |
| 3518 |
|
| 3519 |
|
| 3520 |
G_image = XCreateImage(DISP, G_visual, 1, XYBitmap, 0, |
| 3521 |
(char *)NULL, 0, 0, BMBITS, 0); |
| 3522 |
G_image->bitmap_unit = BMBITS; |
| 3523 |
#ifdef WORDS_BIGENDIAN |
| 3524 |
G_image->bitmap_bit_order = MSBFirst; |
| 3525 |
#else |
| 3526 |
G_image->bitmap_bit_order = LSBFirst; |
| 3527 |
#endif |
| 3528 |
{ |
| 3529 |
short endian = MSBFirst << 8 | LSBFirst; |
| 3530 |
G_image->byte_order = *((char *)&endian); |
| 3531 |
} |
| 3532 |
|
| 3533 |
/* Store window id for use by get_xdvi_window_id(). */ |
| 3534 |
{ |
| 3535 |
long data = XtWindow(globals.widgets.top_level); |
| 3536 |
|
| 3537 |
XChangeProperty(DISP, DefaultRootWindow(DISP), |
| 3538 |
atom_xdvi_windows(), atom_xdvi_windows(), 32, |
| 3539 |
PropModePrepend, (unsigned char *)&data, 1); |
| 3540 |
set_dvi_property(); |
| 3541 |
} |
| 3542 |
|
| 3543 |
|
| 3544 |
#if HAVE_XI21 |
| 3545 |
xi2_init(); /* Set up hi-res (smooth) scrolling */ |
| 3546 |
#endif |
| 3547 |
|
| 3548 |
/* |
| 3549 |
* Step 5: Assign colors and GCs. |
| 3550 |
* Because of the latter, this has to go after the widgets are realized. |
| 3551 |
*/ |
| 3552 |
|
| 3553 |
create_gcs(); |
| 3554 |
|
| 3555 |
create_cursors(); |
| 3556 |
|
| 3557 |
#ifdef MOTIF |
| 3558 |
#if defined(USE_PANNER) && USE_XAW_PANNER |
| 3559 |
XtVaSetValues(panner, XtNsliderWidth, globals.page.w / 2, |
| 3560 |
XtNsliderHeight, globals.page.h / 2, |
| 3561 |
XtNcanvasWidth, globals.page.w, |
| 3562 |
XtNcanvasHeight, globals.page.h, |
| 3563 |
NULL); |
| 3564 |
XtManageChild(panner); |
| 3565 |
XtAddCallback(panner, XtNreportCallback, panner_cb, (XtPointer)NULL); |
| 3566 |
#endif |
| 3567 |
create_pagelist(); |
| 3568 |
#endif |
| 3569 |
|
| 3570 |
/* trigger forward search */ |
| 3571 |
do_forward_search(resource.src_pos); |
| 3572 |
|
| 3573 |
/* trigger string search */ |
| 3574 |
if (resource.find_string != NULL) { |
| 3575 |
globals.ev.flags |= EV_FIND; |
| 3576 |
} |
| 3577 |
|
| 3578 |
/* trigger anchor search */ |
| 3579 |
if (resource.anchor_pos != NULL) { |
| 3580 |
g_anchor_pos = xstrdup(resource.anchor_pos); |
| 3581 |
g_anchor_len = strlen(g_anchor_pos); |
| 3582 |
globals.ev.flags |= EV_ANCHOR; |
| 3583 |
} |
| 3584 |
|
| 3585 |
#if defined(MOTIF) && HAVE_XPM |
| 3586 |
tb_check_navigation_sensitivity(current_page); |
| 3587 |
#endif |
| 3588 |
|
| 3589 |
#if CHECK_APP_FILEVERSION |
| 3590 |
check_app_defaults_fileversion(); |
| 3591 |
#endif |
| 3592 |
|
| 3593 |
/* can do this only after scrollbars have been realized */ |
| 3594 |
if (!BROKEN_RECONFIG && (resource.expert_mode & XPRT_SHOW_SCROLLBARS) == 0) { |
| 3595 |
toggle_scrollbars(); |
| 3596 |
} |
| 3597 |
|
| 3598 |
/* initialize file watching */ |
| 3599 |
if (resource.watch_file > 0.0) { |
| 3600 |
#if XDVI_XT_TIMER_HACK |
| 3601 |
watch_file_cb(NULL, NULL); |
| 3602 |
#else |
| 3603 |
XDVI_WARNING((stderr, "Could not redefine XtAppAddTimeOut(); `watchfile' not available.")); |
| 3604 |
#endif |
| 3605 |
} |
| 3606 |
|
| 3607 |
/* raise `early' message windows */ |
| 3608 |
raise_message_windows(); |
| 3609 |
|
| 3610 |
{ |
| 3611 |
String args[1]; |
| 3612 |
char mmode[LENGTH_OF_INT]; |
| 3613 |
snprintf(mmode, LENGTH_OF_INT, "%d", resource.mouse_mode); |
| 3614 |
args[0] = mmode; |
| 3615 |
XtCallActionProc(globals.widgets.top_level, "switch-mode", NULL, args, 1); |
| 3616 |
} |
| 3617 |
|
| 3618 |
/* go to home position on first page to honor -(side|top)margin flags */ |
| 3619 |
if (!resource.keep_flag) |
| 3620 |
home(False); |
| 3621 |
|
| 3622 |
do_pages(); |
| 3623 |
} |