[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
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 |
3365.0. "XSetFont cancels XSelectAsyncInput?" by WPOMM2::ZAMBOTTI (It only works after you ask!) Thu Sep 20 1990 02:43
Hi again,
this note duplicates note 3242.6 and is in reference to note 3242.0 and
has been re-entered as a new topic.
I have found a problem in my application code. When ever certain
X functions are called XSelectAsyntInput then the requested async input
seems to turn off.
In the example that follows you may resize the window as many times as
you like (the new size is displayed in the window top border). But if
you change the font (XSetFont()) more than once then the async routine
is no longer called.
To change the font press MB3 (mouse button 3) where you would like the
text to appear then press MB3 in the top left corner (X > 10 & X < 20 &
Y > 10 & Y < 20).
If you press in the font set area (described above) once then resize
the window you will notice the window name change. But change the font
twice and resize the window you will notice the window name will not
change. The async input routine has somehow being cancelled.
The code follows below. I only tried this on the DECstation and not on
VMS (could somebody try this for me).
-----------------------------------------------------------------------
#include <stdio.h>
#ifdef VMS
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#include <decw$include/Xatom.h>
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#endif
Display *Disp = NULL ;
Screen *Screen1 ;
Visual *DefScreenVis ;
Window Win1, DefRootWin ;
XSetWindowAttributes WinAttr ;
Window FocusReturn ;
XGCValues GCVals ;
GC TextGC ;
int RevertToReturn ;
XWMHints Win1WMHints = { InputHint|StateHint, False, NormalState, 0, 0, 0, 0, 0 } ;
XSizeHints Win1SizeHints = { USPosition|USSize|PMinSize|PMaxSize, 0, 0, 640, 350, 640, 350, 1020, 840 } ;
XWindowChanges WindowChange ;
int DeviceWidth = 640, DeviceHeight = 350, WindowResizeIntercept() ;
void readlocator_();
void initgraphics_();
main()
{
short int XPos, YPos, Button, LastX, LastY ;
static XFontStruct *DotFont = NULL ;
initgraphics_(0) ;
for(;;)
{
readlocator_(&XPos, &YPos, &Button) ;
if(Button) {
printf("Rodent activity detected @ %d %d with button %d\n", XPos, YPos, Button) ;
if(Button == 132 && XPos < 10 && YPos < 10) {
exit(0) ;
}
if(Button == 132 && XPos < 20 && YPos < 20) {
if(DotFont) {
XFreeFont(Disp, DotFont) ;
}
if((DotFont = XLoadQueryFont(Disp, "-dec-terminal-medium-r-wide--14-140-*-c-120-iso8859-1")) == NULL) {
fprintf(stderr, "Can't find font\n") ;
exit(1) ;
}
XSetFont(Disp, TextGC, DotFont->fid) ;
XDrawImageString(Disp, Win1, TextGC, LastX, LastY, "Hello", 5) ;
XFlush(Disp) ;
printf("Font Changed\n") ;
}
LastX = XPos ;
LastY = YPos ;
}
}
}
void initgraphics_(mode)
short int *mode ; /* not used */
{
char WindowName[20] ;
if(Disp != NULL) {
return ;
}
Disp = XOpenDisplay(NULL) ;
if(Disp == NULL) {
return ;
}
Screen1 = XDefaultScreenOfDisplay(Disp) ;
DefRootWin = XDefaultRootWindow(Disp) ;
DefScreenVis = XDefaultVisualOfScreen(Screen1) ;
WinAttr.event_mask = StructureNotifyMask ;
WinAttr.background_pixel = XBlackPixel(Disp, XDefaultScreen(Disp)) ;
WinAttr.backing_store = Always ;
Win1 = XCreateWindow(Disp, DefRootWin, 0, 0, 1020, 840, 0, CopyFromParent,
InputOutput, CopyFromParent,
CWEventMask|CWBackPixel|CWBackingStore, &WinAttr) ;
XSelectAsyncInput(Disp, Win1, StructureNotifyMask, WindowResizeIntercept, NULL) ;
sprintf(WindowName, "Surpac : %d %d", DeviceWidth, DeviceHeight) ;
XStoreName(Disp, Win1, WindowName) ;
XSetIconName(Disp, Win1, "Surpac Mining") ;
GCVals.background = XBlackPixelOfScreen(XDefaultScreenOfDisplay(Disp)) ;
GCVals.foreground = XWhitePixelOfScreen(XDefaultScreenOfDisplay(Disp)) ;
TextGC = XCreateGC(Disp, Win1, (GCForeground | GCBackground), &GCVals) ;
WindowChange.width = Win1SizeHints.width = DeviceWidth ;
WindowChange.height = Win1SizeHints.height = DeviceHeight ;
XSetNormalHints(Disp, Win1, &Win1SizeHints) ;
XConfigureWindow(Disp, Win1, CWWidth | CWHeight, &WindowChange) ;
XMapWindow(Disp, Win1) ;
XGetInputFocus(Disp, &FocusReturn, &RevertToReturn) ;
}
XEvent WindowResize ;
WindowResizeIntercept(NotUsed)
long NotUsed ;
{
char WindowName[20] ;
XNextEvent(Disp, &WindowResize) ;
switch(WindowResize.xconfigure.type){
case ConfigureNotify :
DeviceWidth = WindowResize.xconfigure.width ;
DeviceHeight = WindowResize.xconfigure.height ;
printf("async event received : %d %d\n", DeviceWidth, DeviceHeight) ;
sprintf(WindowName, "Surpac : %d %d", DeviceWidth, DeviceHeight) ;
XStoreName(Disp, Win1, WindowName) ;
XFlush(Disp); break ;
}
}
void readlocator_(x, y, status)
short int *x, *y, *status ;
{
int RootX, RootY, ButtonMask ;
short int WinX, WinY;
Window Root, Child ;
#ifdef VMS
if(XQueryPointer(Disp, Win1, &Root, &Child, &RootX, &RootY,
&WinX, &WinY, &ButtonMask) && Child == Win1) {
#else
if(XQueryPointer(Disp, Win1, &Root, &Child, &RootX, &RootY,
&WinX, &WinY, &ButtonMask) /* && Child == Win1 */) {
#endif
if(WinX < 0 || WinX >= DeviceWidth || WinY < 0 || WinY >= DeviceHeight)
WinX = WinY = 0 ;
*x = WinX ;
*y = WinY ;
switch(ButtonMask & (Button1Mask | Button2Mask | Button3Mask)) {
case Button1Mask : case Button2Mask : *status = 130 ; break ;
case Button3Mask : *status = 132 ; break ;
default : *status = 0 ; break ;
}
}
}
T.R | Title | User | Personal Name | Date | Lines
|
---|