File: show_screen_saver.adb

package info (click to toggle)
libadabindx 0.7.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,136 kB
  • ctags: 32
  • sloc: ada: 35,597; makefile: 556; sh: 10
file content (118 lines) | stat: -rw-r--r-- 4,811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
-------------------------------------------------------------------------------
--                                                                           --
--  Ada Interface to the X Window System and Motif(tm)/Lesstif               --
--  Copyright (c) 1996-2000 Hans-Frieder Vogt                                --
--                                                                           --
--  This program is free software; you can redistribute it and/or modify     --
--  it under the terms of the GNU General Public License as published by     --
--  the Free Software Foundation; either version 2 of the License, or        --
--  (at your option) any later version.                                      --
--                                                                           --
--  This program is distributed in the hope that it will be useful,          --
--  but WITHOUT ANY WARRANTY; without even the implied warranty of           --
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
--  See the GNU General Public License for more details.                     --
--                                                                           --
--  You should have received a copy of the GNU General Public License        --
--  along with this program; if not, write to the                            --
--  Free Software Foundation, Inc.,                                          --
--  59 Temple Place - Suite 330,                                             --
--  Boston, MA 02111-1307, USA.                                              --
--                                                                           --
--                                                                           --
--  X Window System is copyrighted by the X Consortium                       --
--  Motif(tm)       is copyrighted by the Open Software Foundation, Inc.     --
--                                                                           --
--                                                                           --
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--
-- HISTORY:
--          June 20, 1998 begin of history
--
-------------------------------------------------------------------------------

with X_Lib,
     X_Lib.Screen_Saver,
     X_Lib.Tasking,
     X_Toolkit,
     X_Toolkit.Shell;
with Interfaces.C;
with Text_Io;
procedure Show_Screen_Saver is

   use  X_Lib, X_Lib.Screen_Saver, X_Toolkit, Interfaces.C;

   Appshell : Widget;
   Display  : Display_Pointer;
   Screen   : Screen_Pointer;
   Visual   : Visual_Pointer;
   Window   : Window_ID;

   Argl : Arg_List;
   App_Con : Xt_App_Context;

   Timeout, Interval : Integer;
   Blank             : Blanking_Mode;
   Exposures         : Exposures_Mode;

   package Int_Io       is new Text_Io.Integer_Io (Integer);
   package Blank_Io     is new Text_Io.Enumeration_Io (Blanking_Mode);
   package Exposures_Io is new Text_Io.Enumeration_Io (Exposures_Mode);

begin
   X_Lib.Tasking.Resource.Seize;
-- UseX11R6
--!    Xt_Open_Application (Appshell,
--!                         App_Con,
--!                         "ShowScreenSaver",
--!                         W_Class => X_Toolkit.Shell.Top_Level_Shell_Widget_Class);
-- NotX11R6
   Xt_App_Initialize (Appshell,
                      App_Con,
                      "ShowScreenSaver");
-- EndX11R6
   
   Display := Xt_Display (Appshell);
   Screen  := Xt_Screen (Appshell);
   Window  := X_Root_Window_Of_Screen (Screen);

   Visual  := X_Default_Visual_Of_Screen (Screen);


   X_Get_Screen_Saver (Display, Timeout, Interval, Blank, Exposures);
   X_Lib.Tasking.Resource.Release;

   Text_Io.Put_Line ("Screen-saver values:");
   Text_Io.Put ("  Timeout:         "); Int_Io.Put (Timeout); Text_Io.New_Line;
   Text_Io.Put ("  Interval:        "); Int_Io.Put (Interval); Text_Io.New_Line;
   Text_Io.Put ("  Prefer_Blanking: "); Blank_Io.Put (Blank); Text_Io.New_Line;
   Text_Io.Put ("  Allow_Exposures: "); Exposures_Io.Put (Exposures); Text_Io.New_Line;
   Text_Io.New_Line;

   Text_Io.Put_Line ("Test of the screen-saver:");
   Text_Io.New_Line;
   Text_Io.Put_Line ("The screen will be blanked for 2 s");
   Text_Io.Put_Line ("The test of the screen-saver begins in 5 s");
   Text_Io.Flush;
   for I in 1 .. 5 loop
      delay 1.0;
      Text_Io.Put (".");
      Text_Io.Flush;
   end loop;
   Text_Io.New_Line;

   X_Lib.Tasking.Resource.Seize;
   X_Activate_Screen_Saver (Display);
   X_Flush (Display);
   X_Lib.Tasking.Resource.Release;

   delay 2.0;

   X_Lib.Tasking.Resource.Seize;
   X_Reset_Screen_Saver (Display);
   X_Flush (Display);
   X_Lib.Tasking.Resource.Release;

end Show_Screen_Saver;