Re: Alt-Esc works, why can't we pass Alt-Tab to the WM?

2003-07-04 Thread Igor Pechtchanski
On Fri, 4 Jul 2003, Sam Edge wrote:

 Igor Pechtchanski [EMAIL PROTECTED] wrote in [EMAIL PROTECTED]
 in gmane.os.cygwin.xfree on Wed, 2 Jul 2003 19:26:44 -0400 (EDT):

  On Wed, 2 Jul 2003, Harold L Hunt II wrote:
   There is the possibility that Alt+Tab can only be trapped on NT-based
   OSes, but that isn't much more to worry about.

  Win98, at least, has a Misc tab in shortcut properties, that lists Windows
  shortcut keys to ignore (let the application handle).  Alt-Tab is one of
  them.  Thus, you could instruct the users set up a shortcut to XWin.exe
  and let it handle Alt-Tab, even if XWin.exe can't capture it itself.
  P.S. I'm not sure Win95/ME have this feature.

 I think you'll find that the Misc property page is only available with
 shortcuts to DOS-mode applications. Windows-native executables like
 XWin.exe don't have it.

Yes, you're right.  However, after some more digging, it seems that
keyboard hooks (perhaps similar to what Harold suggested earlier?) *can*
be used on Win9x to intercept hotkeys (e.g., Alt-Tab) in Win32 apps.  I
haven't found the exact instructions on MSDN, though...
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster.  -- Patrick Naughton



Re: Alt-Esc works, why can't we pass Alt-Tab to the WM?

2003-07-04 Thread Joakim Erdfelt
Igor Pechtchanski wrote:

Yes, you're right.  However, after some more digging, it seems that
keyboard hooks (perhaps similar to what Harold suggested earlier?) *can*
be used on Win9x to intercept hotkeys (e.g., Alt-Tab) in Win32 apps.  I
haven't found the exact instructions on MSDN, though...
Igor
Wouldn't the vnc / tightvnc win32 servers have an example of this hook?
Since their full-screen mode does intercept those keys. 
In fact, the only key they make available to escape the vnc session is
Ctrl-ESC.  All others are sent down the vnc path.

Would it be ethical (or within license) to borrow that code?

/* joakim */



Memory access error in XWin -multiwindow

2003-07-04 Thread Biju G C
Harold,

I am facing an issue of Memory access error in XWin -multiwindow mode
see http://www.cygwin.com/ml/cygwin-xfree/2003-06/msg00294.html

So Ralf pointed me to http://cygwin.com/ml/cygwin-xfree/2003-06/msg00162.html

After seeing that patch, I have just gone thru XWin Source and found,
at lot of place we call memory alloc and not testing the return value.
I am attaching the list  extracts from programs
I dont know all of those will make any issue.

I did not checked whether it is properly free()-ed
And also I did not checked the functions which receives 
allocated memory another function as return value or thru 
a passed argument to the called function.


List of variables:-

in winmultiwindowwm.c
   pXMsgArgat function winInitWM 


in winmultiwindowwindow.c
   vlist   at function winMoveXWindow 
   vlist   at function winResizeXWindow 


in winmultiwindowicons.c
   iconDataat function winScaleXBitmapToWindows 
   image   at function winXIconToHICON 
   imageMask   at function winXIconToHICON 
   maskat function winXIconToHICON 


in winmultiwindowclass.c
   *res_name   at function winMultiWindowGetClassHint 
   *res_role   at function winMultiWindowGetWindowRole 


in winconfig.c
   ret at function winNormalizeName 


in winclipboardxevents.c
   pszUTF8 at function winClipboardFlushXEvents 
   pszReturnData   at function winClipboardFlushXEvents 
   pwszUnicodeStr  at function winClipboardFlushXEvents 
   hGlobal at function winClipboardFlushXEvents 


in winclipboardtextconv.c
   pszDestBegin / pszDest at function winClipboardUNIXtoDOS 




### EXTRACTS FROM PROGRAMS ##



### NEXT FILE ##

winmultiwindowwm.c

Bool
winInitWM (void **ppWMInfo,
   pthread_t *ptWMProc,
   pthread_t *ptXMsgProc,
   pthread_mutex_t *ppmServerStarted,
   int dwScreen)
{
  WMProcArgPtr  pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
  WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
  XMsgProcArgPtrpXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));

  /* Bail if the input parameters are bad */
  if (pArg == NULL || pWMInfo == NULL)
{
  ErrorF (winInitWM - malloc fail.\n);
  return FALSE;
}




### NEXT FILE ##

winmultiwindowwindow.c

void
winMoveXWindow (WindowPtr pWin, int x, int y)
{
  XID *vlist = malloc(sizeof(long)*2);

  (CARD32*)vlist[0] = x;
  (CARD32*)vlist[1] = y;
  ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
  free(vlist);
}


/*
 * winResizeXWindow - 
 */

