HP Visual User Environment (HP VUE) Release Document
Software Release 1.0
Copyright Hewlett-Packard Co. 1990
First Printing: May 1990
UNIX is a registered trademark of AT&T in the USA and other countries.
NOTICE
The information contained in this document is subject to change
without notice.
HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS
MATERIAL INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MER-
CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard
shall not be liable for errors contained herein or for incidental or
consequential damages in connection with the furnishing, performance
or use of this material.
Hewlett-Packard assumes no responsibility for the use or reliability
of its software on equipment that is not furnished by Hewlett-Packard.
This document contains proprietary information which is protected by
copyright. All rights reserved. No part of this document may be pho-
tocopied, reproduced or translated to another language without the
prior written consent of Hewlett-Packard Company.
RESTRICTED RIGHTS LEGEND. Use, duplication or disclosure by government
is subject to restrictions as set forth is subdivision (c) (1) (ii) of
the Rights in Technical Data and Computer Software Clause at DFARS
252.227.7013. Hewlett-Packard Co., 3000 Hanover Street, Palo Alto, CA
94304
10 9 8 7 6 5 4 3 2 1
Preface
This document describes the HP Visual User Environment (HP VUE) Ver-
sion 1.0. It explains software features, installation procedures,
documentation, limitations, and current known bugs.
The normal software installation process places a version of this
release document in each node's /install/doc/apollo directory. You
may print the online copy of this document by using one of the print
commands described below.
If your installation uses the SysV lp print daemon, use an lp command
similar to the following:
lp -dprinter_name pathname
where pathname is the pathname of the release notes, usually
/install/doc/apollo/hpvue.v.1.0.__notes (for MC680x0-based workstations)
/install/doc/apollo/hpvue.v.1.0.p__notes (for Series 10000 workstations)
(Note that there are two underscores before notes).
If your installation uses the Domain print system, use the following
Aegis /com/prf command:
prf pathname -pr printer_name -npag
If your installation uses the BSD lpd print daemon, use an lpr command
similar to the following:
lpr -Pprinter_name pathname
CONTENTS
1. Overview of HP VUE Version 1.0............................... 1-1
2. Installing and Using HP VUE.................................. 2-1
2.1 Installation............................................ 2-1
2.2 Configuration........................................... 2-2
2.2.1 Selecting a Default Environment.................. 2-2
2.2.2 Running the Visual Shell......................... 2-2
2.3 Customization........................................... 2-2
2.4 Software for HP VUE Version 1.0......................... 2-3
2.5 Software Notes.......................................... 2-4
2.5.1 Installation Problems............................ 2-4
2.5.2 Startup and Login Problems....................... 2-4
2.5.3 Display Manager Problems......................... 2-5
2.5.4 Keyboard Problems................................ 2-6
3. Documentation................................................ 3-1
3.1 HP VUE Documentation.................................... 3-1
3.2 HP VUE Online Help...................................... 3-1
3.3 Additions or Changes to Documentation................... 3-1
4. Limitations and Known Bugs................................... 4-1
4.1 HP VUE Environment Limitations and Bugs................. 4-1
4.2 Visual Shell Limitations and Bugs....................... 4-1
4.3 Vuepad Browser Limitations and Bugs..................... 4-2
4.4 Datebook Limitations and Bugs........................... 4-3
4.5 Display Manager (DM) Limitations and Bugs............... 4-3
5. Programmer Notes............................................. 5-1
5.1 Instructions for Incorporating Drag and Drop............ 5-1
5.2 Source Code for Drag and Drop........................... 5-3
v
HP VUE Version 1.0
Chapter 1: Overview of HP VUE Version 1.0
The HP Visual User Environment (HP VUE) Version 1.0 is a graphical
user environment for Apollo workstations, based on the X11R3 version
of X Windows and on the OSF/Motif appearance and behavior style.
HP VUE provides workstation users with an easy-to-use interface for
display management and operating system tasks.
The main HP VUE components are the Motif Window Manager (mwm), the
Visual Shell (vsh) for file system management, a control panel (xctrl)
for session management, a text browser (vuepad), and a terminal emula-
tor program (mterm). HP VUE also includes the following productivity
tools: an appointment scheduler (datebook), clock (xclock), system
load monitor (xload), and calculator (hpcalc).
HP VUE runs under the X Window System on Apollo workstations running
Version SR10.2 of Domain/OS (as updated by Product Support Kit
PSK5.v.10.2) or a later version of Domain/OS.
HP VUE is supported on Domain Series 2500, Series 3500, Series 4000,
Series 4500, and Series 10000 workstations.
Overview of HP VUE Version 1.0 1-1
HP VUE Version 1.0
Chapter 2: Installing and Using HP VUE
This chapter describes how to install, configure, and customize
HP VUE.
2.1 Installation
You can install HP VUE on a user node (one equipped with monitor and
keyboard) or a Domain Server Processor (DSP) that is running Version
SR10.2 of the Domain operating system (updated by PSK5.v.10.2) or a
more recent version of Domain/OS. The node should have TCP/IP
enabled.
If you are running Version 10.2 of Domain/OS, you must install
PSK5.v.10.2 before installing HP VUE.
The complete HP VUE configuration requires at least 12 MB of memory,
and the minimal configuration requires at least 8 MB.
The HP VUE media contains the following products:
Product Version Selection File(s) Override File(s)
hpvue 1.0 aa.hpvue ov.hpvue
hpvue 1.0.p aa.hpvue ov.hpvue
Selection and override files reside in the directory
//<authorized_area>/install/templates/apollo/<product_name>.v.<version>
where:
<authorized_area> is your authorized area,
<product_name> is the product name (as listed in the first column of the table above), and
<version> is the version number (as listed in the second column of the table above).
For directions about how to install this product and about the use of
selection and override files, see the manual Installing Software with
Apollo's Release and Installation Tools, Order No. 008860-A02.
Installing and Using HP VUE 2-1
HP VUE Version 1.0
2.2 Configuration
In the first stage of the installation process, you create a confi-
guration file by responding to questions from the configuration pro-
gram. This section provides guidelines on how to respond to these
questions.
2.2.1 Selecting a Default Environment
HP VUE users have the choice of using either the HP VUE windowing
environment or the standard Apollo Display Manager (DM). HP VUE
features include the Visual Shell, Motif window manager, and other
user-friendly programs based on X11. The DM environment provides edit
pads and window manipulation using the original Apollo Display
Manager.
NOTE: The HP VUE environment does not currently support borrow mode.
If you want to run borrow-mode programs, you must specify the
DM as your default environment.
The standard default environment is HP VUE. If you want to run
borrow-mode programs, or if you want to use the HP VUE applications in
a DM environment, then specify the DM as your default environment.
For further information on the interaction of HP VUE and the DM, see
the HP VUE User's Guide.
2.2.2 Running the Visual Shell
The Visual Shell program runs best on machines with at least 12 MB of
memory, and on medium to high-end machines. On machines with less
than 12 MB of memory, especially on low-end machines such as the
DN3500 or DN2500, performance of the Visual Shell program may be unac-
ceptably slow.
The default startup configuration for HP VUE places a Visual Shell
icon at the bottom of your screen, which you can select when you want
to start up the Visual Shell. If you choose not to run the Visual
Shell program, you should specify during configuration that the Visual
Shell icon be disabled.
2.3 Customization
You can change the appearance and behavior of your window session and
the window applications you use by creating special startup files in
your home directory. An easy way to do this is to copy some of the
default system startup files, rename them, and edit them as you wish.
The files you use for customization are listed below, along with the
source files to use as templates.
2-2 Installing and Using HP VUE
HP VUE Version 1.0
.Xresources For changing the appearance (fonts, color schemes,
etc.) and behavior of HP VUE applications. The system
file to copy is /usr/lib/X11/sys.Xresources .
.Xsession For changing what applications and tools are available
as icons when you log in, and for setting your PATH
variable. The system file to copy is
/usr/lib/X11/xdm/Xsession.user .
.vshrc For changing Visual Shell startup. The system file to
copy is /usr/lib/X11/system.vshrc .
.mwmrc For changing key and button bindings. The system file
to copy is /usr/lib/X11/system.mwmrc .
.datebookrc For changing datebook features. The system file to
copy is /usr/lib/X11/datebookrc .
For details on how to customize HP VUE startup, and for information on
other aspects of HP VUE operation that you can customize, see the
HP VUE User's Guide.
2.4 Software for HP VUE Version 1.0
This section identifies the main HP VUE directories and files provided
by the HP VUE media.
Directory Contents
/install/doc/apollo Online release notes for HP VUE 1.0.
/lib The mtflib.vue, dlglib.vue, and
ntmllib.vue libraries used by HP VUE
applications; the xmlib1.0, xtlib1.0,
and xwlib libraries used by Motif appli-
cations; and the general cxxlib library.
/sys/node_data/etc/xdm/options Files controlling the HP VUE configura-
tion.
/usr/apollo/lib/dlg.help The vuepad and vsh subdirectories with
application-specific online help files.
/usr/bin/X11 Binaries for datebook, eclient, hpcalc,
mterm, mwm, startvue, vsh, vuepad,
x11lock, xctrl, xhelp, and xicon.
/usr/lib/X11 System startup files for many HP VUE
applications.
Installing and Using HP VUE 2-3
HP VUE Version 1.0
/usr/lib/X11/app-defaults Default resource files for most HP VUE
applications.
/usr/lib/X11/bitmaps Icons used for HP VUE.
/usr/lib/X11/datebook Files needed by datebook.
/usr/lib/X11/ddb Files needed by vsh and vuepad.
/usr/lib/X11/helpfiles Files and subdirectories for the online
Help and Man Page system (xhelp) con-
trolled by the Control Panel (xctrl).
/bsd4.3/usr/man Manual pages for HP VUE applications.
/sys5.3/usr/catman Manual pages for HP VUE applications.
2.5 Software Notes
This section contains suggestions and troubleshooting information for
possible problems that might occur with HP VUE.
2.5.1 Installation Problems
Here are some steps to take if you encounter problems during HP VUE
installation.
o Check your SR10 baselevel. It must be SR10.2 or later, and you
must have /usr/X11/bin.
o If you are running SR10.2, you must have PSK5 installed.
2.5.2 Startup and Login Problems
Here are some steps to take if you encounter problems during HP VUE
startup and login.
o Check the file /sys/node_data/etc/xdm/xdm-errors for a record of
errors during startup. This file is usually locked, so you may
need to use the crp command to access the machine and the cat
command to read the file.
o Check to see if /usr/X11/lib/xdm is a link to `node_data/etc/xdm.
If /usr/X11/lib/xdm is a real directory, you will likely have
problems during login and/or startup.
2-4 Installing and Using HP VUE
HP VUE Version 1.0
o Check /etc/rc. It should start up Xapollo or xdm like this:
if [ -f /etc/daemons/Xapollo -o -f /etc/daemons/xdm ]; then
if [ -f /etc/xdm -a -f /etc/daemons/xdm ]; then
(echo " xdm\c" >/dev/console)
(/etc/xdm) &
elif [ -f /etc/Xapollo -a -f /etc/daemons/Xapollo ]; then
(echo " Xapollo\c" >/dev/console)
# (nice --10 /etc/Xapollo -D1 s+r+ ) &
(nice --5 /etc/Xapollo -K /usr/X11/lib/keyboard/keyboard.config -D1 s+r-) &
fi
fi
o If your /usr/bin is not local to your node, the node that you are
linked to must have the link:
//<othernode>/usr/bin/X11 -> /usr/X11/bin
Without this link, you will have problems logging in and running
clients that depend on the /usr/bin/X11 path.
o Check /sys/node_data/etc/daemons for xdm. You need the xdm dae-
mon to log in through xdm. Without it, you will get the DM
(Apollo Display Manager) login.
o If the node hangs after rebooting and you have no
/etc/daemons/xdm file, check /etc/ttys. If dm_or_spm has a -x
option, remove the -x.
o At login, if the system redisplays the login screen instead of
logging you in, check to see if you have the files .Xsession or
.Xresources in your home directory. If so, rename them until you
get login working. Also check /sys/node_data/etc/xdm-errors.
o Check your /lib/cpp which links to /usr/lib/cpp. If /usr/lib/cpp
is not local to your node, cpp may be unreachable. Without cpp,
you will not get a normal-looking login, or initial HP VUE confi-
guration, since resource files are loaded with cpp.
2.5.3 Display Manager Problems
Here are some steps to take if you encounter problems using the Apollo
Display Manager in the HP VUE environment.
o Look for a leftover dm_mbx in /sys/node_data/systmp. This file
can be left locked after the DM exits, and can prevent the DM
from starting up.
o The Motif Window Manager (mwm) can deadlock when started from a
DM pad. A deadlock is caused by two programs attempting to
acquire the screen at the same time.
Installing and Using HP VUE 2-5
HP VUE Version 1.0
A deadlock can occur when:
o mwm grabs the pointer, causing the Xserver to acquire the
screen.
o mwm displays error or warning messages in a DM pad, causing
the DM to acquire the screen.
You can use the following workarounds to prevent the deadlock
problem:
1. Clean up your .mwmrc so no error or warning messages are
displayed.
2. Redirect output from mwm to a file. For example (with csh):
mwm >& /dev/null &
3. Start mwm from an mterm. For example:
mterm -e mwm or mterm -e <some_startup_script>
2.5.4 Keyboard Problems
If your keys are not doing what you expect, check the following files:
~/.mwmrc Changes mapping for the mwm
window manager.
usr/X11/bin/startvue Uses xmodmap to change the
mappings.
/usr/X11/lib/xdm/Xsession Uses xmodmap to change the
mappings.
usr/X11/lib/keyboard/keyboard.config "Excludes" keys from being
seen by X, so the DM will do
the right thing. If you want
the keyboard scrolling keys to
work in vuepad and vsh, you
must comment out the exclusion
of the scrolling keys in this
file.
2-6 Installing and Using HP VUE
HP VUE Version 1.0
Chapter 3: Documentation
3.1 HP VUE Documentation
Documentation supplied with HP VUE 1.0 includes the following:
o Release document for HP VUE Version 1.0 (this online document)
o HP VUE Quick Start (015913-A00)
o HP VUE User's Guide (015914-A00)
o Configuring the OSF/Motif Window Manager (017169-A00)
3.2 HP VUE Online Help
You have several sources of online help in HP VUE, as follows:
o The Control Panel Help system provides task-oriented information
on how to use HP VUE and windows.
o The Control Panel Man Pages system provides Domain/OS command
descriptions in UNIX manual page format.
o The Visual Shell and Vuepad Editor each have Help systems that
provide application-specific information.
See the HP VUE Quick Start for details about accessing online help.
3.3 Additions or Changes to Documentation
The following information should be added to the HP VUE User's Guide.
o For the scroll keys described in Section 3.4.1.1 to work properly
in vsh and vuepad, you may need to comment out some lines in
/usr/X11/lib/keyboard/keyboard.config with an exclamation point
(!). For example,
!!!!exclude LeftBar
!!!!exclude RightBar
!!!!exclude LeftBox
!!!!exclude Up
!!!!exclude RightBox
Documentation 3-1
HP VUE Version 1.0
!!!!exclude Left
!!!!exclude Right
!!!!exclude UpBox
!!!!exclude Down
!!!!exclude DownBox
o Section 3.5.2.9 should include the following information on the
Exit Vsh command:
When vsh is the session manager, a Logout command replaces the
Exit command in the File menu. When you select Logout, a confir-
mation box appears, where you can choose to cancel the logout or
to continue the logout and terminate all programs started since
the beginning of the login session.
o The command text input field described in Section 3.5.6.1 does
not handle multiple input lines. Commands with multiple lines
must be inserted into a script and then executed.
o Section 4.5 should include the following information:
If you have no ~/.vshrc file, vsh will load the file
/usr/X11/lib/system.vshrc to obtain the additional user menus.
3-2 Documentation
HP VUE Version 1.0
Chapter 4: Limitations and Known Bugs
This chapter discusses limitations and known bugs in HP VUE.
4.1 HP VUE Environment Limitations and Bugs
Following are some general limitations and bugs in the HP VUE environ-
ment.
o HP VUE does not support the Apollo Display Manager (DM) under the
xdm login. All DM users must use the DM login. After logging in,
DM users can access HP VUE applications as follows:
o To start up all the default HP VUE applications, run the
shell script, /usr/X11/bin/startvue.
o To start up an individual application (such as vsh, date-
book, mterm, and others) enter a command line with the pro-
gram name and any options you want.
o If you select Close from the mwm window menu of a dialog box in
the vsh or vuepad applications, both the dialog box and the
application window will close, thus terminating the application.
o If you move a vsh or vuepad window while a menu is on display,
the menu fails to move with the window.
o The screenlock feature, controlled by the x11lock program, works
only in the HP VUE environment, where X owns the root window.
Screenlock does not work when the Apollo Display Manager (DM)
owns the root window.
o Restarting mwm is unsuccessful if stderr is redirected to
/dev/null. To avoid this problem, restart mwm using an mterm,
xterm, or crp.
o Cursor artifacts may appear following an mwm refresh operation.
4.2 Visual Shell Limitations and Bugs
Following are limitations and bugs in the Visual Shell program.
o The foreground execution popup provides only the most basic level
of character handling. It is not intended for use as a terminal
emulator, and cannot handle the output of applications that
assume any level of terminal emulation. These include
Limitations and Bugs 4-1
HP VUE Version 1.0
applications that use curses, raw mode, or any termcap values
such as screen width and height. Piping output of programs
through "cat" will normally make the output palatable to fore-
ground execution.
o The Visual Shell does not recognize international characters in
filenames.
o If you attempt to copy a file into a directory for which you lack
write permission, vsh creates an empty file when no file should
be created, and displays an ambiguous error message.
o The first time in a session that you use the Cancel button in any
of the Options dialog boxes, vsh resets the options to their
default values, overriding any values you may have set in a
resource file. Subsequent use of the Cancel button during a ses-
sion simply causes vsh to ignore any values you entered in the
current dialog box.
o The value of the PATH variable in the Visual Shell depends on the
value of PATH in the Xsession file. To ensure that vsh uses a
predictable environment PATH variable, before starting vsh,
create a .Xsession file in your home directory with the PATH you
want vsh to use.
o To view link text, you must use the following settings in the
Format DDA dialog box (selected from the View menu): Vertical,
Show Links, and Long.
o To change the icon of an ASCII file from executable to text,
select Attributes from the Edit menu, and turn off the execute
(X) button for Other in the dialog box. To change the icon from
text to executable, turn on the execute button for Other.
4.3 Vuepad Browser Limitations and Bugs
Following are limitations and bugs in the Vuepad program.
o The vertical scroll bar works incorrectly when a file is first
opened in a vuepad window. The slider is very small, regardless
of the file size. The slider resizes to the correct size if you
click the scroll area under it. Also, the slider fails to move
when you use the down arrow, although the text does scroll.
o No error is reported if you enter an invalid string when using
the Go To Line command in the vuepad Search menu.
o When you scroll to the bottom of a file in vuepad (either by
using the scroll bar or by selecting commands from the Search
menu), the cursor appears at the top line of the window instead
4-2 Limitations and Bugs
HP VUE Version 1.0
of the last line of the file. To move the cursor past the first
line in this last window, use the mouse or the keyboard.
o If you activate character wrap when the cursor is in the middle
of a file, subsequent attempts to scroll to the end of the file
may fail, because vuepad calculates the number of lines
incorrectly.
4.4 Datebook Limitations and Bugs
Following are limitations and bugs in the datebook program.
o If a given event specifies a time range, and datebook is started
up after the end of that time range, datebook still creates an
alarm for the event.
o Datebook fails to synchronize files before adding events. For
example, if you add an event to the calendar using the datebook
dialog box, then edit the ~/.appts file, and then add another
event with the dialog box, the hand-edited changes are lost.
o If the datebook program is left running overnight into the first
day of a new month, the highlighted day is changed to '1' but the
calendar page for the month is not updated from the previous
month (although the title for the month is updated). To update
the display, select another month, and then reselect the new
month.
4.5 Display Manager (DM) Limitations and Bugs
Following are bugs and limitations in the DM when running in the HP
VUE environment.
o The coupling of DM operations is asynchronous. For example, the
cursor may not appear in a newly-created DM window. Also, char-
acters typed just after a command that creates a new window may
apppear in the current window.
o Switching between dmio -on and dmio -off may cause mwm window
borders to appear around the command input and output windows. By
default, these windows do not have mwm borders when you log in
through the DM and run startvue.
o Switching between dmio -off and dmio -on may cause the command
input and output windows at the bottom of the screen to remain in
the "raised" state. These windows will partially obscure any
other DM windows you position at the bottom of the screen (for
example, a maximized window). Input to the obscured window may
be slowed down, and text selection may not work. To restore
Limitations and Bugs 4-3
HP VUE Version 1.0
normal function, you can type dmio -off, or move the DM window
away from the command I/O windows.
o When the mwm Restart query box (from the Root menu) displays on
top of a DM window, the cursor will be visible only within the
dialog box and not in the DM window. If the cursor seems to
disappear when you move it past a DM window border, keep moving
it toward the query box and it will reappear inside the box.
o Applications such as Interleaf that share the DM colormap may
occasionally display icons and window borders in black when other
colors are expected.
o When specifying the position of DM pads that are created in the
HP VUE environment, make sure that both the DM pad and the mwm
window frame that is added to its border will fit within the
screen boundary. If part of the pad appears outside the screen
boundary, data in that part may appear garbled when scrolled into
the window.
o DM windows may sometimes give the error, "(XXX) Command illegal
in obscured window & when WMGR -OFF" even when the DM window is
not obscured.
o When cutting/pasting between itself and X, the DM uses X Primary
selection, not Clipboard selection.
o The cursor may occasionally warp under various conditions that
rarely happen.
o When dmio is set to -off, the DM writes error messages in the
/sys/node_data/system_logs/console file. For information about
errors, you can read this file. If you make an error resulting in
a series of alarms (for example, typing a string in a read-only
window), you may experience a significant wait before all the
messages are logged. If you want to speed up the processing of
error messages, you can set dmio to -on. This will send the mes-
sages to the command output window instead of the log file. (The
DM beeps on window alarms regardless of the dmio setting.)
o Data of more than 8K characters is truncated without warning when
transferred to an X client. When getting more than 8K characters
of data from an X client, the DM gives a "wrong type" error.
4-4 Limitations and Bugs
HP VUE Version 1.0
Chapter 5: Programmer Notes
This chapter provides instructions and source code fragments for
incorporating drag and drop functionality into an application. This
enables the application to receive "drops" from the HP VUE Visual
Shell.
5.1 Instructions for Incorporating Drag and Drop
To use the code, follow the steps and comments below and then compile
the code.
1. #include "vsh_drag_drop.h" in your application.
2. Before you get any drops, initialize your atoms by calling
_vsh_drag_drop_init(your_display);
Display* your_display;
3. Solicit events using PropertyChangeMask in your XSelectInput.
4. When you get a PropertyNotify event with xproperty.atom ==
VSH_MULTI_FILES, call:
int _vsh_get_dropped_command(dspl,win,version,command,
flags,ret_win,filelist);
Display* dspl; //your display
Window win; //your window
int *version; //returned visual shell version number
int *command; //returned command (e.g. copy or move)
int *flags; //returned command options
Window *ret_win; //window where the drag came from.
char ***filelist; //list of files dropped on you.
_vsh_get_dropped_command returns the count of files dropped.
Further explanations:
version Version of the Visual Shell -- ensures compatibility.
command The command returned -- indicates the type of drag
being performed. In general, there are two different
drag modes, modify and nomodify. A modify drag means
that files being dragged may be changed or deleted. A
nomodify drag means that the application getting the
Programmer Notes 5-1
HP VUE Version 1.0
drop should not change or delete the file dragged. Use
the macro:
VSH_MODIFY(command)
to decide whether the command received is a modify
command. VSH_MODIFY returns 0 for nomodify and non-
zero for modify.
ret_win This can be used to signal the dropping shell that you
got the drop. It is not normally necessary unless you
delete or move the file dropped on you, in which case
you should do a changeprop on ret_win with atom
VSH_SYNC, as follows:
XChangeProperty(pda_disp, ret_win, VSH_SYNC,
XA_INTEGER, 32, PropModeReplace, &anyint, 1);
(The data field anyint is just a placeholder. VSH
ignores it.)
flags Used by VSH only.
filelist You must pass in the address of a char**.
vsh_get_dropped command will allocate the space. It is
good practice to free it when you are done with it.
filelist is an array of strings. The pointer after the
last string is null, so you can either iterate looking
for null, or use the count returned, to loop through
the list of names.
5-2 Programmer Notes
HP VUE Version 1.0
5.2 Source Code for Drag and Drop
/*
* COPYRIGHT 1989 @Apollo Computer Inc. Chelmsford Mass.
*
* Apollo makes no assertions or warranties on the correctness
* of this code and the user agrees not to hold Apollo responsible
* in any way shape or form, for any damages that might result
* either directly or indirectly from the use of this code.
* In exchange for such assurances Apollo allows these code
* fragments to be used without restriction.
*/
/********************************************************************/
/* THIS IS THE FILE vsh_drag_drop.h */
/********************************************************************/
#include <X11/X.h> /*defines ShiftMask */
#include <X11/Xatom.h>
#define HEADER_SIZE 20
/* this macro lets interface users determine the meaning of the */
/* command flag returned by vsh_get_dropped_command. It indicates */
/* whether the source of the drag is to be modified. e.g. copy/move*/
/*or readonly/readwrite */
#define VSH_MODIFY(fg) ((fg & ShiftMask) == 0)
extern Atom VSH_MULTI_FILES;
extern Atom VSH_SYNC;
void _vsh_drag_drop_init(Display *);
int _vsh_get_dropped_command(Display *,Window ,
int *,int *,int *,Window *,char ***);
/********************************************************************/
/* THIS IS THE FILE vsh_drag_drop.c */
/********************************************************************/
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <X11/Xlib.h>
#include "vsh_drag_drop.h"
extern XGetWindowProperty(Display*,Window,Atom,int,int,int,Atom,Atom*,
int*,unsigned long*,unsigned long*,char**);
extern XFree(char*);
Atom VSH_MULTI_FILES = None;
Atom VSH_SYNC = None;
Programmer Notes 5-3
HP VUE Version 1.0
/*vsh_drag_drop_init must be called before _vsh_get_dropped_command */
void _vsh_drag_drop_init(Display *dspl)
{
VSH_MULTI_FILES = XInternAtom (dspl, "_VshMultiFiles", False);
VSH_SYNC = XInternAtom (dspl, "_VshSync", False);
}
/*returns selected count*/
int _vsh_get_dropped_command(Display *dspl,Window wndw, int *version,
int *command, int *flags, Window *ret_win,char ***ret_file_list)
{
Atom ret_atom;
int ret_format;
int file_count;
int i,*hdr;
char *selected_str;
unsigned long ret_len, ret_after;
unsigned char *ret_prop;
char **folded;
XGetWindowProperty(dspl,wndw,VSH_MULTI_FILES,0,8192,False,
XA_STRING,&ret_atom, &ret_format, &ret_len,
&ret_after, &ret_prop);
if ( (ret_format == 0) || (ret_len == 0) || (ret_after != 0) ) {
/*problems*/
printf("XGetWindowProperty Failed0);
*version = 0; *command = 0; *flags = 0; *ret_win = 0;
return 0;
}
/*ret_prop is a string. convert to an array of strings*/
/*first extract header info*/
hdr = (int*)ret_prop;
*version = *hdr++;
*command = *hdr++;
*flags = *hdr++;
file_count = *hdr++;
*ret_win = (Window)*hdr;
selected_str = ret_prop + HEADER_SIZE;
folded = (char**)malloc(sizeof(char*)*file_count);
for (i=0; i<file_count; i++) {
folded[i] = (char*)malloc(strlen(selected_str)+1);
strcpy(folded[i],selected_str);
selected_str += (strlen(selected_str)+1);
}
*ret_file_list = folded;
XFree(ret_prop);
return file_count;
5-4 Programmer Notes
HP VUE Version 1.0
}
/**** An Example Code fragment: ****/
/*make sure PropertyChangeMask is selected by XSelectInput*/
int ver,cmd,arg;
char **ret_file_list;
int i,count,nada;
/*set up and realize X Window*/
XNextEvent(disply, &myevent);
switch(myevent.type) {
case PropertyNotify:
if (myevent.xproperty.atom == VSH_MULTI_FILES) {
count = _vsh_get_dropped_command(your_disp,
your_win,&ver,&cmd,&arg,&win,&ret_file_list);
/*print out the files dropped*/
printf("The dropped files are:");
for (i=0; i<count; i++)
printf(" %s",ret_file_list[i]);
/*was it a modify or nomodify drag?*/
printf("Drag type: %s ",VSH_MODIFY(cmd) ?
"Modify" : "NoModify");
/*clean up*/
for (i=0; i<count; i++) free(ret_file_list[i]);
free(ret_file_list);
}
break;
}
Programmer Notes 5-5