15.5 The FULLSCREEN Package
The FULLSCREEN package allows XView clients to grab the server for keyboard and/or
pointer use either exclusively or nonexclusively with other applications. This package is
used primarily to prompt the user for immediate feedback on a question or to notify the user
of an error that needs attention. Typically, the user responds with a button press or a key-
board event. The NOTICE package uses the FULLSCREEN package extensively to implement
its functionality. In most cases, you need nothing more than the NOTICE package and should
rarely need to use the FULLSCREEN package. The need for this package arises if you choose
to implement your own notice or perhaps a user interface item that is not OPEN LOOK-
compliant. In either case, this is advanced usage and is beyond the scope of this book. Using
the FULLSCREEN package can be very dangerous because it uses the X server’s grabbing
functions in Xlib. It is possible to get into a state from which you cannot get out except by
killing the server remotely or rebooting your workstation. When using a debugger, be
extremely careful that you do not set breakpoints within code when the server is in the
middle of a grab of some kind. Whatever you do, do not step through code that creates a
FULLSCREEN instance. If this is unavoidable, you should prepare for it by making sure that
you have remote access to your workstation or by attaching a terminal to it so you can kill the
debugger to free the server.
The flow of control for client code using the FULLSCREEN package is to create a fullscreen
instance (grabbing the server), scan for a particular event and destroy the fullscreen instance
(freeing the server).
Creating a fullscreen object (grabbing the server) involves xv_create() as usual:
Fullscreen fs;
fs = xv_create(owner, FULLSCREEN, NULL);
The owner in this case may be a visible XView object that has a window associated with it*
and is currently displayed on the screen (e.g., XV_SHOW is TRUE). If owner is NULL, then the
root window of the default screen is used as the owner.
The attribute WIN_CURSOR can be used with a fullscreen object to set the mouse cursor
displayed while the fullscreen object is active. The default value for WIN_CURSOR is inherited
by the fullscreen object from its owner.
Example 15-4 uses the FULLSCREEN package. A simple panel with two panel buttons is
created. The Quit button quits the program, and the Fullscreen button calls the grab() rou-
tine that grabs the server using the
FULLSCREEN package and waits for a button to be pressed.
Once this happens, the routine frees the fullscreen object, thus releasing the server. Event
masks can be specified when creating a FULLSCREEN object to set what kind of events the cli-
ent window will accept or detect. The event masks are specified using the regular WIN_*
attributes. A similar event mask is also needed for xv_input_readevent().†
*This does not include panel items.
†See Chapter 6, Handling Input, for more information about xv_input_readevent().
Nonvisual Objects
Nonvisual Objects 359
Example 15-4. The fullscreen.c program
* fullscreen.c
* Demonstrate the fullscreen package. Create a panel button that
* creates a fullscreen instance, thus grabbing the X server. User
* presses a mouse button to release the server.
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/fullscreen.h>
main(argc, argv)
char *argv[ ];
Frame frame;
Panel panel;
void exit(), grab();
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
frame = (Frame)xv_create(XV_NULL, FRAME, NULL);
panel = (Panel)xv_create(frame, PANEL, NULL);
(void) xv_create(panel, PANEL_BUTTON,
(void) xv_create(panel, PANEL_BUTTON,
* Notify procedure for when the "Fullscreen" button is pushed.
* Create a fullscreen instance, scan for a button event, then
* destroy it.
grab(item, event)
Panel_item item;
Event *event;
Panel panel = (Panel)xv_get(item, PANEL_PARENT_PANEL);
Frame frame = (Frame)xv_get(panel, XV_OWNER);
Fullscreen fs;
Inputmask im;
/* set up an input mask for the call to xv_input_readevent(). */
win_setinputcodebit(&im, MS_LEFT);
win_setinputcodebit(&im, MS_MIDDLE);
win_setinputcodebit(&im, MS_RIGHT);
win_setinputcodebit(&im, LOC_MOVE);
360 XView Programming Manual
Example 15-4. The fullscreen.c program (continued)
* Create a fullscreen object (initialize X server grab).
* Specify which events should be allowed to pass through.
* These events should match the input mask coded above.
fs = xv_create(panel, FULLSCREEN,
/* Loop till user generates a button event */
while (xv_input_readevent(panel, event, TRUE, TRUE, &im) != -1)
if (event_is_button(event))
/* Destroy the fullscreen (release the X server grab) */
/* Report which button was pushed. */
printf("event was button %d (%d, %d)0,
event_id(event) - BUT_FIRST+1,
event_x(event) + (int)xv_get(frame, XV_X),
event_y(event) + (int)xv_get(frame, XV_Y));
When this program is run and the user selects the Fullscreen panel item, the X server is
grabbed and the user must select one of the mouse buttons to release it. To users, it may
appear as though they can select another panel button. Although the panel window is the
owner of the fullscreen object, events that occur while the server is grabbed by the fullscreen
object are not propagated to XView objects under the pointer. In Example 15-4, if the user
presses the mouse button when the pointer is on top of any panel button a panel button while
in fullscreen, the button-down event will trigger the call to xv_input_readevent() and
break the loop. The corresponding button-up event is not read yet and will get read by nor-
mal event processing after the call to grab() returns. If the button-up event happened over
a panel button, then the panel button’s notify routine will be called.
The event masks set by the FULLSCREEN package and by the Inputmask do not interfere
with the event masks in any XView window. Debugging and the
There are four global variables in the
FULLSCREEN package that can be used to help debug
XView programs that grab the server, keyboard or pointer. Note that these variables can only
be used via the FULLSCREEN package. Here are the variables with their default values:
int fullscreendebug = 0;
int fullscreengrabserver = 1;
int fullscreengrabpointer = 1;
int fullscreengrabkbd = 1;
When fullscreengrabserver is set to 0 (in source code or in debugger), the X server
will not be grabbed despite requests to grab it.
Nonvisual Objects
Nonvisual Objects 361
When fullscreengrabpointer is set to 0, the pointer will not be grabbed despite
requests to grab it.
When fullscreengrabkbd is set to 0, the keyboard will not be grabbed despite requests
to grab it.
When fullscreendebug is set to 1, no grabs of any kind are performed.
15.6 Nonvisual Package Summary
There are procedures or macros in the nonvisual packages. Table 15-1 lists the attributes in
the SCREEN package. Table 15-2 lists the attributes in the SERVER and SERVERIMAGE pack-
ages and Table 15-3 lists the attributes in the FULLSCREEN package. This information is
described fully in the XView Reference Manual.
Table 15-1. Screen Attributes
Table 15-2. Server and Server Image Attributes
Table 15-3. Fullscreen Attributes
362 XView Programming Manual
Table 15-3. Fullscreen Attributes (continued)
Nonvisual Objects
Nonvisual Objects 363

Get Volume 7A: XView Programming Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.