~ubuntu-branches/debian/sid/xscreensaver/sid

« back to all changes in this revision

Viewing changes to hacks/xsublim.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Rivas, Tormod Volden, Jose Luis Rivas
  • Date: 2008-07-15 14:48:48 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080715144848-c6c6mhyxij0dk2p7
Tags: 5.05-3
[ Tormod Volden ]
* debian/patches/10_jwz-xscreensaver-randr-patch-3.patch:
  from upstream, addresses issues with xrandr/xinerama
  (Closes: #482385, #428797, #471920, #453708, #473681, #479715, #480231)
* fixed typo "screen < real_nscreens" in driver/lock:1527 from above patch
* drop 61_DualHead-nVidia_bug471920.patch (obsolete)
* drop 67_XineRama-mode_bug473681.patch (obsolete)
* fix m6502.o typo in hacks/Makefile.in
* refresh 53_XScreenSaver.ad.in.patch
* refresh (disabled) 60_add-ant-hack.patch

[ Jose Luis Rivas ]
* add xscreensaver-demo desktop file, thanks to Daniel Dickinson
  (Closes: #480592)
* update package descriptions (thanks jwz)
* fix categories in xscreensaver.menu
* change build-deps from xlibmesa-gl-dev to libgl1-mesa-dev,
  xutils to xutils-dev, x-dev to x11proto-core-dev.
* bump Standards-Version to 3.8.0
* add Vcs fields and Homepage to debian/control
* Flurry is not installed until the bug get fixed (Closes: #484112)

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
 
113
113
/* Globals *******************************************************************/
114
114
char*        progname;
115
 
XtAppContext app;
116
 
XrmDatabase  db;
117
115
char*        progclass = XSUBLIM_NAME;
118
116
 
119
117
# ifdef __GNUC__
122
120
                     in the following string constant... */
123
121
# endif
124
122
 
125
 
char*        defaults[] =
 
123
static char*        defaults[] =
126
124
{
127
125
        ".background:                     #000000",
128
126
        ".foreground:                     #FFFFFF",
180
178
        "*" XSUBLIM_ARG_CENTER":          true",
181
179
        NULL
182
180
};
183
 
XrmOptionDescRec options[] =
 
181
 
 
182
static XrmOptionDescRec options[] =
184
183
{
185
184
        {"-" XSUBLIM_ARG_FONT,          "." XSUBLIM_ARG_FONT,
186
185
         XrmoptionSepArg,0},
223
222
/* Functions *****************************************************************/
224
223
 
225
224
/* Defer signals to protect the server grab ================================ */
226
 
void xsublim_Sig_Catch(int sig_Number)
 
225
static void xsublim_Sig_Catch(int sig_Number)
227
226
{
228
227
        /* BSD needs this reset each time, and it shouldn't hurt anything
229
228
           else */
262
261
        }
263
262
        return (*Xsublim_Sh_Handler)(handle_Display,handle_Error);
264
263
}
 
264
 
 
265
 
265
266
int main(int argc,char* argv[])
266
267
{
 
268
        XtAppContext app;
267
269
        int               sig_Number;
268
270
        int               sig_Signal[] =
269
271
        {
298
300
                -1
299
301
        };
300
302
        Widget            app_App;
301
 
        Display*          disp_Display;
 
303
        Display*          dpy;
302
304
        Window            win_Root;
303
305
        XWindowAttributes attr_Win;
304
306
        XGCValues         gc_ValFore;
419
421
            exit (-1);
420
422
          }
421
423
 
422
 
        disp_Display = XtDisplay(app_App);
423
 
        db = XtDatabase(disp_Display);
424
 
        XtGetApplicationNameAndClass(disp_Display,&progname,&progclass);
 
424
        dpy = XtDisplay(app_App);
 
425
        XtGetApplicationNameAndClass(dpy,&progname,&progclass);
425
426
        win_Root = RootWindowOfScreen(XtScreen(app_App));
426
427
        XtDestroyWidget(app_App);
427
428
 
428
429
        /* Get the arguments */
429
 
        arg_FlagCenter = get_boolean_resource(XSUBLIM_ARG_CENTER,"Boolean");
430
 
        arg_FlagOutline = get_boolean_resource(XSUBLIM_ARG_OUTLINE,"Boolean");
431
 
        arg_FlagScreensaver = get_boolean_resource(XSUBLIM_ARG_SCREENSAVER,
 
430
        arg_FlagCenter = get_boolean_resource(dpy, XSUBLIM_ARG_CENTER,"Boolean");
 
431
        arg_FlagOutline = get_boolean_resource(dpy, XSUBLIM_ARG_OUTLINE,"Boolean");
 
432
        arg_FlagScreensaver = get_boolean_resource(dpy, XSUBLIM_ARG_SCREENSAVER,
432
433
         "Boolean");
433
 
        arg_FlagRandom = get_boolean_resource(XSUBLIM_ARG_RANDOM,"Boolean");
434
 
        arg_DelayShow = get_integer_resource(XSUBLIM_ARG_DELAYSHOW,"Integer");
435
 
        arg_DelayWord = get_integer_resource(XSUBLIM_ARG_DELAYWORD,"Integer");
436
 
        arg_DelayPhraseMin = get_integer_resource(XSUBLIM_ARG_DELAYPHRASEMIN,
 
434
        arg_FlagRandom = get_boolean_resource(dpy, XSUBLIM_ARG_RANDOM,"Boolean");
 
435
        arg_DelayShow = get_integer_resource(dpy, XSUBLIM_ARG_DELAYSHOW,"Integer");
 
436
        arg_DelayWord = get_integer_resource(dpy, XSUBLIM_ARG_DELAYWORD,"Integer");
 
437
        arg_DelayPhraseMin = get_integer_resource(dpy, XSUBLIM_ARG_DELAYPHRASEMIN,
437
438
         "Integer");
438
 
        arg_DelayPhraseMax = get_integer_resource(XSUBLIM_ARG_DELAYPHRASEMAX,
 
439
        arg_DelayPhraseMax = get_integer_resource(dpy, XSUBLIM_ARG_DELAYPHRASEMAX,
439
440
         "Integer");
440
441
        if (arg_DelayPhraseMax < arg_DelayPhraseMin)
441
442
        {
447
448
        text_Item = 0;
448
449
        text_Count = 0;
449
450
        memset(text_Used,0,sizeof(text_Used));
450
 
        arg_Source = get_string_resource(XSUBLIM_ARG_FILE,"Filename");
 
451
        arg_Source = get_string_resource(dpy, XSUBLIM_ARG_FILE,"Filename");
451
452
        if (arg_Source != NULL)
452
453
        {
453
454
                FILE*       file_Fs;
480
481
        }
481
482
        else
482
483
        {
483
 
                arg_Source = get_string_resource(XSUBLIM_ARG_PROGRAM,
 
484
                arg_Source = get_string_resource(dpy, XSUBLIM_ARG_PROGRAM,
484
485
                 "Executable");
485
486
                if (arg_Source != NULL)
486
487
                {
531
532
                else
532
533
                {
533
534
                        arg_Text =
534
 
                         get_string_resource(XSUBLIM_ARG_PHRASES,"Phrases");
 
535
                         get_string_resource(dpy, XSUBLIM_ARG_PHRASES,"Phrases");
535
536
                        if (arg_Text != NULL)
536
537
                        {
537
538
                                arg_Text = strdup(arg_Text);
556
557
        }
557
558
 
558
559
        /* Load the font */
559
 
        font_Font = XLoadQueryFont(disp_Display,
560
 
         get_string_resource(XSUBLIM_ARG_FONT,"Font"));
 
560
        font_Font = XLoadQueryFont(dpy,
 
561
         get_string_resource(dpy, XSUBLIM_ARG_FONT,"Font"));
561
562
        font_Index = 0;
562
563
        while ((font_Font == NULL) && (font_List[font_Index] != NULL))
563
564
        {
564
 
                font_Font = XLoadQueryFont(disp_Display,font_List[font_Index]);
 
565
                font_Font = XLoadQueryFont(dpy,font_List[font_Index]);
565
566
                font_Index++;
566
567
        }
567
568
        if (font_Font == NULL)
571
572
        }
572
573
 
573
574
        /* Create the GCs */
574
 
        XGetWindowAttributes(disp_Display,win_Root,&attr_Win);
 
575
        XGetWindowAttributes(dpy,win_Root,&attr_Win);
575
576
        gc_ValFore.font = font_Font->fid;
576
 
        gc_ValFore.foreground = get_pixel_resource("foreground","Foreground",
577
 
         disp_Display,attr_Win.colormap);
578
 
        gc_ValFore.background = get_pixel_resource("background","Background",
579
 
         disp_Display,attr_Win.colormap);
 
577
        gc_ValFore.foreground = get_pixel_resource(dpy,
 
578
                                                   attr_Win.colormap,
 
579
                                                   "foreground","Foreground");
 
580
        gc_ValFore.background = get_pixel_resource(dpy,
 
581
                                                   attr_Win.colormap,
 
582
                                                   "background","Background");
580
583
        gc_ValFore.subwindow_mode = IncludeInferiors;
581
 
        gc_GcFore = XCreateGC(disp_Display,win_Root,
 
584
        gc_GcFore = XCreateGC(dpy,win_Root,
582
585
         (GCFont|GCForeground|GCBackground|GCSubwindowMode),&gc_ValFore);
583
586
        gc_ValBack.font = font_Font->fid;
584
 
        gc_ValBack.foreground = get_pixel_resource("background","Background",
585
 
         disp_Display,attr_Win.colormap);
586
 
        gc_ValBack.background = get_pixel_resource("foreground","Foreground",
587
 
         disp_Display,attr_Win.colormap);
 
587
        gc_ValBack.foreground = get_pixel_resource(dpy,
 
588
                                                   attr_Win.colormap,
 
589
                                                   "background","Background");
 
590
        gc_ValBack.background = get_pixel_resource(dpy,
 
591
                                                   attr_Win.colormap,
 
592
                                                   "foreground","Foreground");
588
593
        gc_ValBack.subwindow_mode = IncludeInferiors;
589
 
        gc_GcBack = XCreateGC(disp_Display,win_Root,
 
594
        gc_GcBack = XCreateGC(dpy,win_Root,
590
595
         (GCFont|GCForeground|GCBackground|GCSubwindowMode),&gc_ValBack);
591
596
 
592
597
        /* Loop ------------------------------------------------------------ */
598
603
                if (arg_FlagScreensaver != FALSE)
599
604
                {
600
605
                        /* Find the screensaver's window */
601
 
                        win_Root = xsublim_Ss_GetWindow(disp_Display);
 
606
                        win_Root = xsublim_Ss_GetWindow(dpy);
602
607
                        if (win_Root == 0)
603
608
                        {
604
609
                                usleep(30000000);
640
645
                        /* Once-per-word stuff ----------------------------- */
641
646
 
642
647
                        /* Find the text's position */
643
 
                        XGetWindowAttributes(disp_Display,win_Root,&attr_Win);
 
648
                        XGetWindowAttributes(dpy,win_Root,&attr_Win);
644
649
                        text_Length = strlen(text_Word);
645
650
                        text_Width = XTextWidth(font_Font,text_Word,
646
651
                         text_Length)+XSUBLIM_TEXT_OUTLINE*2;
686
691
 
687
692
                        /* Grab the server -- we can't let anybody draw over
688
693
                           us */
689
 
                        XSync(disp_Display,FALSE);
690
 
                        XGrabServer(disp_Display);
691
 
                        XSync(disp_Display,FALSE);
 
694
                        XSync(dpy,FALSE);
 
695
                        XGrabServer(dpy);
 
696
                        XSync(dpy,FALSE);
692
697
 
693
698
                        /* Set up an error handler that ignores BadMatches --
694
699
                           since the screensaver can take its window away at
698
703
                         XSetErrorHandler(xsublim_Sh_Handler);
699
704
 
700
705
                        /* Save the current background */
701
 
                        image_Image = XGetImage(disp_Display,win_Root,image_X,
 
706
                        image_Image = XGetImage(dpy,win_Root,image_X,
702
707
                         image_Y,image_Width,image_Height,~0L,ZPixmap);
703
708
 
704
709
                        /* If we've successfully saved the background... */
721
726
                                                           annoying at some
722
727
                                                           point... */
723
728
                                                        XDrawString(
724
 
                                                         disp_Display,
 
729
                                                         dpy,
725
730
                                                         win_Root,gc_GcBack,
726
731
                                                         text_X+text_Outline[
727
732
                                                         text_OutlineIndex].
739
744
                                        }
740
745
 
741
746
                                        /* Draw the word */
742
 
                                        XDrawString(disp_Display,win_Root,
 
747
                                        XDrawString(dpy,win_Root,
743
748
                                         gc_GcFore,text_X,
744
749
                                         text_Y+(font_Font->ascent),text_Word,
745
750
                                         text_Length);
747
752
                                if (Xsublim_Sh_Status == 0)
748
753
                                {
749
754
                                        /* Wait a bit */
750
 
                                        XSync(disp_Display,FALSE);
 
755
                                        XSync(dpy,FALSE);
751
756
                                        if (Xsublim_Sig_Last == -1)
752
757
                                        {
753
758
                                                usleep(arg_DelayShow);
754
759
                                        }
755
760
        
756
761
                                        /* Restore the background */
757
 
                                        XPutImage(disp_Display,win_Root,
 
762
                                        XPutImage(dpy,win_Root,
758
763
                                         gc_GcFore,image_Image,0,0,image_X,
759
764
                                         image_Y,image_Width,image_Height);
760
765
                                }
764
769
                        }
765
770
 
766
771
                        /* Restore the error handler, ungrab the server */
767
 
                        XSync(disp_Display,FALSE);
 
772
                        XSync(dpy,FALSE);
768
773
                        XSetErrorHandler(Xsublim_Sh_Handler);
769
 
                        XUngrabServer(disp_Display);
770
 
                        XSync(disp_Display,FALSE);
 
774
                        XUngrabServer(dpy);
 
775
                        XSync(dpy,FALSE);
771
776
 
772
777
                        /* Pause between words */
773
778
                        if (Xsublim_Sig_Last == -1)