[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2525.0. "Different results between V5.1 and V5.3" by POBOX::PETROVIC (Chicago Services EIS) Wed Mar 28 1990 00:17

I have a customer who's complaining that his DECwindow V5.1 functions no
longer work under DECwindows V5.3.  If I can summarize this correctly, the 
first problem relates to a function which used to create a DECterm window at 
a particular location on the screen.  

The second problem relates to the use of the function keys to toggle between
windows (they're afraid of the mouse).  

The following is a brief explaination and code for Problem I and Problem II,
any help on how to make these function work again would be much appreciated.

/mike

----------------------------------------------------------------------------
Problem I:

The function create_decterm creates the decterm where the TEAM application
will run.  The file DECWMAIN_PMM.DAT in the DECwTermPort call contains 
parameters for where to place the window.  When creating the terminal window 
on the VS3100 DECwindows V5.3, the window is not created in the proper place.  
The DECWMAIN_PMM file follows the code for the create_decterm function.  

static create_decterm( display )
Display *display;
{
   Window focus_window_1;
   int status;
   char device_name[50];
   unsigned int process_id;
   $DESCRIPTOR(image, "SYS$SYSTEM:LOGINOUT.EXE");
   $DESCRIPTOR(proc_name, "TEAM");
   struct dsc$descriptor_s device =
		{  0, DSC$K_DTYPE_T, DSC$K_CLASS_S, device_name };
   Window find_decterm_window();

   status = DECwTermPort(0,"SYS$LOGIN:DECWMAIN_PMM.DAT",NULL, device_name, 
			 &device.dsc$w_length);
#ifdef DEBUG
   if (!(status & 1)) {
	printf("DECwTermPort failed, status = %d\n", status);
   }
#endif

   /* Find the top-level window of the DECterm */
   focus_window_1 = find_decterm_window(display, DefaultRootWindow(display));

   /* bind key F2 to set focus to the DECterm */

   set_focus_key (display ,focus_window_1,XK_F2,0,True);
   set_focus_key (display ,focus_window_1,XK_F2,LockMask,True);

   /* Create a process to run in the DECterm */

   SYS$CREPRC( &process_id,
		&image,		/* Image to run */
		&device,	/* INPUT */
		&device,	/* OUTPUT */
		&device,	/* ERROR */
		0,		/* Privileges */
		0,		/* Quotas */
                &proc_name,	/* Process name */
                4,		/* Base priority */
		0,		/* UIC */
		0,		/* Mailbox */
		PRC$M_DETACH	 /* Options */
		);
}

*** End of function ***

*** DECWMAIN_PMM.DAT file ***

DECW$TERMINAL.borderWidth:	0
*.borderWidth: 0
DECW$TERMINAL.decWmValueMask:	1
DECW$TERMINAL.*.x: 2
DECW$TERMINAL.*.y: 2
DECW$TERMINAL.main.y : 200
DECW$TERMINAL.main.terminal.warningBellEnable:	on
DECW$TERMINAL.main.terminal.autoWrapEnable:	on
DECW$TERMINAL.main.terminal.rows:	24
DECW$TERMINAL.main.terminal.width:	648
DECW$TERMINAL.main.terminal.warningBellEnable:	on
DECW$TERMINAL.main.terminal.autoWrapEnable:	on
DECW$TERMINAL.main.terminal.saveLinesOffTop:	off
DECW$TERMINAL.main.terminal.displayWidth:	648
DECW$TERMINAL.main.terminal.scrollVertical:	off

---------------------------------------------------------------------------
Problem II:

Another item that was working on the VAXstation 3200 DECwindows V5.1 but not 
on the VAXstation 3100 DECwindows V5.3) is the use of function keys to toggle 
between windows.  For the prototype, F2 and F4 were used to shift focus.  F2 
would give focus to the DECterm window while F4 would give focus to a 
particular widget.  The code in the main program is as follows.  

*** C code that binds the F4 function key to change the window focus ***

   current_focus_widget = control_window;
   set_widget_focus_key( XtDisplay( cover_window ), cover_window,
			XK_F4, 0, True );
   set_widget_focus_key( XtDisplay( cover_window ), cover_window,
			XK_F4, LockMask, True );
*** End of code ***

Note:  The binding of F2 occurs in the create_decterm function

     The set_focus_key file contains the code that actually binds the keys.

*** set_focus_key_file ***

#include <decw$include/Dwtappl.h>
#include <decw$include/Xlib.h>

#define TRUE 1
#define FALSE 0
#define WINDOW 0
#define WIDGET 1

extern Widget current_focus_widget;

static int which = -1;
static Display *dpy;
static KeyCode window_keycode;
static KeyCode widget_keycode;
static Time window_keypress_time;
static Time widget_keypress_time = CurrentTime;
static Window root;
static Widget widget;
static Atom widget_focus_atom;
static int window_modifiers;

set_widget_focus_key( display, w, ksym, modifiers, async )
Display *display;
Widget w;
KeySym ksym;
unsigned int modifiers;
int async;
{
XtEventHandler widget_focus_handler();
int ast_func();
dpy = display;
root = DefaultRootWindow( dpy );
widget = w;
widget_focus_atom = XInternAtom( dpy, "CTT_TAKE_FOCUS",FALSE);
XtAddEventHandler( w, NoEventMask, TRUE, widget_focus_handler,
	&widget_keypress_time );

if (async) {
	XSelectAsyncInput(dpy,root,FocusChangeMask | KeyPressMask | 
			  KeyReleaseMask, ast_func,0);
}

widget_keycode = XKeysymToKeycode( dpy, ksym);

XGrabKey( dpy, widget_keycode, modifiers,root,False,GrabModeAsync, GrabModeAsync
);

XSelectInput(dpy,root,FocusChangeMask);
XFlush( dpy );

return;
}

















XtEventHandler widget_focus_handler( w, time, event )
Widget w;
Time *time;
XClientMessageEvent *event; /* don't care */
{
if (event->type != ClientMessage)
	return;
if (event->message_type != widget_focus_atom)
	return;

XtCallAcceptFocus( current_focus_widget, time );
}












send_set_focus( widget )
Widget *widget;
{
XClientMessageEvent event;

	event.type = ClientMessage;
	event.display = dpy;
	event.window = XtWindow( widget );
	event.message_type = widget_focus_atom;
	event.format = 32;
	event.data.l[0] = widget_keypress_time;
	event.data.l[1] = 0;
	event.data.l[2] = 0;
	event.data.l[3] = 0;
	event.data.l[4] = 0;

	XSendEvent( event.display, event.window, TRUE, NoEventMask, &event );
}






set_focus_key(display,focus_window,ksym,modifiers,async)
Display *display;
Window focus_window;
KeySym ksym;
unsigned int modifiers;
int async;
{
int ast_func();  
int ast_term_func();

/* Save global information */
dpy = display;
window_modifiers = modifiers;

#ifdef DEBUG
printf("%s\n",async ? "ASYNCHRONOUS" : "SYNCHRONOUS" );
#endif

root = DefaultRootWindow( dpy );

if (async) {
	XSelectAsyncInput(dpy,root,FocusChangeMask | KeyPressMask | 
			  KeyReleaseMask, ast_func,focus_window);
	XSelectAsyncInput(dpy, focus_window, StructureNotifyMask,
			ast_term_func, focus_window );
}

window_keycode = XKeysymToKeycode( dpy, ksym);

XGrabKey( dpy, window_keycode, modifiers,root,False,GrabModeAsync, GrabModeAsync
);

XSelectInput(dpy,root,FocusChangeMask);
XSelectInput(dpy,focus_window,StructureNotifyMask);
XFlush( dpy );

return;
}

ast_term_func( focus_window )
Window focus_window;
{
	XEvent event;
#ifdef DEBUG
	printf("..in ast_term_func()\n");
#endif
	while (XCheckWindowEvent(dpy, focus_window, StructureNotifyMask,
				 &event)){
	      ProcessEvent(&event,focus_window);
	}
}

ast_func(focus_window)
Window focus_window;
{
	XEvent event;
#ifdef DEBUG
	printf("..in ast_func()\n");
#endif
	while (XCheckWindowEvent(dpy,root,FocusChangeMask | KeyPressMask |
				 KeyReleaseMask,&event)){
	      ProcessEvent(&event,focus_window);
	}
}

ask_to_take_focus(win)
Window win;
{
XClientMessageEvent e;

e.display = dpy;
e.type = ClientMessage;

e.message_type = XInternAtom(dpy,"DEC_WM_TAKE_FOCUS",FALSE);

e.format = 32;
e.data.l[0] = window_keypress_time;
e.data.l[1] = 0;
e.data.l[2] = 0;
e.data.l[3] = 0;
e.data.l[4] = 0;
e.window = win;

XSendEvent(dpy,win,TRUE,NoEventMask,&e);
}

ProcessEvent(event,focus_window)
XEvent *event;
Window focus_window;
{
XKeyEvent *ke;
XFocusChangeEvent *fe;
XDestroyWindowEvent *de;

switch (event->type) {
	case KeyPress:
		ke = event;
		if (ke->keycode == window_keycode) {
			which = WINDOW;
			window_keypress_time = ke->time;
		}
		else if (ke->keycode == widget_keycode) {
			which = WIDGET;
			widget_keypress_time = ke->time;
		}
#if DEBUG
		printf("key pressed %d\n",ke->keycode);
		break;
#endif
#ifdef DEBUG
	case KeyRelease:
		ke = event;
		printf("Focus In");
		if (fe->mode == NotifyGrab)
			printf(", NotifyGrab\n");
		else
			printf(",mode = %d\n",fe->mode);
		printf("   detail = %d\n",fe->detail);
		if (fe->window != root)
			printf("   Not root window\n");
		break;
#endif
	case FocusOut:
		fe = event;
#ifdef DEBUG
		printf("Focus Out");
		if (fe->mode == NotifyGrab)
			printf(", NotifyGrab\n");
		else if (fe->mode == NotifyUngrab)
			printf(", NotifyUngrab\n");
		else
			printf(", mode = %d\n",fe->mode);
		printf("   detail = %d\n",fe->detail);
		if (fe->window != root)
		      	printf("   Not root window\n");
#endif

		if (fe->mode == NotifyUngrab)
			if (which == WINDOW)
				ask_to_take_focus(focus_window);
			else if (which == WIDGET)
				send_set_focus(widget);
		break;
	case DestroyNotify :
		de = event;
		if (de->window == focus_window) {
			/* Ungrab key */
			XUngrabKey( dpy, window_keycode,
				window_modifiers, root );
			/* set focus to 'current_focus_widget' */
			send_set_focus( widget );
		}      
	default:
#ifdef DEBUG
		print(" Other event %d\n",event->type);
#endif
		break;
	}
}

-----------------------------------------------------------------------------
T.RTitleUserPersonal
Name
DateLines
2525.1Possible solution for window position problemHANNAH::MESSENGERBob MessengerWed Mar 28 1990 12:1317
Re: .0

For one thing, they should try changing:

DECW$TERMINAL.*.x: 2
DECW$TERMINAL.*.y: 2

to:

DECW$TERMINAL.x: 2
DECW$TERMINAL.y: 2

However, some people have reported problems (which I can't reproduce) where
DECterm doesn't honor all their customizations.  Maybe there is a conflicting
resource definition in another file (such as DECW$XDEFAULTS.DAT).

				-- Bob
2525.2Window positioning still wrongPOBOX::PETROVICChicago Services EISWed Mar 28 1990 17:457
Bob,

Removing the ".*" out of the DECW$TERMINAL functions did not correct
the problem.

/mike