void
winResizeXWindow (WindowPtr pWin, int w, int h)
{
  XID *vlist = malloc(sizeof(long)*2);

  (CARD32*)vlist[0] = w;
  (CARD32*)vlist[1] = h;
  ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
  free(vlist);
}



### NEXT FILE ##

winmultiwindowicons.c


static void
winScaleXBitmapToWindows (int iconSize,
  int effBPP,
  PixmapPtr pixmap,
  unsigned char *image)
{



  iconData = malloc (xStride * pixmap-drawable.height);
  miGetImage ((DrawablePtr) (pixmap-drawable), 0, 0,
  pixmap-drawable.width, pixmap-drawable.height,
  ZPixmap, 0x, iconData);






HICON
winXIconToHICON (WindowPtr pWin)
{

.
  image = (unsigned char * ) malloc (stride * iconSize);
  imageMask = (unsigned char *) malloc (stride * iconSize);
  mask = (unsigned char *) malloc (maskStride * iconSize);





### NEXT FILE ##

winmultiwindowclass.c

int
winMultiWindowGetClassHint (WindowPtr pWin, char **res_name, char **res_class)
{



(*res_name) = malloc (len_name + 1);


int
winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role)
{


(*res_role) = malloc (len_role + 1);




### NEXT FILE ##

winconfig.c

char *
winNormalizeName (const char *s)
{

..

  ret = malloc (strlen (s) + 1);




### NEXT FILE ##

winclipboardxevents.c
Bool
winClipboardFlushXEvents (HWND hwnd,
  Atom atomClipboard,
  Atom atomLocalProperty,
  Atom atomUTF8String,
  Atom atomCompoundText,
  Atom atomTargets,
  Atom atomDeleteWindow,
  int iWindow,
  Display *pDisplay,
  Bool fUnicodeSupport)
{


  pszUTF8 = (char *) malloc (iUTF8); /* Don't need +1 */
  WideCharToMultiByte (CP_UTF8,



...


  if (iCount  0)
{
  pszReturnData = malloc (strlen (ppszTextList[0]) + 1);
  strcpy (pszReturnData, ppszTextList[0]);
}
  else
{
  pszReturnData = malloc 

RE: Memory access error in XWin -multiwindow

2003-07-04 Thread Ralf Habacker
Hi Biju,

 I am facing an issue of Memory access error in XWin -multiwindow mode
 see http://www.cygwin.com/ml/cygwin-xfree/2003-06/msg00294.html

 So Ralf pointed me to http://cygwin.com/ml/cygwin-xfree/2003-06/msg00162.html

 After seeing that patch, I have just gone thru XWin Source and found,
 at lot of place we call memory alloc and not testing the return value.
 I am attaching the list  extracts from programs
 I dont know all of those will make any issue.

 I did not checked whether it is properly free()-ed

You can try the mem_watch library on
http://sourceforge.net/project/showfiles.php?group_id=27249.
It allows checking of memory related calls on cygwin with minimal effort.

After installing this package, relink the Xserver with the following line:

$ make LDFLAGS=-Wl,--whole-archive -Wl,-lmemwatch -Wl,--no-whole-archive

Then start Xwin and you can see all memory related calls and there calling
address.

See an example output below (you can get more informations through the INSTALL
file of the memwatch release).

$ ./test
MemWatch hooks installed (set MEMWATCH=1 env var to enable debugging)

Memory Checker report
=
number of calls:
malloc   : 3
calloc   : 1
realloc  : 0
free : 1

used memory  : 350

unfree'd memory areas

  address sizecalladdr

 0a040488  30000401afc
 0a040448   2000401ac7
 0a040460   3000401ad9
==
   350

compile this application with debugging symbols and try
addr2line to get the source line of the relating call

addr2line -e ./test.exe calladdr

May be that helps.

Cheers
Ralf



Re: Alt-Esc works, why can't we pass Alt-Tab to the WM?

2003-07-04 Thread Igor Pechtchanski
On Fri, 4 Jul 2003, Joakim Erdfelt wrote:

 Igor Pechtchanski wrote:

 Yes, you're right.  However, after some more digging, it seems that
 keyboard hooks (perhaps similar to what Harold suggested earlier?) *can*
 be used on Win9x to intercept hotkeys (e.g., Alt-Tab) in Win32 apps.  I
 haven't found the exact instructions on MSDN, though...
Igor
 
 Wouldn't the vnc / tightvnc win32 servers have an example of this hook?
 Since their full-screen mode does intercept those keys.
 In fact, the only key they make available to escape the vnc session is
 Ctrl-ESC.  All others are sent down the vnc path.

 Would it be ethical (or within license) to borrow that code?

 /* joakim */

Actually, I did eventually find an example on MSDN that it would be
perfectly ethical to borrow from, IMO:
http://msdn.microsoft.com/msdnmag/issues/0700/Win32/.  Harold also
posted an example of a keyboard hook a while ago -- the only question was
whether this will work on Win9x, and the MSDN example seems to suggest
that it will.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster.  -- Patrick Naughton