1
/* $XFree86: xc/programs/xvidtune/xvidtune.c,v 3.35tsi Exp $ */
5
Copyright (c) 1995 Kaleb S. KEITHLEY
7
Permission is hereby granted, free of charge, to any person obtaining
8
a copy of this software and associated documentation files (the
9
"Software"), to deal in the Software without restriction, including
10
without limitation the rights to use, copy, modify, merge, publish,
11
distribute, sublicense, and/or sell copies of the Software, and to
12
permit persons to whom the Software is furnished to do so, subject to
13
the following conditions:
15
The above copyright notice and this permission notice shall be
16
included in all copies or substantial portions of the Software.
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
22
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
OTHER DEALINGS IN THE SOFTWARE.
26
Except as contained in this notice, the name of Kaleb S. KEITHLEY
27
shall not be used in advertising or otherwise to promote the sale, use
28
or other dealings in this Software without prior written authorization
29
from Kaleb S. KEITHLEY.
33
#include <X11/Intrinsic.h>
34
#include <X11/Shell.h>
35
#include <X11/StringDefs.h>
36
#include <X11/Xatom.h>
37
#include <X11/Xaw/Form.h>
38
#include <X11/Xaw/Scrollbar.h>
39
#include <X11/Xaw/Label.h>
40
#include <X11/Xaw/Command.h>
41
#include <X11/Xaw/AsciiText.h>
42
#include <X11/Xaw/Box.h>
43
#include <X11/Xaw/Toggle.h>
44
#include <X11/Xmu/StdSel.h>
46
#include <X11/extensions/xf86vmode.h>
52
int MajorVersion, MinorVersion;
53
int EventBase, ErrorBase;
54
int dot_clock, mode_flags;
55
unsigned long TestTimeout=5000; /* Default test timeout */
58
/* Minimum extension version required */
62
/* Mode flags -- ignore flags not in V_FLAG_MASK */
63
#define V_FLAG_MASK 0x1FF;
64
#define V_PHSYNC 0x001
65
#define V_NHSYNC 0x002
66
#define V_PVSYNC 0x004
67
#define V_NVSYNC 0x008
68
#define V_INTERLACE 0x010
69
#define V_DBLSCAN 0x020
71
#define V_PCSYNC 0x080
72
#define V_NCSYNC 0x100
74
typedef enum { HDisplay, HSyncStart, HSyncEnd, HTotal,
75
VDisplay, VSyncStart, VSyncEnd, VTotal, Flags,
76
InvertVclk, BlankDelay1, BlankDelay2, EarlySc,
77
PixelClock, HSyncRate, VSyncRate, fields_num } fields;
89
static struct _AppResources {
90
ScrollData field[fields_num];
97
{ HSyncStart, HDisplay, },
98
{ HSyncEnd, HDisplay, },
99
{ HTotal, HDisplay, },
101
{ VSyncStart, VDisplay, },
102
{ VSyncEnd, VDisplay, },
103
{ VTotal, VDisplay, },
115
static XtResource Resources[] = {
116
{ "adInstalled", "AdInstalled", XtRBool, sizeof(Bool),
117
XtOffsetOf(struct _AppResources, ad_installed),
118
XtRImmediate, (XtPointer)FALSE },
119
{ "hSyncStartRange", "SyncStartRange", XtRInt, sizeof(int),
120
XtOffsetOf(struct _AppResources, field[HSyncStart].range),
121
XtRImmediate, (XtPointer)200 },
122
{ "hSyncEndRange", "SyncEndRange", XtRInt, sizeof(int),
123
XtOffsetOf(struct _AppResources, field[HSyncEnd].range),
124
XtRImmediate, (XtPointer)400 },
125
{ "hTotalRange", "TotalRange", XtRInt, sizeof(int),
126
XtOffsetOf(struct _AppResources, field[HTotal].range),
127
XtRImmediate, (XtPointer)400 },
128
{ "vSyncStartRange", "SyncStartRange", XtRInt, sizeof(int),
129
XtOffsetOf(struct _AppResources, field[VSyncStart].range),
130
XtRImmediate, (XtPointer)20 },
131
{ "vSyncEndRange", "SyncEndRange", XtRInt, sizeof(int),
132
XtOffsetOf(struct _AppResources, field[VSyncEnd].range),
133
XtRImmediate, (XtPointer)40 },
134
{ "vTotalRange", "TotalRange", XtRInt, sizeof(int),
135
XtOffsetOf(struct _AppResources, field[VTotal].range),
136
XtRImmediate, (XtPointer)80 },
139
static XtTranslations trans;
141
static Atom wm_delete_window;
142
static Widget invalid_mode_popup;
143
static Widget testing_popup;
145
static Widget auto_apply_toggle;
147
static Bool S3Specials = False;
148
static char modebuf[160];
150
static void UpdateSyncRates(Bool dolabels);
153
CleanUp(Display *dpy)
155
/* Make sure mode switching is not locked out at exit */
156
XF86VidModeLockModeSwitch(dpy, DefaultScreen(dpy), FALSE);
163
XtNoticeSignal(sigId);
167
CatchXtSig(XtPointer closure, XtSignalId *id)
169
CleanUp(XtDisplay(Top));
174
GetModeLine (Display* dpy, int scrn)
176
XF86VidModeModeLine mode_line;
179
if (!XF86VidModeGetModeLine (dpy, scrn, &dot_clock, &mode_line))
182
AppRes.field[HDisplay].val = mode_line.hdisplay;
183
AppRes.field[HSyncStart].val = mode_line.hsyncstart;
184
AppRes.field[HSyncEnd].val = mode_line.hsyncend;
185
AppRes.field[HTotal].val = mode_line.htotal;
186
AppRes.field[VDisplay].val = mode_line.vdisplay;
187
AppRes.field[VSyncStart].val = mode_line.vsyncstart;
188
AppRes.field[VSyncEnd].val = mode_line.vsyncend;
189
AppRes.field[VTotal].val = mode_line.vtotal;
190
mode_flags = mode_line.flags;
191
AppRes.field[Flags].val = mode_flags & V_FLAG_MASK;
192
AppRes.field[PixelClock].val = dot_clock;
193
UpdateSyncRates(FALSE);
194
if (mode_line.privsize && mode_line.private) {
196
AppRes.field[InvertVclk].val = mode_line.private[1];
197
AppRes.field[BlankDelay1].val = mode_line.private[2] & 7;
198
AppRes.field[BlankDelay2].val = (mode_line.private[2] >> 4) & 7;
199
AppRes.field[EarlySc].val = mode_line.private[3];
202
for (i = HDisplay; i < fields_num; i++)
203
AppRes.orig[i] = AppRes.field[i].val;
208
GetMonitor (Display* dpy, int scrn)
210
XF86VidModeMonitor monitor;
213
if (!XF86VidModeGetMonitor (dpy, scrn, &monitor))
216
printf("Vendor: %s, Model: %s\n", monitor.vendor, monitor.model);
217
printf("Num hsync: %d, Num vsync: %d\n", monitor.nhsync, monitor.nvsync);
218
for (i = 0; i < monitor.nhsync; i++) {
219
printf("hsync range %d: %6.2f - %6.2f\n", i, monitor.hsync[i].lo,
220
monitor.hsync[i].hi);
222
for (i = 0; i < monitor.nvsync; i++) {
223
printf("vsync range %d: %6.2f - %6.2f\n", i, monitor.vsync[i].lo,
224
monitor.vsync[i].hi);
232
if (AppRes.field[HTotal].val == 0 || AppRes.field[VTotal].val == 0)
237
static int hitError = 0;
238
static int (*xtErrorfunc)(Display *, XErrorEvent *);
241
vidmodeError(Display *dis, XErrorEvent *err)
243
if ((err->error_code >= ErrorBase &&
244
err->error_code < ErrorBase + XF86VidModeNumberErrors) ||
245
err->error_code == BadValue) {
250
(*xtErrorfunc)(dis, err);
252
return 0; /* ignored */
260
for (i = HDisplay; i <= Flags; i++) {
262
ScrollData* sdp = &AppRes.field[i];
264
if (sdp->scrollwidget != (Widget) NULL) {
268
base = AppRes.field[sdp->use].val;
269
percent = ((float)(sdp->val - base)) / ((float)sdp->range);
270
XawScrollbarSetThumb (sdp->scrollwidget, percent, 0.0);
276
QuitCB (Widget w, XtPointer client, XtPointer call)
278
CleanUp(XtDisplay(w));
279
#if XtSpecificationRelease < 6
282
XtAppSetExitFlag (XtWidgetToApplicationContext (w));
287
popdownInvalid(Widget w, XtPointer client, XtPointer call)
289
XtPopdown((Widget)client);
293
ApplyCB (Widget w, XtPointer client, XtPointer call)
295
XF86VidModeModeLine mode_line;
301
mode_line.hdisplay = AppRes.field[HDisplay].val;
302
mode_line.hsyncstart = AppRes.field[HSyncStart].val;
303
mode_line.hsyncend = AppRes.field[HSyncEnd].val;
304
mode_line.htotal = AppRes.field[HTotal].val;
305
mode_line.vdisplay = AppRes.field[VDisplay].val;
306
mode_line.vsyncstart = AppRes.field[VSyncStart].val;
307
mode_line.vsyncend = AppRes.field[VSyncEnd].val;
308
mode_line.vtotal = AppRes.field[VTotal].val;
309
/* Don't read flags from widget */
311
XtVaGetValues (AppRes.field[Flags].textwidget,
312
XtNstring, &string, NULL);
313
(void) sscanf (string, "%x", &i);
315
mode_line.flags = mode_flags;
317
mode_line.privsize = 4;
318
mode_line.private = S3private;
319
mode_line.private[0] = (1 << 1) | (1 << 2) | (1 << 3);
320
XtVaGetValues(AppRes.field[InvertVclk].textwidget,
321
XtNstate, &state, NULL);
322
AppRes.field[InvertVclk].val = state ? 1 : 0;
323
mode_line.private[1] = AppRes.field[InvertVclk].val;
324
XtVaGetValues (AppRes.field[BlankDelay1].textwidget,
325
XtNstring, &string, NULL);
326
(void) sscanf (string, "%x", &i);
327
AppRes.field[BlankDelay1].val = i;
328
mode_line.private[2] = AppRes.field[BlankDelay1].val;
329
XtVaGetValues (AppRes.field[BlankDelay2].textwidget,
330
XtNstring, &string, NULL);
331
(void) sscanf (string, "%x", &i);
332
AppRes.field[BlankDelay2].val = i;
333
mode_line.private[2] |= AppRes.field[BlankDelay2].val << 4;
334
XtVaGetValues(AppRes.field[EarlySc].textwidget,
335
XtNstate, &state, NULL);
336
AppRes.field[EarlySc].val = state ? 1 : 0;
337
mode_line.private[3] = AppRes.field[EarlySc].val;
339
mode_line.privsize = 0;
343
XF86VidModeModModeLine (XtDisplay (w), DefaultScreen (XtDisplay (w)),
345
XSync(XtDisplay (w), False); /* process errors */
347
XBell(XtDisplay (w), 80);
348
XtPopup(invalid_mode_popup, XtGrabExclusive /*XtGrabNone*/);
356
ScrollData* sdp = &AppRes.field[i];
358
if (sdp->textwidget != (Widget) NULL) {
363
* Disable AutoApply so that the apply doesn't happen more than
364
* once as a consequence of callbacks being called because of the
368
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
370
XtVaSetValues(auto_apply_toggle, XtNstate, 0, NULL);
373
(void) sprintf (buf, "%04x", sdp->val);
374
else if (i >= PixelClock && i <= VSyncRate)
375
(void) sprintf (buf, "%6.2f", (float)sdp->val / 1000.0);
376
else if (i == BlankDelay1 || i == BlankDelay2) {
377
(void) sprintf (buf, "%d", sdp->val);
379
(void) sprintf (buf, "%5d", sdp->val);
381
sdp->lastpercent = -1;
388
text.format = XawFmt8Bit;
389
XawTextReplace (sdp->textwidget, 0, 4, &text);
390
} else if (i == BlankDelay1 || i == BlankDelay2) {
396
XawTextReplace (sdp->textwidget, 0, 1, &text);
397
} else if (i == InvertVclk || i == EarlySc) {
398
XtVaSetValues (sdp->textwidget, XtNstate, sdp->val, NULL);
400
XtVaSetValues (sdp->textwidget, XtNlabel, buf, NULL);
403
XtVaSetValues(auto_apply_toggle, XtNstate, 1, NULL);
409
UpdateSyncRates(Bool dolabels)
414
AppRes.field[HSyncRate].val = AppRes.field[PixelClock].val * 1000 /
415
AppRes.field[HTotal].val;
416
AppRes.field[VSyncRate].val = AppRes.field[HSyncRate].val * 1000 /
417
AppRes.field[VTotal].val;
418
if (mode_flags & V_INTERLACE)
419
AppRes.field[VSyncRate].val *= 2;
420
else if (mode_flags & V_DBLSCAN)
421
AppRes.field[VSyncRate].val /= 2;
429
RestoreCB (Widget w, XtPointer client, XtPointer call)
434
for (i = HDisplay; i < fields_num; i++) {
435
AppRes.field[i].val = AppRes.orig[i];
439
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
441
ApplyCB (w, client, call);
446
ApplyIfAutoCB (Widget w, XtPointer client, XtPointer call)
450
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
452
ApplyCB (w, client, call);
457
FetchCB (Widget w, XtPointer client, XtPointer call)
460
(void) GetModeLine(XtDisplay (w), DefaultScreen (XtDisplay (w)));
462
for (i = HDisplay; i < fields_num; i++) {
467
static XtIntervalId TOid;
470
TestTO (XtPointer client, XtIntervalId* id)
473
for (i = HDisplay; i < fields_num; i++)
474
AppRes.field[i].val = AppRes.orig[i];
476
ApplyCB ((Widget) client, NULL, NULL);
478
for (i = HDisplay; i < fields_num; i++)
479
AppRes.field[i].val = AppRes.old[i];
482
XtPopdown(testing_popup);
486
TestTOCB (Widget w, XtPointer client, XtPointer call)
488
XtRemoveTimeOut(TOid);
489
TestTO(w, (XtIntervalId *) NULL);
493
TestCB (Widget w, XtPointer client, XtPointer call)
496
for (i = HDisplay; i < fields_num; i++)
497
AppRes.old[i] = AppRes.field[i].val;
499
XtPopup(testing_popup, XtGrabExclusive /*XtGrabNone*/);
500
XSync(XtDisplay(w), False);
501
TOid = XtAppAddTimeOut (XtWidgetToApplicationContext (w),
502
TestTimeout, TestTO, (XtPointer) w);
504
ApplyCB (w, client, call);
510
Atom *selection, Atom *target, Atom *type,
512
unsigned long *length,
515
if (XmuConvertStandardSelection(w, CurrentTime, selection, target, type,
516
(XPointer *) value, length, format))
519
if (*target == XA_STRING) {
522
*length = strlen(*value);
530
ShowCB(Widget w, XtPointer client, XtPointer call)
535
sprintf(tmpbuf, "\"%dx%d\"",
536
AppRes.field[HDisplay].val, AppRes.field[VDisplay].val);
537
sprintf(modebuf, "%-11s %6.2f %4d %4d %4d %4d %4d %4d %4d %4d",
538
tmpbuf, (float)dot_clock/1000.0,
539
AppRes.field[HDisplay].val,
540
AppRes.field[HSyncStart].val,
541
AppRes.field[HSyncEnd].val,
542
AppRes.field[HTotal].val,
543
AppRes.field[VDisplay].val,
544
AppRes.field[VSyncStart].val,
545
AppRes.field[VSyncEnd].val,
546
AppRes.field[VTotal].val);
547
/* Print out the flags (if any) */
548
if (mode_flags & V_PHSYNC) strcat(modebuf, " +hsync");
549
if (mode_flags & V_NHSYNC) strcat(modebuf, " -hsync");
550
if (mode_flags & V_PVSYNC) strcat(modebuf, " +vsync");
551
if (mode_flags & V_NVSYNC) strcat(modebuf, " -vsync");
552
if (mode_flags & V_INTERLACE) strcat(modebuf, " interlace");
553
if (mode_flags & V_CSYNC) strcat(modebuf, " composite");
554
if (mode_flags & V_PCSYNC) strcat(modebuf, " +csync");
555
if (mode_flags & V_NCSYNC) strcat(modebuf, " -csync");
556
if (mode_flags & V_DBLSCAN) strcat(modebuf, " doublescan");
557
printf("%s\n", modebuf);
558
time = XtLastTimestampProcessed(XtDisplay(w));
559
XtOwnSelection(w, XA_PRIMARY, time, ConvertSelection, NULL, NULL);
565
XtVaGetValues(AppRes.field[InvertVclk].textwidget,
566
XtNstate, &state, NULL);
567
AppRes.field[InvertVclk].val = state ? 1 : 0;
568
XtVaGetValues (AppRes.field[BlankDelay1].textwidget,
569
XtNstring, &string, NULL);
570
(void) sscanf (string, "%x", &i);
571
AppRes.field[BlankDelay1].val = i;
572
XtVaGetValues (AppRes.field[BlankDelay2].textwidget,
573
XtNstring, &string, NULL);
574
(void) sscanf (string, "%x", &i);
575
AppRes.field[BlankDelay2].val = i;
576
XtVaGetValues(AppRes.field[EarlySc].textwidget,
577
XtNstate, &state, NULL);
578
AppRes.field[EarlySc].val = state ? 1 : 0;
579
if (AppRes.field[InvertVclk].val != AppRes.orig[InvertVclk])
580
printf("InvertVCLK\t\"%dx%d\" %d\n", AppRes.field[HDisplay].val,
581
AppRes.field[VDisplay].val, AppRes.field[InvertVclk].val);
582
if (AppRes.field[EarlySc].val != AppRes.orig[EarlySc])
583
printf("EarlySC\t\t\"%dx%d\" %d\n", AppRes.field[HDisplay].val,
584
AppRes.field[VDisplay].val, AppRes.field[EarlySc].val);
585
if (AppRes.field[BlankDelay1].val != AppRes.orig[BlankDelay1]
586
|| AppRes.field[BlankDelay2].val != AppRes.orig[BlankDelay2])
587
printf("BlankDelay\t\"%dx%d\" %d %d\n", AppRes.field[HDisplay].val,
588
AppRes.field[VDisplay].val, AppRes.field[BlankDelay1].val,
589
AppRes.field[BlankDelay2].val);
595
AdjustCB(Widget w, XtPointer client, XtPointer call)
597
int what = (long) client;
602
if (AppRes.field[HSyncEnd].val + 4 < AppRes.field[HTotal].val) {
603
AppRes.field[HSyncEnd].val += 4;
604
AppRes.field[HSyncStart].val += 4;
605
SetLabel(HSyncStart);
608
XBell(XtDisplay(w), 80);
611
if (AppRes.field[HSyncStart].val - 4 > AppRes.field[HDisplay].val) {
612
AppRes.field[HSyncEnd].val -= 4;
613
AppRes.field[HSyncStart].val -= 4;
614
SetLabel(HSyncStart);
617
XBell(XtDisplay(w), 80);
620
AppRes.field[HTotal].val += 4;
622
UpdateSyncRates(TRUE);
625
if (AppRes.field[HTotal].val - 4 > AppRes.field[HSyncEnd].val) {
626
AppRes.field[HTotal].val -= 4;
628
UpdateSyncRates(TRUE);
630
XBell(XtDisplay(w), 80);
633
if (AppRes.field[VSyncEnd].val + 4 < AppRes.field[VTotal].val) {
634
AppRes.field[VSyncEnd].val += 4;
635
AppRes.field[VSyncStart].val += 4;
636
SetLabel(VSyncStart);
639
XBell(XtDisplay(w), 80);
642
if (AppRes.field[VSyncStart].val - 4 > AppRes.field[VDisplay].val) {
643
AppRes.field[VSyncEnd].val -= 4;
644
AppRes.field[VSyncStart].val -= 4;
645
SetLabel(VSyncStart);
648
XBell(XtDisplay(w), 80);
651
AppRes.field[VTotal].val += 4;
653
UpdateSyncRates(TRUE);
656
if (AppRes.field[VTotal].val - 4 > AppRes.field[VSyncEnd].val) {
657
AppRes.field[VTotal].val -= 4;
659
UpdateSyncRates(TRUE);
661
XBell(XtDisplay(w), 80);
665
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
667
ApplyCB (w, client, call);
673
EditCB (Widget w, XtPointer client, XtPointer call)
675
int base, current, i, len;
678
ScrollData* sdp = (ScrollData*) client;
680
len = strlen (sdp->string);
682
for (i = 0; i < len; i++) {
683
if (!(isdigit (sdp->string[i]) || isspace (sdp->string[i]))) {
684
XBell (XtDisplay(XtParent(w)), 100);
690
lower = atoi (AppRes.field[HDisplay].string);
691
upper = atoi (AppRes.field[HSyncEnd].string);
695
lower = atoi (AppRes.field[HSyncStart].string);
696
upper = atoi (AppRes.field[HTotal].string);
700
lower = atoi (AppRes.field[HSyncEnd].string);
701
upper = atoi (AppRes.field[HDisplay].string) +
702
AppRes.field[HTotal].range;
706
lower = atoi (AppRes.field[VDisplay].string);
707
upper = atoi (AppRes.field[VSyncEnd].string);
711
lower = atoi (AppRes.field[VSyncStart].string);
712
upper = atoi (AppRes.field[VTotal].string);
716
lower = atoi (AppRes.field[VSyncEnd].string);
717
upper = atoi (AppRes.field[VDisplay].string) +
718
AppRes.field[VTotal].range;
721
current = atoi (sdp->string);
722
if (current < lower || current > upper) {
726
if (current < lower) {
727
(void) sprintf (tmp, "%5d", lower);
730
(void) sprintf (tmp, "%5d", upper);
734
text.length = strlen (tmp);
736
text.format = XawFmt8Bit;
737
XawTextReplace (sdp->textwidget, 0, text.length, &text);
739
base = atoi (AppRes.field[sdp->use].string);
740
percent = ((float)(current - base)) / ((float)sdp->range);
741
XawScrollbarSetThumb (sdp->scrollwidget, percent, 0.0);
746
FlagsEditCB (Widget w, XtPointer client, XtPointer call)
750
fields findex = (fields) (unsigned long) client;
751
ScrollData* sdp = &AppRes.field[findex];
753
XtVaGetValues (w, XtNstring, &string, NULL);
754
len = strlen (string);
758
XBell (XtDisplay(XtParent(w)), 100);
759
(void) strncpy (buf, string, 4);
761
XtVaSetValues (sdp->textwidget, XtNstring, buf, NULL);
762
XawTextSetInsertionPoint (sdp->textwidget, 4);
765
for (i = 0; i < len; i++) {
766
if (!isxdigit (string[i])) {
767
XBell (XtDisplay(XtParent(w)), 100);
773
BlankEditCB (Widget w, XtPointer client, XtPointer call)
777
fields findex = (fields) (unsigned long) client;
778
ScrollData* sdp = &AppRes.field[findex];
781
Boolean noAuto = False;
783
XtVaGetValues (w, XtNstring, &string, NULL);
784
len = strlen (string);
786
XBell (XtDisplay(XtParent(w)), 100);
788
XtVaSetValues (sdp->textwidget, XtNstring, buf, NULL);
789
XawTextSetInsertionPoint (sdp->textwidget, 1);
793
if (XawTextGetInsertionPoint(sdp->textwidget) < 1) {
800
if (buf[0] == '+' && old < '7')
802
else if (buf[0] == '-' && old > '0')
804
if (!isdigit(buf[0]) || buf[0] > '7') {
805
XBell (XtDisplay(XtParent(w)), 100);
807
if (!isdigit(buf[0]) || buf[0] > '7')
812
XtVaSetValues (sdp->textwidget, XtNstring, buf, NULL);
813
XawTextSetInsertionPoint (sdp->textwidget, 1);
815
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
816
if (state && !noAuto)
817
ApplyCB (sdp->textwidget, client, call);
821
ChangeBlankCB (Widget w, XtPointer client, XtPointer call)
828
int what = (long) client;
832
findex = (fields)-what;
834
findex = (fields)what;
835
sdp = &AppRes.field[findex];
837
XtVaGetValues (sdp->textwidget, XtNstring, &string, NULL);
843
if (string[0] < '0' || string[0] > '7') {
844
XBell (XtDisplay(XtParent(w)), 100);
850
XtVaSetValues (sdp->textwidget, XtNstring, buf, NULL);
851
XawTextSetInsertionPoint (sdp->textwidget, 1);
853
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
855
ApplyCB (sdp->textwidget, client, call);
859
isValid(int val, int field)
863
if (val+8 > AppRes.field[HSyncEnd].val)
864
val = AppRes.field[HSyncEnd].val - 8;
867
if (val-8 < AppRes.field[HSyncStart].val)
868
val = AppRes.field[HSyncStart].val + 8;
869
if (val > AppRes.field[HTotal].val)
870
val = AppRes.field[HTotal].val;
873
if (val < AppRes.field[HSyncEnd].val)
874
val = AppRes.field[HSyncEnd].val;
877
if (val+8 > AppRes.field[VSyncEnd].val)
878
val = AppRes.field[VSyncEnd].val - 8;
881
if (val-8 < AppRes.field[VSyncStart].val)
882
val = AppRes.field[VSyncStart].val + 8;
883
if (val > AppRes.field[VTotal].val)
884
val = AppRes.field[VTotal].val;
887
if (val < AppRes.field[VSyncEnd].val)
888
val = AppRes.field[VSyncEnd].val;
895
ScrollCB (Widget w, XtPointer client, XtPointer call)
897
float percent = *(float*) call;
898
int ipercent = percent * 100;
899
int fieldindex = (long) client;
900
ScrollData* sdp = &AppRes.field[fieldindex];
904
if (ipercent != sdp->lastpercent) {
908
tmp_val = AppRes.field[sdp->use].val;
909
tmp_val += (int) (((float)sdp->range) * percent);
911
sdp->val = isValid(tmp_val, fieldindex);
913
sdp->lastpercent = ipercent;
914
(void) sprintf (buf, "%5d", sdp->val);
915
XtVaSetValues (sdp->textwidget, XtNlabel, buf, NULL);
916
if (sdp->val != tmp_val) {
920
base = AppRes.field[sdp->use].val;
921
percent = ((float)(sdp->val - base)) / ((float)sdp->range);
922
/* This doesn't always work, why? */
923
XawScrollbarSetThumb (sdp->scrollwidget, percent, 0.0);
925
if (fieldindex == HTotal || fieldindex == VTotal)
926
UpdateSyncRates(TRUE);
931
SwitchCB (Widget w, XtPointer client, XtPointer call)
933
XF86VidModeLockModeSwitch(XtDisplay(w), DefaultScreen (XtDisplay (w)),
935
XF86VidModeSwitchMode(XtDisplay(w), DefaultScreen (XtDisplay (w)),
937
XF86VidModeLockModeSwitch(XtDisplay(w), DefaultScreen (XtDisplay (w)),
939
FetchCB(w, NULL, NULL);
945
String callback_name,
946
XtCallbackProc callback,
947
XtPointer client_data)
951
XtVaGetValues (w, XtNtextSource, &src, NULL);
952
XtAddCallback (src, callback_name, callback, client_data);
966
wids[0] = XtCreateWidget (w1name, labelWidgetClass, form, NULL, 0);
967
if (findex >= PixelClock && findex <= VSyncRate)
968
(void) sprintf(buf, "%6.2f", (float)AppRes.field[findex].val / 1000.0);
970
(void) sprintf (buf, "%5d", AppRes.field[findex].val);
971
wids[1] = XtVaCreateWidget (w2name, labelWidgetClass,
972
form, XtNlabel, buf, NULL);
973
if (w3name != NULL) {
974
wids[2] = XtCreateWidget (w3name, scrollbarWidgetClass, form, NULL, 0);
975
XtAddCallback (wids[2], XtNjumpProc, ScrollCB, (XtPointer) findex);
976
XtManageChildren (wids, 3);
978
wids[2] = (Widget) NULL;
979
XtManageChildren (wids, 2);
981
AppRes.field[findex].textwidget = wids[1];
982
AppRes.field[findex].scrollwidget = wids[2];
987
AckWarn (Widget w, XtPointer client, XtPointer call)
989
XtPopdown((Widget) client);
990
XtDestroyWidget((Widget) client);
994
AckNoTune (Widget w, XtPointer client, XtPointer call)
996
CleanUp(XtDisplay(w));
997
#if XtSpecificationRelease < 6
1000
XtAppSetExitFlag (XtWidgetToApplicationContext (w));
1005
displayWarning(Widget top)
1007
Widget w, popup, popupBox;
1010
x = DisplayWidth(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 3;
1011
y = DisplayHeight(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 3;
1013
popup = XtVaCreatePopupShell("Warning",
1014
transientShellWidgetClass, top,
1015
XtNtitle, "WARNING",
1020
popupBox = XtVaCreateManagedWidget(
1026
w = XtVaCreateManagedWidget( "WarnLabel",
1031
w = XtVaCreateManagedWidget( "WarnOK",
1036
XtAddCallback (w, XtNcallback, AckWarn, (XtPointer)popup);
1038
w = XtVaCreateManagedWidget( "WarnCancel",
1042
XtAddCallback (w, XtNcallback, QuitCB, (XtPointer)NULL);
1044
XtPopup(popup, XtGrabExclusive);
1049
displayNoTune(Widget top)
1051
Widget w, popup, popupBox;
1053
popup = XtCreateWidget ("Notice", formWidgetClass, top, NULL, 0);
1054
popupBox = XtVaCreateManagedWidget(
1060
w = XtVaCreateManagedWidget( "NoTuneLabel",
1065
w = XtVaCreateManagedWidget( "NoTuneOK",
1070
XtAddCallback (w, XtNcallback, AckNoTune, (XtPointer)popup);
1072
XtManageChild (popup);
1077
s3Special(Widget top)
1079
Widget w, popup, form, invert_vclk_toggle, wids[6];
1080
char buf1[5] = {'\0',};
1083
x = DisplayWidth(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 3;
1084
y = DisplayHeight(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 3;
1086
popup = XtVaCreatePopupShell("S3Adjust",
1087
transientShellWidgetClass, top,
1088
XtNtitle, "S3Adjust",
1093
form = XtVaCreateManagedWidget(
1099
w = XtVaCreateManagedWidget( "S3Title",
1104
invert_vclk_toggle = XtVaCreateManagedWidget( "InvertVclk-toggle",
1109
wids[0] = XtCreateWidget ("Blank1-label", labelWidgetClass,
1111
wids[1] = XtVaCreateWidget ("Blank1-text", asciiTextWidgetClass,
1112
form, XtNstring, buf1, NULL);
1113
AddCallback (wids[1], XtNcallback, FlagsEditCB, (XtPointer) NULL);
1115
XtManageChildren (wids, 2);
1117
XtPopup(popup, XtGrabNone);
1125
CreateHierarchy(Widget top)
1128
Widget form, forms[14], s3form;
1130
Widget boxW, popdownW, w;
1133
static String form_names[] = {
1150
form = XtCreateWidget ("form", formWidgetClass, top, NULL, 0);
1151
for (i = 0; i < 14; i++)
1152
forms[i] = XtCreateWidget (form_names[i], formWidgetClass,
1155
CreateTyp (forms[0], HDisplay, "HDisplay-label", "HDisplay-text", NULL);
1156
CreateTyp (forms[1], HSyncStart, "HSyncStart-label",
1157
"HSyncStart-text", "HSyncStart-scrollbar");
1158
CreateTyp (forms[2], HSyncEnd, "HSyncEnd-label", "HSyncEnd-text",
1159
"HSyncEnd-scrollbar");
1160
CreateTyp (forms[3], HTotal, "HTotal-label", "HTotal-text",
1161
"HTotal-scrollbar");
1163
w = XtVaCreateManagedWidget(
1168
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)HSyncStart);
1169
w = XtVaCreateManagedWidget(
1174
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)-HSyncStart);
1175
w= XtVaCreateManagedWidget(
1180
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)-HTotal);
1181
w = XtVaCreateManagedWidget(
1186
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)HTotal);
1187
CreateTyp (forms[4], VDisplay, "VDisplay-label", "VDisplay-text", NULL);
1188
CreateTyp (forms[5], VSyncStart, "VSyncStart-label",
1189
"VSyncStart-text", "VSyncStart-scrollbar");
1190
CreateTyp (forms[6], VSyncEnd, "VSyncEnd-label", "VSyncEnd-text",
1191
"VSyncEnd-scrollbar");
1192
CreateTyp (forms[7], VTotal, "VTotal-label", "VTotal-text",
1193
"VTotal-scrollbar");
1194
w = XtVaCreateManagedWidget(
1199
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)VSyncStart);
1200
w = XtVaCreateManagedWidget(
1205
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)-VSyncStart);
1206
w= XtVaCreateManagedWidget(
1211
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)VTotal);
1212
w = XtVaCreateManagedWidget(
1217
XtAddCallback (w, XtNcallback, AdjustCB, (XtPointer)-VTotal);
1219
(void) sprintf (buf, "%04x", AppRes.field[Flags].val);
1220
wids[0] = XtCreateWidget ("Flags-label", labelWidgetClass,
1222
wids[1] = XtVaCreateWidget ("Flags-text", asciiTextWidgetClass,
1223
forms[8], XtNstring, buf, XtNtranslations, trans, NULL);
1224
AddCallback (wids[1], XtNcallback, FlagsEditCB, (XtPointer) Flags);
1225
XtManageChildren (wids, 2);
1226
AppRes.field[Flags].textwidget = wids[1];
1228
wids[0] = XtCreateWidget ("Quit-button", commandWidgetClass,
1230
XtAddCallback (wids[0], XtNcallback, QuitCB, NULL);
1232
wids[1] = XtCreateWidget ("Apply-button", commandWidgetClass,
1234
XtAddCallback (wids[1], XtNcallback, ApplyCB, NULL);
1236
wids[2] = XtCreateWidget ("AutoApply-toggle", toggleWidgetClass,
1238
auto_apply_toggle = wids[2];
1240
wids[3] = XtCreateWidget ("Test-button", commandWidgetClass,
1242
XtAddCallback (wids[3], XtNcallback, TestCB, NULL);
1244
wids[4] = XtCreateWidget ("Restore-button", commandWidgetClass,
1246
XtAddCallback (wids[4], XtNcallback, RestoreCB, NULL);
1248
XtManageChildren (wids, 5);
1251
CreateTyp (forms[10], PixelClock, "PixelClock-label", "PixelClock-text",
1253
CreateTyp (forms[11], HSyncRate, "HSyncRate-label", "HSyncRate-text",
1255
CreateTyp (forms[12], VSyncRate, "VSyncRate-label", "VSyncRate-text",
1258
wids[0] = XtCreateWidget ("Fetch-button", commandWidgetClass,
1259
forms[13], NULL, 0);
1260
XtAddCallback (wids[0], XtNcallback, FetchCB, NULL);
1262
wids[1] = XtCreateWidget ("Show-button", commandWidgetClass,
1263
forms[13], NULL, 0);
1264
XtAddCallback (wids[1], XtNcallback, ShowCB, NULL);
1266
wids[2] = XtCreateWidget ("Next-button", commandWidgetClass,
1267
forms[13], NULL, 0);
1268
XtAddCallback (wids[2], XtNcallback, SwitchCB, (XtPointer)1);
1270
wids[3] = XtCreateWidget ("Prev-button", commandWidgetClass,
1271
forms[13], NULL, 0);
1272
XtAddCallback (wids[3], XtNcallback, SwitchCB, (XtPointer)-1);
1274
XtManageChildren (wids, 4);
1276
XtManageChildren (forms, 14);
1280
s3form = XtCreateWidget ("S3-form", formWidgetClass,
1282
wids[0] = XtVaCreateWidget("InvertVclk-toggle", toggleWidgetClass,
1283
s3form, XtNstate, AppRes.field[InvertVclk].val, NULL);
1284
XtAddCallback (wids[0], XtNcallback, ApplyIfAutoCB, NULL);
1285
AppRes.field[InvertVclk].textwidget = wids[0];
1286
wids[1] = XtVaCreateWidget("EarlySc-toggle", toggleWidgetClass,
1287
s3form, XtNstate, AppRes.field[EarlySc].val, NULL);
1288
XtAddCallback (wids[1], XtNcallback, ApplyIfAutoCB, NULL);
1289
AppRes.field[EarlySc].textwidget = wids[1];
1290
wids[2] = XtCreateWidget("Blank1-label", labelWidgetClass, s3form,
1292
wids[3] = XtVaCreateWidget("Blank1Dec-button", commandWidgetClass,
1294
XtAddCallback (wids[3], XtNcallback, ChangeBlankCB,
1295
(XtPointer)-BlankDelay1);
1296
(void) sprintf (buf, "%d", AppRes.field[BlankDelay1].val);
1297
wids[4] = XtVaCreateWidget("Blank1-text", asciiTextWidgetClass,
1298
s3form, XtNstring, buf, XtNtranslations, trans, NULL);
1299
AddCallback(wids[4], XtNcallback, BlankEditCB, (XPointer) BlankDelay1);
1300
AppRes.field[BlankDelay1].textwidget = wids[4];
1301
wids[5] = XtVaCreateWidget("Blank1Inc-button", commandWidgetClass,
1303
XtAddCallback (wids[5], XtNcallback, ChangeBlankCB,
1304
(XtPointer)BlankDelay1);
1306
wids[6] = XtCreateWidget("Blank2-label", labelWidgetClass, s3form,
1308
wids[7] = XtVaCreateWidget("Blank2Dec-button", commandWidgetClass,
1310
XtAddCallback (wids[7], XtNcallback, ChangeBlankCB,
1311
(XtPointer)-BlankDelay2);
1312
(void) sprintf (buf, "%d", AppRes.field[BlankDelay2].val);
1313
wids[8] = XtVaCreateWidget("Blank2-text", asciiTextWidgetClass,
1314
s3form, XtNstring, buf, XtNtranslations, trans, NULL);
1315
AddCallback(wids[8], XtNcallback, BlankEditCB, (XPointer) BlankDelay2);
1316
AppRes.field[BlankDelay2].textwidget = wids[8];
1317
wids[9] = XtVaCreateWidget("Blank2Inc-button", commandWidgetClass,
1319
XtAddCallback (wids[9], XtNcallback, ChangeBlankCB,
1320
(XtPointer)BlankDelay2);
1321
XtManageChildren (wids, 10);
1322
XtManageChild(s3form);
1325
XtManageChild (form);
1328
x = DisplayWidth(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 2;
1329
y = DisplayHeight(XtDisplay (top),DefaultScreen (XtDisplay (top))) / 2;
1331
invalid_mode_popup = XtVaCreatePopupShell("invalidMode",
1332
transientShellWidgetClass, top,
1333
XtNtitle, "Invalid Mode requested",
1338
testing_popup = XtVaCreatePopupShell("testing",
1339
transientShellWidgetClass, top,
1340
XtNtitle, "Testing_1_2_3",
1344
boxW = XtVaCreateManagedWidget(
1350
w = XtVaCreateManagedWidget(
1356
w = XtVaCreateManagedWidget(
1362
XtAddCallback (w, XtNcallback, (XtCallbackProc) TestTOCB,
1365
boxW = XtVaCreateManagedWidget(
1371
(void) XtVaCreateManagedWidget(
1377
popdownW = XtVaCreateManagedWidget(
1383
XtAddCallback (popdownW, XtNcallback, (XtCallbackProc)popdownInvalid,
1384
(XtPointer) invalid_mode_popup);
1388
QuitAction (Widget w, XEvent* e, String* vector, Cardinal* count)
1390
if ((e->type == ClientMessage
1391
&& e->xclient.data.l[0] == (long) wm_delete_window)
1392
|| e->type == KeyPress)
1393
QuitCB(w, NULL, NULL);
1397
RestoreAction (Widget w, XEvent* e, String* vector, Cardinal* count)
1401
RestoreCB(w, NULL, NULL);
1402
XtVaGetValues(auto_apply_toggle, XtNstate, &state, NULL);
1404
ApplyCB (w, NULL, NULL);
1409
ShowAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1411
ShowCB(w, NULL, NULL);
1415
MoveLeftAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1417
AdjustCB(w, (XtPointer)HSyncStart, NULL);
1421
MoveRightAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1423
AdjustCB(w, (XtPointer)-HSyncStart, NULL);
1427
NarrowerAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1429
AdjustCB(w, (XtPointer)HTotal, NULL);
1433
WiderAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1435
AdjustCB(w, (XtPointer)-HTotal, NULL);
1439
MoveUpAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1441
AdjustCB(w, (XtPointer)VSyncStart, NULL);
1445
MoveDownAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1447
AdjustCB(w, (XtPointer)-VSyncStart, NULL);
1451
TallerAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1453
AdjustCB(w, (XtPointer)-VTotal, NULL);
1457
ShorterAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1459
AdjustCB(w, (XtPointer)VTotal, NULL);
1463
NextModeAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1465
SwitchCB(w, (XPointer) 1, NULL);
1469
PrevModeAction(Widget w, XEvent* e, String* vector, Cardinal* count)
1471
SwitchCB(w, (XPointer) -1, NULL);
1479
fprintf(stderr, "Usage: xvidtune [option]\n");
1480
fprintf(stderr, " where option is one of:\n");
1481
fprintf(stderr, " -show Print current modeline to stdout\n");
1482
fprintf(stderr, " -next Switch to next video mode\n");
1483
fprintf(stderr, " -prev Switch to previous video mode\n");
1484
fprintf(stderr, " -unlock Enable mode switch hot-keys\n");
1485
fprintf(stderr, " -timeout [seconds] Set testmode timeout in seconds,\n");
1491
main (int argc, char** argv)
1496
Bool modeSettable = TRUE;
1498
static XtActionsRec actions[] = { { "xvidtune-quit", QuitAction },
1499
{ "xvidtune-restore", RestoreAction },
1500
{ "xvidtune-show", ShowAction },
1501
{ "xvidtune-moveleft", MoveLeftAction },
1502
{ "xvidtune-moveright", MoveRightAction },
1503
{ "xvidtune-wider", WiderAction },
1504
{ "xvidtune-narrower", NarrowerAction },
1505
{ "xvidtune-moveup", MoveUpAction },
1506
{ "xvidtune-movedown", MoveDownAction },
1507
{ "xvidtune-taller", TallerAction },
1508
{ "xvidtune-shorter", ShorterAction },
1509
{ "xvidtune-nextmode", NextModeAction },
1510
{ "xvidtune-prevmode", PrevModeAction } };
1512
Top = top = XtVaOpenApplication (&app, "Xvidtune", NULL, 0, &argc, argv,
1513
NULL, applicationShellWidgetClass,
1514
XtNmappedWhenManaged, False, NULL);
1516
XtGetApplicationResources (top, (XtPointer)&AppRes,
1517
Resources, XtNumber(Resources),
1520
if (!AppRes.ad_installed) {
1521
fprintf(stderr, "Please install the program before using\n");
1525
if (!XF86VidModeQueryVersion(XtDisplay (top), &MajorVersion, &MinorVersion)) {
1526
fprintf(stderr, "Unable to query video extension version\n");
1530
if (!XF86VidModeQueryExtension(XtDisplay (top), &EventBase, &ErrorBase)) {
1531
fprintf(stderr, "Unable to query video extension information\n");
1535
/* Fail if the extension version in the server is too old */
1536
if (MajorVersion < MINMAJOR ||
1537
(MajorVersion == MINMAJOR && MinorVersion < MINMINOR)) {
1539
"Xserver is running an old XFree86-VidModeExtension version"
1540
" (%d.%d)\n", MajorVersion, MinorVersion);
1541
fprintf(stderr, "Minimum required version is %d.%d\n",
1542
MINMAJOR, MINMINOR);
1546
/* This should probably be done differently */
1548
if( argc == 3 ) { /* this can only be the timeout case */
1549
if( (!strcmp(argv[1], "-timeout")) ) {
1550
TestTimeout = ((unsigned long) atol( argv[2] )) * 1000L;
1561
if (!strcmp(argv[1], "-show")) {
1562
if (!GetModeLine(XtDisplay (top), DefaultScreen (XtDisplay (top)))) {
1563
fprintf(stderr, "Unable to get mode info\n");
1564
CleanUp(XtDisplay (top));
1567
ShowCB(top, NULL, NULL);
1569
} else if (!strcmp(argv[1], "-next"))
1571
else if (!strcmp(argv[1], "-prev"))
1573
else if (!strcmp(argv[1], "-unlock")) {
1574
CleanUp(XtDisplay (top));
1575
XSync(XtDisplay (top), True);
1580
XF86VidModeSwitchMode(XtDisplay (top),
1581
DefaultScreen (XtDisplay (top)), i);
1582
XSync(XtDisplay (top), True);
1586
if (!GetMonitor(XtDisplay (top), DefaultScreen (XtDisplay (top)))) {
1587
fprintf(stderr, "Unable to query monitor info\n");
1591
if (!XF86VidModeLockModeSwitch(XtDisplay (top),
1592
DefaultScreen (XtDisplay (top)), TRUE)) {
1593
fprintf(stderr, "Failed to disable mode-switch hot-keys\n");
1597
signal(SIGINT, CatchSig);
1598
signal(SIGQUIT, CatchSig);
1599
signal(SIGTERM, CatchSig);
1600
signal(SIGHUP, CatchSig);
1601
sigId = XtAppAddSignal(app, CatchXtSig, NULL);
1603
if (!GetModeLine(XtDisplay (top), DefaultScreen (XtDisplay (top)))) {
1604
fprintf(stderr, "Unable to get mode info\n");
1605
CleanUp(XtDisplay (top));
1609
xtErrorfunc = XSetErrorHandler(vidmodeError);
1611
trans = XtParseTranslationTable ("\
1612
<Key>0: insert-char()\n<Key>1: insert-char()\n\
1613
<Key>2: insert-char()\n<Key>3: insert-char()\n\
1614
<Key>4: insert-char()\n<Key>5: insert-char()\n\
1615
<Key>6: insert-char()\n<Key>7: insert-char()\n\
1616
<Key>8: insert-char()\n<Key>9: insert-char()\n\
1617
<Key>a: insert-char()\n<Key>b: insert-char()\n\
1618
<Key>c: insert-char()\n<Key>d: insert-char()\n\
1619
<Key>e: insert-char()\n<Key>f: insert-char()\n\
1620
<Key>+: insert-char()\n<Key>-: insert-char()\n\
1621
<Key>r: xvidtune-restore()\n<Key>q: xvidtune-quit()\n\
1622
<Key>BackSpace: delete-previous-character()\n\
1623
<Key>Right: forward-character()\n<Key>KP_Right: forward-character()\n\
1624
<Key>Left: backward-character()\n<Key>KP_Left: backward-character()\n\
1625
<Key>Delete: delete-previous-character()\n\
1626
<Key>KP_Delete: delete-previous-character()\n\
1627
<EnterWindow>: enter-window()\n<LeaveWindow>: leave-window()\n\
1628
<FocusIn>: focus-in()\n<FocusOut>: focus-out()\n\
1629
<Btn1Down>: select-start()\n");
1631
if (!ModeSettable()) {
1632
printf("Video are not settable on this chip\n");
1634
modeSettable = FALSE;
1636
CreateHierarchy (top);
1639
XtAppAddActions (app, actions, XtNumber(actions));
1641
XtOverrideTranslations (top,
1642
XtParseTranslationTable ("<Message>WM_PROTOCOLS: xvidtune-quit()"));
1644
XtRealizeWidget (top);
1646
dpy = XtDisplay(top);
1648
wm_delete_window = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
1650
(void) XSetWMProtocols (dpy, XtWindow (top), &wm_delete_window, 1);
1655
displayWarning(top);
1657
/* really we should run our own event dispatching here until the
1658
* warning has been read...
1660
XtAppMainLoop (app);