1998-12-07 10:13:40 +01:00
|
|
|
/*
|
1998-12-26 13:00:43 +01:00
|
|
|
* X11 event driver
|
1998-12-07 10:13:40 +01:00
|
|
|
*
|
|
|
|
* Copyright 1993 Alexandre Julliard
|
1999-09-20 17:42:47 +02:00
|
|
|
* 1999 Noel Borthwick
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2000-04-25 21:55:35 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "ts_xlib.h"
|
2002-09-24 20:36:51 +02:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
1999-12-12 20:42:47 +01:00
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
2002-09-24 20:36:51 +02:00
|
|
|
#include <X11/extensions/xf86dga.h>
|
1999-12-12 20:42:47 +01:00
|
|
|
#endif
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
2000-09-16 22:58:06 +02:00
|
|
|
#include "wine/winuser16.h"
|
2000-09-26 01:56:41 +02:00
|
|
|
#include "shlobj.h" /* DROPFILES */
|
2000-09-16 22:58:06 +02:00
|
|
|
|
1999-02-04 12:11:01 +01:00
|
|
|
#include "clipboard.h"
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "dce.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-12-12 22:28:44 +01:00
|
|
|
#include "input.h"
|
2000-03-08 19:26:56 +01:00
|
|
|
#include "win.h"
|
1999-02-04 12:11:01 +01:00
|
|
|
#include "winpos.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
2001-06-26 21:36:23 +02:00
|
|
|
#include "winreg.h"
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "x11drv.h"
|
2001-01-02 22:00:46 +01:00
|
|
|
#include "shellapi.h"
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(event);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/* X context to associate a hwnd to an X window */
|
|
|
|
extern XContext winContext;
|
|
|
|
|
|
|
|
extern Atom wmProtocols;
|
|
|
|
extern Atom wmDeleteWindow;
|
|
|
|
extern Atom dndProtocol;
|
|
|
|
extern Atom dndSelection;
|
|
|
|
|
|
|
|
#define DndNotDnd -1 /* OffiX drag&drop */
|
|
|
|
#define DndUnknown 0
|
|
|
|
#define DndRawData 1
|
|
|
|
#define DndFile 2
|
|
|
|
#define DndFiles 3
|
|
|
|
#define DndText 4
|
|
|
|
#define DndDir 5
|
|
|
|
#define DndLink 6
|
|
|
|
#define DndExe 7
|
|
|
|
|
|
|
|
#define DndEND 8
|
|
|
|
|
|
|
|
#define DndURL 128 /* KDE drag&drop */
|
|
|
|
|
|
|
|
static const char * const event_names[] =
|
|
|
|
{
|
|
|
|
"", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
|
|
|
|
"MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut",
|
|
|
|
"KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify",
|
|
|
|
"CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",
|
|
|
|
"ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify",
|
|
|
|
"ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify",
|
|
|
|
"SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify",
|
|
|
|
"ClientMessage", "MappingNotify"
|
|
|
|
};
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
static void EVENT_ProcessEvent( XEvent *event );
|
|
|
|
|
|
|
|
/* Event handlers */
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_FocusIn( HWND hWnd, XFocusChangeEvent *event );
|
|
|
|
static void EVENT_FocusOut( HWND hWnd, XFocusChangeEvent *event );
|
1999-09-20 17:42:47 +02:00
|
|
|
static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BOOL bIsMultiple );
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_SelectionClear( HWND hWnd, XSelectionClearEvent *event);
|
1999-09-20 17:42:47 +02:00
|
|
|
static void EVENT_PropertyNotify( XPropertyEvent *event );
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event );
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
extern void X11DRV_ButtonPress( HWND hwnd, XButtonEvent *event );
|
|
|
|
extern void X11DRV_ButtonRelease( HWND hwnd, XButtonEvent *event );
|
|
|
|
extern void X11DRV_MotionNotify( HWND hwnd, XMotionEvent *event );
|
2002-06-14 02:08:40 +02:00
|
|
|
extern void X11DRV_EnterNotify( HWND hwnd, XCrossingEvent *event );
|
2001-10-17 19:50:02 +02:00
|
|
|
extern void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event );
|
2001-10-18 23:38:59 +02:00
|
|
|
extern void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event );
|
2001-06-22 05:42:27 +02:00
|
|
|
extern void X11DRV_Expose( HWND hwnd, XExposeEvent *event );
|
2001-06-04 23:55:17 +02:00
|
|
|
extern void X11DRV_MapNotify( HWND hwnd, XMapEvent *event );
|
|
|
|
extern void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event );
|
|
|
|
extern void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event );
|
2001-10-17 19:50:02 +02:00
|
|
|
extern void X11DRV_MappingNotify( XMappingEvent *event );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
1999-12-12 20:42:47 +01:00
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
|
|
|
static int DGAMotionEventType;
|
|
|
|
static int DGAButtonPressEventType;
|
|
|
|
static int DGAButtonReleaseEventType;
|
|
|
|
static int DGAKeyPressEventType;
|
|
|
|
static int DGAKeyReleaseEventType;
|
|
|
|
|
|
|
|
static BOOL DGAUsed = FALSE;
|
|
|
|
static HWND DGAhwnd = 0;
|
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
extern void X11DRV_DGAMotionEvent( HWND hwnd, XDGAMotionEvent *event );
|
|
|
|
extern void X11DRV_DGAButtonPressEvent( HWND hwnd, XDGAButtonEvent *event );
|
|
|
|
extern void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XDGAButtonEvent *event );
|
1999-12-12 20:42:47 +01:00
|
|
|
#endif
|
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
/* Static used for the current input method */
|
|
|
|
static INPUT_TYPE current_input_type = X11DRV_INPUT_ABSOLUTE;
|
|
|
|
static BOOL in_transition = FALSE; /* This is not used as for today */
|
1998-12-07 10:13:40 +01:00
|
|
|
|
|
|
|
|
1999-07-10 12:24:31 +02:00
|
|
|
/***********************************************************************
|
2001-05-16 21:52:29 +02:00
|
|
|
* process_events
|
1999-07-10 12:24:31 +02:00
|
|
|
*/
|
2001-06-04 23:55:17 +02:00
|
|
|
static int process_events( struct x11drv_thread_data *data )
|
1999-02-21 19:15:26 +01:00
|
|
|
{
|
1999-05-22 20:57:17 +02:00
|
|
|
XEvent event;
|
2001-06-04 23:55:17 +02:00
|
|
|
int count = 0;
|
1999-02-21 19:15:26 +01:00
|
|
|
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 23:55:17 +02:00
|
|
|
while ( XPending( data->display ) )
|
1999-05-22 20:57:17 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
XNextEvent( data->display, &event );
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_unlock();
|
1999-05-22 20:57:17 +02:00
|
|
|
EVENT_ProcessEvent( &event );
|
2001-06-04 23:55:17 +02:00
|
|
|
count++;
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_lock();
|
1999-05-22 20:57:17 +02:00
|
|
|
}
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
return count;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/***********************************************************************
|
2001-05-19 00:51:56 +02:00
|
|
|
* MsgWaitForMultipleObjectsEx (X11DRV.@)
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2001-05-19 00:51:56 +02:00
|
|
|
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
|
|
|
|
DWORD timeout, DWORD mask, DWORD flags )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1]; /* FIXME! */
|
|
|
|
DWORD i, ret;
|
|
|
|
struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
|
|
|
|
|
|
|
|
if (!data || data->process_event_count)
|
2001-05-19 00:51:56 +02:00
|
|
|
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
2001-05-16 21:52:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) new_handles[i] = handles[i];
|
|
|
|
new_handles[count] = data->display_fd;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( gdi_display );
|
|
|
|
XFlush( data->display );
|
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
data->process_event_count++;
|
|
|
|
if (process_events( data )) ret = count;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = WaitForMultipleObjectsEx( count+1, new_handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
|
|
|
if (ret == count) process_events( data );
|
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
data->process_event_count--;
|
|
|
|
return ret;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_ProcessEvent
|
|
|
|
*
|
|
|
|
* Process an X event.
|
|
|
|
*/
|
|
|
|
static void EVENT_ProcessEvent( XEvent *event )
|
|
|
|
{
|
1999-04-15 17:22:23 +02:00
|
|
|
HWND hWnd;
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = event->xany.display;
|
1999-03-16 11:37:30 +01:00
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE( "called.\n" );
|
1999-05-22 20:57:17 +02:00
|
|
|
|
1999-03-16 11:37:30 +01:00
|
|
|
switch (event->type)
|
1999-04-01 14:03:52 +02:00
|
|
|
{
|
|
|
|
case SelectionNotify: /* all of these should be caught by XCheckTypedWindowEvent() */
|
1999-12-08 04:56:23 +01:00
|
|
|
FIXME("Got SelectionNotify - must not happen!\n");
|
1999-04-01 14:03:52 +02:00
|
|
|
/* fall through */
|
|
|
|
|
1999-03-16 11:37:30 +01:00
|
|
|
/* We get all these because of StructureNotifyMask.
|
|
|
|
This check is placed here to avoid getting error messages below,
|
|
|
|
as X might send some of these even for windows that have already
|
|
|
|
been deleted ... */
|
|
|
|
case CirculateNotify:
|
|
|
|
case CreateNotify:
|
|
|
|
case DestroyNotify:
|
|
|
|
case GravityNotify:
|
|
|
|
case ReparentNotify:
|
|
|
|
return;
|
1999-04-01 14:03:52 +02:00
|
|
|
}
|
1999-11-07 23:44:06 +01:00
|
|
|
|
1999-12-12 20:42:47 +01:00
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
|
|
|
if (DGAUsed) {
|
|
|
|
if (event->type == DGAMotionEventType) {
|
|
|
|
TRACE("DGAMotionEvent received.\n");
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_DGAMotionEvent( DGAhwnd, (XDGAMotionEvent *)event );
|
1999-12-12 20:42:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event->type == DGAButtonPressEventType) {
|
|
|
|
TRACE("DGAButtonPressEvent received.\n");
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_DGAButtonPressEvent( DGAhwnd, (XDGAButtonEvent *)event );
|
1999-12-12 20:42:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event->type == DGAButtonReleaseEventType) {
|
|
|
|
TRACE("DGAButtonReleaseEvent received.\n");
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_DGAButtonReleaseEvent( DGAhwnd, (XDGAButtonEvent *)event );
|
1999-12-12 20:42:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((event->type == DGAKeyPressEventType) ||
|
|
|
|
(event->type == DGAKeyReleaseEventType)) {
|
1999-12-12 22:28:44 +01:00
|
|
|
/* Fill a XKeyEvent to send to EVENT_Key */
|
1999-12-12 20:42:47 +01:00
|
|
|
XKeyEvent ke;
|
1999-12-12 22:28:44 +01:00
|
|
|
XDGAKeyEvent *evt = (XDGAKeyEvent *) event;
|
1999-12-12 20:42:47 +01:00
|
|
|
|
|
|
|
TRACE("DGAKeyPress/ReleaseEvent received.\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-12 22:28:44 +01:00
|
|
|
if (evt->type == DGAKeyReleaseEventType)
|
|
|
|
ke.type = KeyRelease;
|
|
|
|
else
|
|
|
|
ke.type = KeyPress;
|
|
|
|
ke.serial = evt->serial;
|
|
|
|
ke.send_event = FALSE;
|
|
|
|
ke.display = evt->display;
|
|
|
|
ke.window = 0;
|
|
|
|
ke.root = 0;
|
|
|
|
ke.subwindow = 0;
|
|
|
|
ke.time = evt->time;
|
2001-10-17 19:50:02 +02:00
|
|
|
ke.x = -1;
|
|
|
|
ke.y = -1;
|
1999-12-12 22:28:44 +01:00
|
|
|
ke.x_root = -1;
|
|
|
|
ke.y_root = -1;
|
|
|
|
ke.state = evt->state;
|
|
|
|
ke.keycode = evt->keycode;
|
|
|
|
ke.same_screen = TRUE;
|
2001-10-17 19:50:02 +02:00
|
|
|
X11DRV_KeyEvent( 0, &ke );
|
1999-12-12 20:42:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-09-24 20:36:51 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if (XFindContext( display, event->xany.window, winContext, (char **)&hWnd ) != 0)
|
1999-05-22 20:57:17 +02:00
|
|
|
hWnd = 0; /* Not for a registered window */
|
2002-09-24 20:36:51 +02:00
|
|
|
wine_tsx11_unlock();
|
1999-04-15 17:22:23 +02:00
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
if ( !hWnd && event->xany.window != root_window
|
2002-06-01 01:06:46 +02:00
|
|
|
&& event->type != PropertyNotify
|
2000-04-16 19:07:27 +02:00
|
|
|
&& event->type != MappingNotify)
|
2001-06-04 23:55:17 +02:00
|
|
|
WARN( "Got event %s for unknown Window %08lx\n",
|
|
|
|
event_names[event->type], event->xany.window );
|
1999-03-10 14:26:09 +01:00
|
|
|
else
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Got event %s for hwnd %04x\n",
|
|
|
|
event_names[event->type], hWnd );
|
1999-04-15 17:22:23 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
switch(event->type)
|
|
|
|
{
|
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
2001-10-17 19:50:02 +02:00
|
|
|
/* FIXME: should generate a motion event if event point is different from current pos */
|
|
|
|
X11DRV_KeyEvent( hWnd, (XKeyEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-10-18 23:38:59 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case ButtonPress:
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_ButtonPress( hWnd, (XButtonEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-10-18 23:38:59 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case ButtonRelease:
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_ButtonRelease( hWnd, (XButtonEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-06-25 22:01:03 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case MotionNotify:
|
2001-10-18 23:38:59 +02:00
|
|
|
X11DRV_MotionNotify( hWnd, (XMotionEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
1999-07-24 14:16:00 +02:00
|
|
|
|
2002-06-14 02:08:40 +02:00
|
|
|
case EnterNotify:
|
|
|
|
X11DRV_EnterNotify( hWnd, (XCrossingEvent*)event );
|
|
|
|
break;
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
case FocusIn:
|
|
|
|
EVENT_FocusIn( hWnd, (XFocusChangeEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case FocusOut:
|
1999-04-15 17:22:23 +02:00
|
|
|
EVENT_FocusOut( hWnd, (XFocusChangeEvent*)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case Expose:
|
2001-06-22 05:42:27 +02:00
|
|
|
X11DRV_Expose( hWnd, &event->xexpose );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case ConfigureNotify:
|
2001-05-16 21:52:29 +02:00
|
|
|
if (!hWnd) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
X11DRV_ConfigureNotify( hWnd, &event->xconfigure );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionRequest:
|
2001-05-16 21:52:29 +02:00
|
|
|
if (!hWnd) return;
|
1999-09-20 17:42:47 +02:00
|
|
|
EVENT_SelectionRequest( hWnd, (XSelectionRequestEvent *)event, FALSE );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionClear:
|
2001-05-16 21:52:29 +02:00
|
|
|
if (!hWnd) return;
|
1999-04-15 17:22:23 +02:00
|
|
|
EVENT_SelectionClear( hWnd, (XSelectionClearEvent*) event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
case PropertyNotify:
|
|
|
|
EVENT_PropertyNotify( (XPropertyEvent *)event );
|
|
|
|
break;
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case ClientMessage:
|
2001-05-16 21:52:29 +02:00
|
|
|
if (!hWnd) return;
|
1999-04-15 17:22:23 +02:00
|
|
|
EVENT_ClientMessage( hWnd, (XClientMessageEvent *) event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NoExpose:
|
|
|
|
break;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
case MapNotify:
|
2001-06-04 23:55:17 +02:00
|
|
|
X11DRV_MapNotify( hWnd, (XMapEvent *)event );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
1999-04-01 14:03:52 +02:00
|
|
|
|
|
|
|
case UnmapNotify:
|
2001-06-04 23:55:17 +02:00
|
|
|
X11DRV_UnmapNotify( hWnd, (XUnmapEvent *)event );
|
1999-04-01 14:03:52 +02:00
|
|
|
break;
|
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
case KeymapNotify:
|
|
|
|
X11DRV_KeymapNotify( hWnd, (XKeymapEvent *)event );
|
|
|
|
break;
|
|
|
|
|
2000-04-16 19:07:27 +02:00
|
|
|
case MappingNotify:
|
2001-10-17 19:50:02 +02:00
|
|
|
X11DRV_MappingNotify( (XMappingEvent *) event );
|
2000-04-16 19:07:27 +02:00
|
|
|
break;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
default:
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("Unprocessed event %s for hwnd %04x\n",
|
1999-04-15 17:22:23 +02:00
|
|
|
event_names[event->type], hWnd );
|
1998-12-07 10:13:40 +01:00
|
|
|
break;
|
|
|
|
}
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE( "returns.\n" );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* can_activate_window
|
|
|
|
*
|
|
|
|
* Check if we can activate the specified window.
|
|
|
|
*/
|
|
|
|
inline static BOOL can_activate_window( HWND hwnd )
|
|
|
|
{
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
if (!(style & WS_VISIBLE)) return FALSE;
|
|
|
|
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
|
|
|
|
return !(style & WS_DISABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
2002-09-19 01:09:50 +02:00
|
|
|
* set_focus_error_handler
|
|
|
|
*
|
|
|
|
* Handler for X errors happening during XSetInputFocus call.
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2002-09-19 01:09:50 +02:00
|
|
|
static int set_focus_error_handler( Display *display, XErrorEvent *event, void *arg )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-26 05:23:13 +02:00
|
|
|
return (event->error_code == BadMatch);
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* set_focus
|
|
|
|
*/
|
|
|
|
static void set_focus( HWND hwnd, Time time )
|
|
|
|
{
|
2002-10-12 01:41:06 +02:00
|
|
|
HWND focus;
|
2002-09-19 01:09:50 +02:00
|
|
|
Window win;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
TRACE( "setting foreground window to %x\n", hwnd );
|
|
|
|
SetForegroundWindow( hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
focus = GetFocus();
|
|
|
|
win = X11DRV_get_whole_window(focus);
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
TRACE( "setting focus to %x (%lx) time=%ld\n", focus, win, time );
|
|
|
|
X11DRV_expect_error( display, set_focus_error_handler, NULL );
|
|
|
|
XSetInputFocus( display, win, RevertToParent, time );
|
2002-09-26 05:23:13 +02:00
|
|
|
if (X11DRV_check_error()) TRACE("got BadMatch, ignoring\n" );
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-09-19 01:09:50 +02:00
|
|
|
* handle_wm_protocols_message
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2002-09-19 01:09:50 +02:00
|
|
|
static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
Atom protocol = (Atom)event->data.l[0];
|
|
|
|
|
|
|
|
if (!protocol) return;
|
1999-10-13 15:49:01 +02:00
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
if (protocol == wmDeleteWindow)
|
|
|
|
{
|
|
|
|
/* Ignore the delete window request if the window has been disabled
|
|
|
|
* and we are in managed mode. This is to disallow applications from
|
|
|
|
* being closed by the window manager while in a modal state.
|
|
|
|
*/
|
|
|
|
if (IsWindowEnabled(hwnd)) PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
|
|
|
}
|
|
|
|
else if (protocol == wmTakeFocus)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
Time event_time = (Time)event->data.l[1];
|
|
|
|
HWND last_focus = x11drv_thread_data()->last_focus;
|
|
|
|
|
|
|
|
TRACE( "got take focus msg for %x, enabled=%d, focus=%x, active=%x, fg=%x, last=%x\n",
|
|
|
|
hwnd, IsWindowEnabled(hwnd), GetFocus(), GetActiveWindow(),
|
|
|
|
GetForegroundWindow(), last_focus );
|
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (can_activate_window(hwnd))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
/* simulate a mouse click on the caption to find out
|
|
|
|
* whether the window wants to be activated */
|
|
|
|
LRESULT ma = SendMessageW( hwnd, WM_MOUSEACTIVATE,
|
|
|
|
GetAncestor( hwnd, GA_ROOT ),
|
|
|
|
MAKELONG(HTCAPTION,WM_LBUTTONDOWN) );
|
|
|
|
if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE) set_focus( hwnd, event_time );
|
|
|
|
else TRACE( "not setting focus to %x (%lx), ma=%ld\n", hwnd, event->window, ma );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2002-09-19 01:09:50 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hwnd = GetFocus();
|
|
|
|
if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
if (!hwnd) hwnd = last_focus;
|
2002-10-12 01:41:06 +02:00
|
|
|
if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, event_time );
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char * const focus_details[] =
|
|
|
|
{
|
|
|
|
"NotifyAncestor",
|
|
|
|
"NotifyVirtual",
|
|
|
|
"NotifyInferior",
|
|
|
|
"NotifyNonlinear",
|
|
|
|
"NotifyNonlinearVirtual",
|
|
|
|
"NotifyPointer",
|
|
|
|
"NotifyPointerRoot",
|
|
|
|
"NotifyDetailNone"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_FocusIn
|
|
|
|
*/
|
|
|
|
static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
|
|
|
|
{
|
|
|
|
if (!hwnd) return;
|
|
|
|
|
|
|
|
TRACE( "win %x xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );
|
|
|
|
|
|
|
|
if (wmTakeFocus) return; /* ignore FocusIn if we are using take focus */
|
|
|
|
if (event->detail == NotifyPointer) return;
|
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (!can_activate_window(hwnd))
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
HWND hwnd = GetFocus();
|
|
|
|
if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
if (!hwnd) hwnd = x11drv_thread_data()->last_focus;
|
2002-10-12 01:41:06 +02:00
|
|
|
if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, CurrentTime );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2002-10-12 01:41:06 +02:00
|
|
|
else SetForegroundWindow( hwnd );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
2002-09-19 01:09:50 +02:00
|
|
|
* EVENT_FocusOut
|
|
|
|
*
|
|
|
|
* Note: only top-level windows get FocusOut events.
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2002-09-19 01:09:50 +02:00
|
|
|
static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
HWND hwnd_tmp;
|
|
|
|
Window focus_win;
|
|
|
|
int revert;
|
|
|
|
|
|
|
|
TRACE( "win %x xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );
|
|
|
|
|
|
|
|
if (event->detail == NotifyPointer) return;
|
2002-10-12 01:41:06 +02:00
|
|
|
x11drv_thread_data()->last_focus = hwnd;
|
2002-09-19 01:09:50 +02:00
|
|
|
if (hwnd != GetForegroundWindow()) return;
|
|
|
|
SendMessageA( hwnd, WM_CANCELMODE, 0, 0 );
|
|
|
|
|
|
|
|
/* don't reset the foreground window, if the window which is
|
|
|
|
getting the focus is a Wine window */
|
|
|
|
|
2002-09-24 20:36:51 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XGetInputFocus( thread_display(), &focus_win, &revert );
|
|
|
|
if (focus_win)
|
|
|
|
{
|
|
|
|
if (XFindContext( thread_display(), focus_win, winContext, (char **)&hwnd_tmp ) != 0)
|
|
|
|
focus_win = 0;
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
if (!focus_win)
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
/* Abey : 6-Oct-99. Check again if the focus out window is the
|
|
|
|
Foreground window, because in most cases the messages sent
|
|
|
|
above must have already changed the foreground window, in which
|
|
|
|
case we don't have to change the foreground window to 0 */
|
|
|
|
if (hwnd == GetForegroundWindow())
|
|
|
|
{
|
|
|
|
TRACE( "lost focus, setting fg to 0\n" );
|
|
|
|
SetForegroundWindow( 0 );
|
|
|
|
}
|
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest_TARGETS
|
|
|
|
* Service a TARGETS selection request event
|
|
|
|
*/
|
2001-05-16 21:52:29 +02:00
|
|
|
static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
|
|
|
|
Atom target, Atom rprop )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
|
|
|
Atom xaTargets = TSXInternAtom(display, "TARGETS", False);
|
|
|
|
Atom* targets;
|
|
|
|
Atom prop;
|
|
|
|
UINT wFormat;
|
|
|
|
unsigned long cTargets;
|
|
|
|
BOOL bHavePixmap;
|
|
|
|
int xRc;
|
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Request for %s\n", TSXGetAtomName(display, target));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/*
|
|
|
|
* Count the number of items we wish to expose as selection targets.
|
|
|
|
* We include the TARGETS item, and a PIXMAP if we have CF_DIB or CF_BITMAP
|
|
|
|
*/
|
|
|
|
cTargets = CountClipboardFormats() + 1;
|
|
|
|
if ( CLIPBOARD_IsPresent(CF_DIB) || CLIPBOARD_IsPresent(CF_BITMAP) )
|
|
|
|
cTargets++;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Allocate temp buffer */
|
2000-04-29 16:20:28 +02:00
|
|
|
targets = (Atom*)HeapAlloc( GetProcessHeap(), 0, cTargets * sizeof(Atom));
|
|
|
|
if(targets == NULL) return None;
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/* Create TARGETS property list (First item in list is TARGETS itself) */
|
|
|
|
|
|
|
|
for ( targets[0] = xaTargets, cTargets = 1, wFormat = 0, bHavePixmap = FALSE;
|
|
|
|
(wFormat = EnumClipboardFormats( wFormat )); )
|
|
|
|
{
|
|
|
|
if ( (prop = X11DRV_CLIPBOARD_MapFormatToProperty(wFormat)) != None )
|
|
|
|
{
|
|
|
|
/* Scan through what we have so far to avoid duplicates */
|
|
|
|
int i;
|
|
|
|
BOOL bExists;
|
|
|
|
for (i = 0, bExists = FALSE; i < cTargets; i++)
|
|
|
|
{
|
|
|
|
if (targets[i] == prop)
|
|
|
|
{
|
|
|
|
bExists = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bExists)
|
|
|
|
{
|
|
|
|
targets[cTargets++] = prop;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Add PIXMAP prop for bitmaps additionally */
|
|
|
|
if ( (wFormat == CF_DIB || wFormat == CF_BITMAP )
|
|
|
|
&& !bHavePixmap )
|
|
|
|
{
|
|
|
|
targets[cTargets++] = XA_PIXMAP;
|
|
|
|
bHavePixmap = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-10 23:15:21 +01:00
|
|
|
if (TRACE_ON(event))
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2000-02-10 23:15:21 +01:00
|
|
|
int i;
|
|
|
|
for ( i = 0; i < cTargets; i++)
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2000-02-10 23:15:21 +01:00
|
|
|
if (targets[i])
|
|
|
|
{
|
|
|
|
char *itemFmtName = TSXGetAtomName(display, targets[i]);
|
|
|
|
TRACE("\tAtom# %d: Type %s\n", i, itemFmtName);
|
|
|
|
TSXFree(itemFmtName);
|
|
|
|
}
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Update the X property */
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("\tUpdating property %s...\n", TSXGetAtomName(display, rprop));
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/* We may want to consider setting the type to xaTargets instead,
|
|
|
|
* in case some apps expect this instead of XA_ATOM */
|
|
|
|
xRc = TSXChangeProperty(display, requestor, rprop,
|
|
|
|
XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char *)targets, cTargets);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("(Rc=%d)\n", xRc);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, targets );
|
|
|
|
|
|
|
|
return rprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest_STRING
|
|
|
|
* Service a STRING selection request event
|
|
|
|
*/
|
2001-05-16 21:52:29 +02:00
|
|
|
static Atom EVENT_SelectionRequest_STRING( Display *display, Window requestor,
|
|
|
|
Atom target, Atom rprop )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2000-12-11 02:09:56 +01:00
|
|
|
static UINT text_cp = (UINT)-1;
|
|
|
|
HANDLE hUnicodeText;
|
|
|
|
LPWSTR uni_text;
|
1999-09-20 17:42:47 +02:00
|
|
|
LPSTR text;
|
|
|
|
int size,i,j;
|
|
|
|
char* lpstr = 0;
|
|
|
|
char *itemFmtName;
|
|
|
|
int xRc;
|
|
|
|
|
2000-12-11 02:09:56 +01:00
|
|
|
if(text_cp == (UINT)-1)
|
2001-06-26 21:36:23 +02:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
/* default value */
|
|
|
|
text_cp = CP_ACP;
|
|
|
|
if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
DWORD type, count = sizeof(buf);
|
|
|
|
if(!RegQueryValueExA(hkey, "TextCP", 0, &type, buf, &count))
|
|
|
|
text_cp = atoi(buf);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
2000-12-11 02:09:56 +01:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/*
|
|
|
|
* Map the requested X selection property type atom name to a
|
|
|
|
* windows clipboard format ID.
|
|
|
|
*/
|
|
|
|
itemFmtName = TSXGetAtomName(display, target);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Request for %s (wFormat=%x %s)\n",
|
2002-08-27 21:19:49 +02:00
|
|
|
itemFmtName, CF_UNICODETEXT, CLIPBOARD_GetFormatName(CF_UNICODETEXT, NULL, 0));
|
1999-09-20 17:42:47 +02:00
|
|
|
TSXFree(itemFmtName);
|
|
|
|
|
2000-12-11 02:09:56 +01:00
|
|
|
hUnicodeText = GetClipboardData(CF_UNICODETEXT);
|
|
|
|
if(!hUnicodeText)
|
|
|
|
return None;
|
|
|
|
uni_text = GlobalLock(hUnicodeText);
|
|
|
|
if(!uni_text)
|
2000-03-04 20:18:47 +01:00
|
|
|
return None;
|
2000-12-11 02:09:56 +01:00
|
|
|
|
|
|
|
size = WideCharToMultiByte(text_cp, 0, uni_text, -1, NULL, 0, NULL, NULL);
|
|
|
|
text = HeapAlloc(GetProcessHeap(), 0, size);
|
2000-03-04 20:18:47 +01:00
|
|
|
if (!text)
|
|
|
|
return None;
|
2000-12-11 02:09:56 +01:00
|
|
|
WideCharToMultiByte(text_cp, 0, uni_text, -1, text, size, NULL, NULL);
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* remove carriage returns */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-04-29 16:20:28 +02:00
|
|
|
lpstr = (char*)HeapAlloc( GetProcessHeap(), 0, size-- );
|
|
|
|
if(lpstr == NULL) return None;
|
1999-09-20 17:42:47 +02:00
|
|
|
for(i=0,j=0; i < size && text[i]; i++ )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if( text[i] == '\r' &&
|
1999-09-20 17:42:47 +02:00
|
|
|
(text[i+1] == '\n' || text[i+1] == '\0') ) continue;
|
|
|
|
lpstr[j++] = text[i];
|
|
|
|
}
|
|
|
|
lpstr[j]='\0';
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Update the X property */
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tUpdating property %s...\n", TSXGetAtomName(display, rprop));
|
1999-09-20 17:42:47 +02:00
|
|
|
xRc = TSXChangeProperty(display, requestor, rprop,
|
|
|
|
XA_STRING, 8, PropModeReplace,
|
|
|
|
lpstr, j);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("(Rc=%d)\n", xRc);
|
1999-09-20 17:42:47 +02:00
|
|
|
|
2000-12-11 02:09:56 +01:00
|
|
|
GlobalUnlock(hUnicodeText);
|
|
|
|
HeapFree(GetProcessHeap(), 0, text);
|
1999-09-20 17:42:47 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, lpstr );
|
|
|
|
|
|
|
|
return rprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest_PIXMAP
|
|
|
|
* Service a PIXMAP selection request event
|
|
|
|
*/
|
2001-05-16 21:52:29 +02:00
|
|
|
static Atom EVENT_SelectionRequest_PIXMAP( Display *display, Window requestor,
|
|
|
|
Atom target, Atom rprop )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
|
|
|
HANDLE hClipData = 0;
|
1999-11-28 21:31:04 +01:00
|
|
|
Pixmap pixmap = 0;
|
1999-09-20 17:42:47 +02:00
|
|
|
UINT wFormat;
|
|
|
|
char * itemFmtName;
|
|
|
|
int xRc;
|
|
|
|
#if(0)
|
|
|
|
XSetWindowAttributes win_attr;
|
|
|
|
XWindowAttributes win_attr_src;
|
|
|
|
#endif
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/*
|
|
|
|
* Map the requested X selection property type atom name to a
|
|
|
|
* windows clipboard format ID.
|
|
|
|
*/
|
|
|
|
itemFmtName = TSXGetAtomName(display, target);
|
|
|
|
wFormat = X11DRV_CLIPBOARD_MapPropertyToFormat(itemFmtName);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Request for %s (wFormat=%x %s)\n",
|
2002-08-27 21:19:49 +02:00
|
|
|
itemFmtName, wFormat, CLIPBOARD_GetFormatName( wFormat, NULL, 0 ));
|
1999-09-20 17:42:47 +02:00
|
|
|
TSXFree(itemFmtName);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
hClipData = GetClipboardData(wFormat);
|
|
|
|
if ( !hClipData )
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Could not retrieve a Pixmap compatible format from clipboard!\n");
|
1999-09-20 17:42:47 +02:00
|
|
|
rprop = None; /* Fail the request */
|
|
|
|
goto END;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wFormat == CF_DIB)
|
|
|
|
{
|
|
|
|
HWND hwnd = GetOpenClipboardWindow();
|
|
|
|
HDC hdc = GetDC(hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* For convert from packed DIB to Pixmap */
|
|
|
|
pixmap = X11DRV_DIB_CreatePixmapFromDIB(hClipData, hdc);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-19 22:34:17 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
else if (wFormat == CF_BITMAP)
|
|
|
|
{
|
|
|
|
HWND hwnd = GetOpenClipboardWindow();
|
|
|
|
HDC hdc = GetDC(hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
pixmap = X11DRV_BITMAP_CreatePixmapFromBitmap(hClipData, hdc);
|
|
|
|
|
2001-09-19 22:34:17 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
FIXME("%s to PIXMAP conversion not yet implemented!\n",
|
2002-08-27 21:19:49 +02:00
|
|
|
CLIPBOARD_GetFormatName(wFormat, NULL, 0));
|
1999-09-20 17:42:47 +02:00
|
|
|
rprop = None;
|
|
|
|
goto END;
|
|
|
|
}
|
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tUpdating property %s on Window %ld with %s %ld...\n",
|
|
|
|
TSXGetAtomName(display, rprop), (long)requestor,
|
|
|
|
TSXGetAtomName(display, target), pixmap);
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/* Store the Pixmap handle in the property */
|
2002-06-01 01:06:46 +02:00
|
|
|
xRc = TSXChangeProperty(display, requestor, rprop, target,
|
1999-09-20 17:42:47 +02:00
|
|
|
32, PropModeReplace,
|
|
|
|
(unsigned char *)&pixmap, 1);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("(Rc=%d)\n", xRc);
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/* Enable the code below if you want to handle destroying Pixmap resources
|
|
|
|
* in response to property notify events. Clients like XPaint don't
|
|
|
|
* appear to be duplicating Pixmaps so they don't like us deleting,
|
|
|
|
* the resource in response to the property being deleted.
|
|
|
|
*/
|
|
|
|
#if(0)
|
|
|
|
/* Express interest in property notify events so that we can delete the
|
|
|
|
* pixmap when the client deletes the property atom.
|
|
|
|
*/
|
|
|
|
xRc = TSXGetWindowAttributes(display, requestor, &win_attr_src);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Turning on PropertyChangeEvent notifications from window %ld\n",
|
|
|
|
(long)requestor);
|
1999-09-20 17:42:47 +02:00
|
|
|
win_attr.event_mask = win_attr_src.your_event_mask | PropertyChangeMask;
|
|
|
|
TSXChangeWindowAttributes(display, requestor, CWEventMask, &win_attr);
|
|
|
|
|
|
|
|
/* Register the Pixmap we created with the request property Atom.
|
|
|
|
* When this property is destroyed we also destroy the Pixmap in
|
|
|
|
* response to the PropertyNotify event.
|
|
|
|
*/
|
|
|
|
X11DRV_CLIPBOARD_RegisterPixmapResource( rprop, pixmap );
|
|
|
|
#endif
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
END:
|
|
|
|
return rprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest_WCF
|
|
|
|
* Service a Wine Clipboard Format selection request event.
|
|
|
|
* For <WCF>* data types we simply copy the data to X without conversion.
|
|
|
|
*/
|
2001-05-16 21:52:29 +02:00
|
|
|
static Atom EVENT_SelectionRequest_WCF( Display *display, Window requestor,
|
|
|
|
Atom target, Atom rprop )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
|
|
|
HANDLE hClipData = 0;
|
|
|
|
void* lpClipData;
|
|
|
|
UINT wFormat;
|
|
|
|
char * itemFmtName;
|
|
|
|
int cBytes;
|
|
|
|
int xRc;
|
2002-08-27 21:19:49 +02:00
|
|
|
int bemf;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/*
|
|
|
|
* Map the requested X selection property type atom name to a
|
|
|
|
* windows clipboard format ID.
|
|
|
|
*/
|
|
|
|
itemFmtName = TSXGetAtomName(display, target);
|
|
|
|
wFormat = X11DRV_CLIPBOARD_MapPropertyToFormat(itemFmtName);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Request for %s (wFormat=%x %s)\n",
|
2002-08-27 21:19:49 +02:00
|
|
|
itemFmtName, wFormat, CLIPBOARD_GetFormatName( wFormat, NULL, 0));
|
1999-09-20 17:42:47 +02:00
|
|
|
TSXFree(itemFmtName);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-25 22:08:44 +02:00
|
|
|
hClipData = GetClipboardData(wFormat);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-08-27 21:19:49 +02:00
|
|
|
bemf = wFormat == CF_METAFILEPICT || wFormat == CF_ENHMETAFILE;
|
|
|
|
if (bemf)
|
|
|
|
hClipData = X11DRV_CLIPBOARD_SerializeMetafile(wFormat, hClipData, sizeof(hClipData), TRUE);
|
|
|
|
|
2001-06-25 22:08:44 +02:00
|
|
|
if( hClipData && (lpClipData = GlobalLock(hClipData)) )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2001-06-25 22:08:44 +02:00
|
|
|
cBytes = GlobalSize(hClipData);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tUpdating property %s, %d bytes...\n",
|
|
|
|
TSXGetAtomName(display, rprop), cBytes);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
xRc = TSXChangeProperty(display, requestor, rprop,
|
|
|
|
target, 8, PropModeReplace,
|
|
|
|
(unsigned char *)lpClipData, cBytes);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("(Rc=%d)\n", xRc);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-25 22:08:44 +02:00
|
|
|
GlobalUnlock(hClipData);
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tCould not retrieve native format!\n");
|
1999-09-20 17:42:47 +02:00
|
|
|
rprop = None; /* Fail the request */
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-08-27 21:19:49 +02:00
|
|
|
if (bemf) /* We must free serialized metafile data */
|
|
|
|
GlobalFree(hClipData);
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
return rprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest_MULTIPLE
|
|
|
|
* Service a MULTIPLE selection request event
|
|
|
|
* rprop contains a list of (target,property) atom pairs.
|
|
|
|
* The first atom names a target and the second names a property.
|
|
|
|
* The effect is as if we have received a sequence of SelectionRequest events
|
|
|
|
* (one for each atom pair) except that:
|
|
|
|
* 1. We reply with a SelectionNotify only when all the requested conversions
|
|
|
|
* have been performed.
|
|
|
|
* 2. If we fail to convert the target named by an atom in the MULTIPLE property,
|
|
|
|
* we replace the atom in the property by None.
|
|
|
|
*/
|
|
|
|
static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *pevent )
|
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = pevent->display;
|
1999-09-20 17:42:47 +02:00
|
|
|
Atom rprop;
|
|
|
|
Atom atype=AnyPropertyType;
|
|
|
|
int aformat;
|
|
|
|
unsigned long remain;
|
|
|
|
Atom* targetPropList=NULL;
|
|
|
|
unsigned long cTargetPropList = 0;
|
|
|
|
/* Atom xAtomPair = TSXInternAtom(display, "ATOM_PAIR", False); */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* If the specified property is None the requestor is an obsolete client.
|
|
|
|
* We support these by using the specified target atom as the reply property.
|
|
|
|
*/
|
|
|
|
rprop = pevent->property;
|
2002-06-01 01:06:46 +02:00
|
|
|
if( rprop == None )
|
1999-09-20 17:42:47 +02:00
|
|
|
rprop = pevent->target;
|
|
|
|
if (!rprop)
|
|
|
|
goto END;
|
|
|
|
|
|
|
|
/* Read the MULTIPLE property contents. This should contain a list of
|
|
|
|
* (target,property) atom pairs.
|
|
|
|
*/
|
|
|
|
if(TSXGetWindowProperty(display, pevent->requestor, rprop,
|
1999-12-08 04:56:23 +01:00
|
|
|
0, 0x3FFF, False, AnyPropertyType, &atype,&aformat,
|
|
|
|
&cTargetPropList, &remain,
|
|
|
|
(unsigned char**)&targetPropList) != Success)
|
|
|
|
TRACE("\tCouldn't read MULTIPLE property\n");
|
1999-09-20 17:42:47 +02:00
|
|
|
else
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tType %s,Format %d,nItems %ld, Remain %ld\n",
|
|
|
|
TSXGetAtomName(display, atype), aformat, cTargetPropList, remain);
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we got what we expect.
|
|
|
|
* NOTE: According to the X-ICCCM Version 2.0 documentation the property sent
|
|
|
|
* in a MULTIPLE selection request should be of type ATOM_PAIR.
|
|
|
|
* However some X apps(such as XPaint) are not compliant with this and return
|
|
|
|
* a user defined atom in atype when XGetWindowProperty is called.
|
|
|
|
* The data *is* an atom pair but is not denoted as such.
|
|
|
|
*/
|
|
|
|
if(aformat == 32 /* atype == xAtomPair */ )
|
|
|
|
{
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Iterate through the ATOM_PAIR list and execute a SelectionRequest
|
|
|
|
* for each (target,property) pair */
|
|
|
|
|
|
|
|
for (i = 0; i < cTargetPropList; i+=2)
|
|
|
|
{
|
|
|
|
char *targetName = TSXGetAtomName(display, targetPropList[i]);
|
|
|
|
char *propName = TSXGetAtomName(display, targetPropList[i+1]);
|
|
|
|
XSelectionRequestEvent event;
|
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
|
|
|
|
i/2, targetName, propName);
|
1999-09-20 17:42:47 +02:00
|
|
|
TSXFree(targetName);
|
|
|
|
TSXFree(propName);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* We must have a non "None" property to service a MULTIPLE target atom */
|
|
|
|
if ( !targetPropList[i+1] )
|
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("\tMULTIPLE(%d): Skipping target with empty property!\n", i);
|
1999-09-20 17:42:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Set up an XSelectionRequestEvent for this (target,property) pair */
|
|
|
|
memcpy( &event, pevent, sizeof(XSelectionRequestEvent) );
|
|
|
|
event.target = targetPropList[i];
|
|
|
|
event.property = targetPropList[i+1];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Fire a SelectionRequest, informing the handler that we are processing
|
|
|
|
* a MULTIPLE selection request event.
|
|
|
|
*/
|
|
|
|
EVENT_SelectionRequest( hWnd, &event, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the list of targets/properties */
|
|
|
|
TSXFree(targetPropList);
|
|
|
|
}
|
|
|
|
|
|
|
|
END:
|
|
|
|
return rprop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionRequest
|
1999-09-20 17:42:47 +02:00
|
|
|
* Process an event selection request event.
|
|
|
|
* The bIsMultiple flag is used to signal when EVENT_SelectionRequest is called
|
|
|
|
* recursively while servicing a "MULTIPLE" selection target.
|
|
|
|
*
|
1999-09-03 17:17:57 +02:00
|
|
|
* Note: We only receive this event when WINE owns the X selection
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
1999-09-20 17:42:47 +02:00
|
|
|
static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BOOL bIsMultiple )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = event->display;
|
1998-12-07 10:13:40 +01:00
|
|
|
XSelectionEvent result;
|
1999-09-03 17:17:57 +02:00
|
|
|
Atom rprop = None;
|
|
|
|
Window request = event->requestor;
|
|
|
|
BOOL couldOpen = FALSE;
|
1999-09-20 17:42:47 +02:00
|
|
|
Atom xaClipboard = TSXInternAtom(display, "CLIPBOARD", False);
|
|
|
|
Atom xaTargets = TSXInternAtom(display, "TARGETS", False);
|
|
|
|
Atom xaMultiple = TSXInternAtom(display, "MULTIPLE", False);
|
1998-12-07 10:13:40 +01:00
|
|
|
|
1999-09-03 17:17:57 +02:00
|
|
|
/*
|
1999-09-20 17:42:47 +02:00
|
|
|
* We can only handle the selection request if :
|
|
|
|
* The selection is PRIMARY or CLIPBOARD, AND we can successfully open the clipboard.
|
|
|
|
* Don't do these checks or open the clipboard while recursively processing MULTIPLE,
|
|
|
|
* since this has been already done.
|
1999-09-03 17:17:57 +02:00
|
|
|
*/
|
1999-09-20 17:42:47 +02:00
|
|
|
if ( !bIsMultiple )
|
|
|
|
{
|
|
|
|
if ( ( (event->selection != XA_PRIMARY) && (event->selection != xaClipboard) )
|
|
|
|
|| !(couldOpen = OpenClipboard(hWnd)) )
|
|
|
|
goto END;
|
|
|
|
}
|
1999-09-03 17:17:57 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* If the specified property is None the requestor is an obsolete client.
|
|
|
|
* We support these by using the specified target atom as the reply property.
|
1999-09-03 17:17:57 +02:00
|
|
|
*/
|
|
|
|
rprop = event->property;
|
2002-06-01 01:06:46 +02:00
|
|
|
if( rprop == None )
|
1999-09-03 17:17:57 +02:00
|
|
|
rprop = event->target;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-03 17:17:57 +02:00
|
|
|
if(event->target == xaTargets) /* Return a list of all supported targets */
|
|
|
|
{
|
1999-09-20 17:42:47 +02:00
|
|
|
/* TARGETS selection request */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_TARGETS( display, request, event->target, rprop );
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
else if(event->target == xaMultiple) /* rprop contains a list of (target, property) atom pairs */
|
|
|
|
{
|
|
|
|
/* MULTIPLE selection request */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event );
|
1999-09-03 17:17:57 +02:00
|
|
|
}
|
|
|
|
else if(event->target == XA_STRING) /* treat CF_TEXT as Unix text */
|
1999-04-01 14:03:52 +02:00
|
|
|
{
|
1999-09-20 17:42:47 +02:00
|
|
|
/* XA_STRING selection request */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_STRING( display, request, event->target, rprop );
|
1999-09-03 17:17:57 +02:00
|
|
|
}
|
|
|
|
else if(event->target == XA_PIXMAP) /* Convert DIB's to Pixmaps */
|
|
|
|
{
|
1999-09-20 17:42:47 +02:00
|
|
|
/* XA_PIXMAP selection request */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_PIXMAP( display, request, event->target, rprop );
|
1999-09-03 17:17:57 +02:00
|
|
|
}
|
1999-09-20 17:42:47 +02:00
|
|
|
else if(event->target == XA_BITMAP) /* Convert DIB's to 1-bit Pixmaps */
|
1999-09-03 17:17:57 +02:00
|
|
|
{
|
1999-09-20 17:42:47 +02:00
|
|
|
/* XA_BITMAP selection request - TODO: create a monochrome Pixmap */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_PIXMAP( display, request, XA_PIXMAP, rprop );
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
|
|
|
else if(X11DRV_CLIPBOARD_IsNativeProperty(event->target)) /* <WCF>* */
|
|
|
|
{
|
|
|
|
/* All <WCF> selection requests */
|
2001-05-16 21:52:29 +02:00
|
|
|
rprop = EVENT_SelectionRequest_WCF( display, request, event->target, rprop );
|
1999-04-01 14:03:52 +02:00
|
|
|
}
|
1999-09-20 17:42:47 +02:00
|
|
|
else
|
|
|
|
rprop = None; /* Don't support this format */
|
1999-09-03 17:17:57 +02:00
|
|
|
|
|
|
|
END:
|
|
|
|
/* close clipboard only if we opened before */
|
|
|
|
if(couldOpen) CloseClipboard();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if( rprop == None)
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tRequest ignored\n");
|
1999-04-01 14:03:52 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* reply to sender
|
1999-09-20 17:42:47 +02:00
|
|
|
* SelectionNotify should be sent only at the end of a MULTIPLE request
|
|
|
|
*/
|
|
|
|
if ( !bIsMultiple )
|
|
|
|
{
|
|
|
|
result.type = SelectionNotify;
|
|
|
|
result.display = display;
|
|
|
|
result.requestor = request;
|
|
|
|
result.selection = event->selection;
|
|
|
|
result.property = rprop;
|
|
|
|
result.target = event->target;
|
|
|
|
result.time = event->time;
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Sending SelectionNotify event...\n");
|
1999-09-20 17:42:47 +02:00
|
|
|
TSXSendEvent(display,event->requestor,False,NoEventMask,(XEvent*)&result);
|
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_SelectionClear
|
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_SelectionClear( HWND hWnd, XSelectionClearEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Atom xaClipboard = TSXInternAtom(event->display, "CLIPBOARD", False);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-03 17:17:57 +02:00
|
|
|
if (event->selection == XA_PRIMARY || event->selection == xaClipboard)
|
|
|
|
X11DRV_CLIPBOARD_ReleaseSelection( event->selection, event->window, hWnd );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_PropertyNotify
|
|
|
|
* We use this to release resources like Pixmaps when a selection
|
|
|
|
* client no longer needs them.
|
|
|
|
*/
|
|
|
|
static void EVENT_PropertyNotify( XPropertyEvent *event )
|
|
|
|
{
|
|
|
|
/* Check if we have any resources to free */
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("Received PropertyNotify event: \n");
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
switch(event->state)
|
|
|
|
{
|
|
|
|
case PropertyDelete:
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tPropertyDelete for atom %s on window %ld\n",
|
|
|
|
TSXGetAtomName(event->display, event->atom), (long)event->window);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-10 03:16:19 +02:00
|
|
|
if (X11DRV_IsSelectionOwner())
|
1999-09-20 17:42:47 +02:00
|
|
|
X11DRV_CLIPBOARD_FreeResources( event->atom );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PropertyNewValue:
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("\tPropertyNewValue for atom %s on window %ld\n\n",
|
|
|
|
TSXGetAtomName(event->display, event->atom), (long)event->window);
|
1999-09-20 17:42:47 +02:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2002-09-23 22:56:37 +02:00
|
|
|
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
|
|
|
|
{
|
|
|
|
RECT tempRect;
|
|
|
|
|
|
|
|
if (!IsWindowEnabled(hQueryWnd)) return 0;
|
|
|
|
|
|
|
|
GetWindowRect(hQueryWnd, &tempRect);
|
|
|
|
|
|
|
|
if(!PtInRect(&tempRect, *lpPt)) return 0;
|
|
|
|
|
|
|
|
if (!IsIconic( hQueryWnd ))
|
|
|
|
{
|
|
|
|
GetClientRect( hQueryWnd, &tempRect );
|
|
|
|
MapWindowPoints( hQueryWnd, 0, (LPPOINT)&tempRect, 2 );
|
|
|
|
|
|
|
|
if (PtInRect( &tempRect, *lpPt))
|
|
|
|
{
|
|
|
|
HWND *list = WIN_ListChildren( hQueryWnd );
|
|
|
|
HWND bResult = 0;
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; list[i]; i++)
|
|
|
|
{
|
|
|
|
if (GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)
|
|
|
|
{
|
|
|
|
GetWindowRect( list[i], &tempRect );
|
|
|
|
if (PtInRect( &tempRect, *lpPt )) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list[i])
|
|
|
|
{
|
|
|
|
if (IsWindowEnabled( list[i] ))
|
|
|
|
bResult = find_drop_window( list[i], lpPt );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
|
|
|
}
|
|
|
|
if(bResult) return bResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(GetWindowLongA( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return 0;
|
|
|
|
|
|
|
|
ScreenToClient(hQueryWnd, lpPt);
|
|
|
|
|
|
|
|
return hQueryWnd;
|
|
|
|
}
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_DropFromOffix
|
|
|
|
*
|
|
|
|
* don't know if it still works (last Changlog is from 96/11/04)
|
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-23 22:56:37 +02:00
|
|
|
unsigned long data_length;
|
|
|
|
unsigned long aux_long;
|
|
|
|
unsigned char* p_data = NULL;
|
|
|
|
union {
|
|
|
|
Atom atom_aux;
|
|
|
|
struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} pt_aux;
|
|
|
|
int i;
|
|
|
|
} u;
|
|
|
|
int x, y;
|
|
|
|
BOOL bAccept;
|
|
|
|
Window w_aux_root, w_aux_child;
|
|
|
|
WND* pWnd;
|
|
|
|
HWND hScope = hWnd;
|
|
|
|
|
|
|
|
pWnd = WIN_FindWndPtr(hWnd);
|
|
|
|
|
|
|
|
TSXQueryPointer( event->display, get_whole_window(pWnd), &w_aux_root, &w_aux_child,
|
|
|
|
&x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
|
|
|
|
(unsigned int*)&aux_long);
|
|
|
|
|
|
|
|
/* find out drop point and drop window */
|
|
|
|
if( x < 0 || y < 0 ||
|
|
|
|
x > (pWnd->rectWindow.right - pWnd->rectWindow.left) ||
|
|
|
|
y > (pWnd->rectWindow.bottom - pWnd->rectWindow.top) )
|
|
|
|
{
|
|
|
|
bAccept = pWnd->dwExStyle & WS_EX_ACCEPTFILES;
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
else
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-23 22:56:37 +02:00
|
|
|
POINT pt = { x, y };
|
|
|
|
HWND hwndDrop = find_drop_window( hWnd, &pt );
|
|
|
|
if (hwndDrop)
|
|
|
|
{
|
|
|
|
x = pt.x;
|
|
|
|
y = pt.y;
|
|
|
|
hScope = hwndDrop;
|
|
|
|
bAccept = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bAccept = FALSE;
|
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2002-09-23 22:56:37 +02:00
|
|
|
WIN_ReleaseWndPtr(pWnd);
|
2001-10-16 23:58:58 +02:00
|
|
|
|
|
|
|
if (!bAccept) return;
|
|
|
|
|
|
|
|
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
|
|
|
dndSelection, 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y,
|
|
|
|
&data_length, &aux_long, &p_data);
|
|
|
|
|
|
|
|
if( !aux_long && p_data) /* don't bother if > 64K */
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2001-10-16 23:58:58 +02:00
|
|
|
signed char *p = (signed char*) p_data;
|
|
|
|
char *p_drop;
|
1999-03-14 18:25:32 +01:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
aux_long = 0;
|
|
|
|
while( *p ) /* calculate buffer size */
|
|
|
|
{
|
|
|
|
p_drop = p;
|
|
|
|
if((u.i = *p) != -1 )
|
|
|
|
{
|
|
|
|
INT len = GetShortPathNameA( p, NULL, 0 );
|
|
|
|
if (len) aux_long += len + 1;
|
|
|
|
else *p = -1;
|
|
|
|
}
|
|
|
|
p += strlen(p) + 1;
|
|
|
|
}
|
|
|
|
if( aux_long && aux_long < 65535 )
|
|
|
|
{
|
|
|
|
HDROP hDrop;
|
|
|
|
DROPFILES *lpDrop;
|
|
|
|
|
|
|
|
aux_long += sizeof(DROPFILES) + 1;
|
|
|
|
hDrop = GlobalAlloc( GMEM_SHARE, aux_long );
|
|
|
|
lpDrop = (DROPFILES*)GlobalLock( hDrop );
|
|
|
|
|
|
|
|
if( lpDrop )
|
|
|
|
{
|
2002-09-23 22:56:37 +02:00
|
|
|
WND *pDropWnd = WIN_FindWndPtr( hScope );
|
2001-10-16 23:58:58 +02:00
|
|
|
lpDrop->pFiles = sizeof(DROPFILES);
|
|
|
|
lpDrop->pt.x = x;
|
|
|
|
lpDrop->pt.y = y;
|
|
|
|
lpDrop->fNC =
|
|
|
|
( x < (pDropWnd->rectClient.left - pDropWnd->rectWindow.left) ||
|
|
|
|
y < (pDropWnd->rectClient.top - pDropWnd->rectWindow.top) ||
|
|
|
|
x > (pDropWnd->rectClient.right - pDropWnd->rectWindow.left) ||
|
|
|
|
y > (pDropWnd->rectClient.bottom - pDropWnd->rectWindow.top) );
|
|
|
|
lpDrop->fWide = FALSE;
|
|
|
|
WIN_ReleaseWndPtr(pDropWnd);
|
|
|
|
p_drop = (char *)(lpDrop + 1);
|
|
|
|
p = p_data;
|
|
|
|
while(*p)
|
|
|
|
{
|
|
|
|
if( *p != -1 ) /* use only "good" entries */
|
|
|
|
{
|
|
|
|
GetShortPathNameA( p, p_drop, 65535 );
|
|
|
|
p_drop += strlen( p_drop ) + 1;
|
|
|
|
}
|
|
|
|
p += strlen(p) + 1;
|
|
|
|
}
|
|
|
|
*p_drop = '\0';
|
|
|
|
PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( p_data ) TSXFree(p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_DropURLs
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* drop items are separated by \n
|
1998-12-07 10:13:40 +01:00
|
|
|
* each item is prefixed by its mime type
|
|
|
|
*
|
|
|
|
* event->data.l[3], event->data.l[4] contains drop x,y position
|
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
|
|
|
unsigned long data_length;
|
|
|
|
unsigned long aux_long, drop_len = 0;
|
|
|
|
unsigned char *p_data = NULL; /* property data */
|
|
|
|
char *p_drop = NULL;
|
|
|
|
char *p, *next;
|
2000-09-26 01:56:41 +02:00
|
|
|
int x, y;
|
|
|
|
DROPFILES *lpDrop;
|
|
|
|
HDROP hDrop;
|
1998-12-07 10:13:40 +01:00
|
|
|
union {
|
|
|
|
Atom atom_aux;
|
|
|
|
int i;
|
|
|
|
Window w_aux;
|
|
|
|
} u; /* unused */
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
1998-12-07 10:13:40 +01:00
|
|
|
dndSelection, 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom_aux, &u.i,
|
|
|
|
&data_length, &aux_long, &p_data);
|
|
|
|
if (aux_long)
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("property too large, truncated!\n");
|
|
|
|
TRACE("urls=%s\n", p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
|
|
|
|
if( !aux_long && p_data) { /* don't bother if > 64K */
|
|
|
|
/* calculate length */
|
|
|
|
p = p_data;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
while (p) {
|
|
|
|
if (next) *next=0;
|
|
|
|
if (strncmp(p,"file:",5) == 0 ) {
|
1999-02-26 12:11:13 +01:00
|
|
|
INT len = GetShortPathNameA( p+5, NULL, 0 );
|
1998-12-07 10:13:40 +01:00
|
|
|
if (len) drop_len += len + 1;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (next) {
|
|
|
|
*next = '\n';
|
1998-12-07 10:13:40 +01:00
|
|
|
p = next + 1;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
} else {
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
if( drop_len && drop_len < 65535 ) {
|
2001-05-16 21:52:29 +02:00
|
|
|
TSXQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux,
|
1998-12-07 10:13:40 +01:00
|
|
|
&x, &y, &u.i, &u.i, &u.i);
|
1999-04-15 17:22:23 +02:00
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
drop_len += sizeof(DROPFILES) + 1;
|
2001-01-02 22:00:46 +01:00
|
|
|
hDrop = GlobalAlloc( GMEM_SHARE, drop_len );
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop = (DROPFILES *) GlobalLock( hDrop );
|
|
|
|
|
|
|
|
if( lpDrop ) {
|
2001-10-16 23:58:58 +02:00
|
|
|
WND *pDropWnd = WIN_FindWndPtr( hWnd );
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop->pFiles = sizeof(DROPFILES);
|
|
|
|
lpDrop->pt.x = (INT)x;
|
|
|
|
lpDrop->pt.y = (INT)y;
|
|
|
|
lpDrop->fNC =
|
1998-12-07 10:13:40 +01:00
|
|
|
( x < (pDropWnd->rectClient.left - pDropWnd->rectWindow.left) ||
|
|
|
|
y < (pDropWnd->rectClient.top - pDropWnd->rectWindow.top) ||
|
|
|
|
x > (pDropWnd->rectClient.right - pDropWnd->rectWindow.left) ||
|
|
|
|
y > (pDropWnd->rectClient.bottom - pDropWnd->rectWindow.top) );
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop->fWide = FALSE;
|
|
|
|
p_drop = (char*)(lpDrop + 1);
|
2001-10-16 23:58:58 +02:00
|
|
|
WIN_ReleaseWndPtr(pDropWnd);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2000-09-26 01:56:41 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/* create message content */
|
|
|
|
if (p_drop) {
|
|
|
|
p = p_data;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
while (p) {
|
|
|
|
if (next) *next=0;
|
|
|
|
if (strncmp(p,"file:",5) == 0 ) {
|
1999-02-26 12:11:13 +01:00
|
|
|
INT len = GetShortPathNameA( p+5, p_drop, 65535 );
|
1998-12-07 10:13:40 +01:00
|
|
|
if (len) {
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("drop file %s as %s\n", p+5, p_drop);
|
1998-12-07 10:13:40 +01:00
|
|
|
p_drop += len+1;
|
|
|
|
} else {
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("can't convert file %s to dos name \n", p+5);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
} else {
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("unknown mime type %s\n", p);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (next) {
|
|
|
|
*next = '\n';
|
1998-12-07 10:13:40 +01:00
|
|
|
p = next + 1;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
} else {
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
*p_drop = '\0';
|
|
|
|
}
|
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
GlobalUnlock(hDrop);
|
2001-01-02 22:00:46 +01:00
|
|
|
PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if( p_data ) TSXFree(p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_ClientMessage
|
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
|
|
|
if (event->message_type != None && event->format == 32) {
|
2002-09-19 01:09:50 +02:00
|
|
|
if (event->message_type == wmProtocols)
|
|
|
|
handle_wm_protocols_message( hWnd, event );
|
2001-06-04 23:55:17 +02:00
|
|
|
else if (event->message_type == dndProtocol)
|
|
|
|
{
|
|
|
|
/* query window (drag&drop event contains only drag window) */
|
|
|
|
Window root, child;
|
|
|
|
int root_x, root_y, child_x, child_y;
|
|
|
|
unsigned int u;
|
2002-09-24 20:36:51 +02:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XQueryPointer( event->display, root_window, &root, &child,
|
|
|
|
&root_x, &root_y, &child_x, &child_y, &u);
|
|
|
|
if (XFindContext( event->display, child, winContext, (char **)&hWnd ) != 0) hWnd = 0;
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
if (!hWnd) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (event->data.l[0] == DndFile || event->data.l[0] == DndFiles)
|
|
|
|
EVENT_DropFromOffiX(hWnd, event);
|
|
|
|
else if (event->data.l[0] == DndURL)
|
|
|
|
EVENT_DropURLs(hWnd, event);
|
1999-04-18 11:21:01 +02:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
else {
|
|
|
|
#if 0
|
|
|
|
/* enable this if you want to see the message */
|
|
|
|
unsigned char* p_data = NULL;
|
|
|
|
union {
|
|
|
|
unsigned long l;
|
|
|
|
int i;
|
|
|
|
Atom atom;
|
|
|
|
} u; /* unused */
|
2001-05-16 21:52:29 +02:00
|
|
|
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
1998-12-07 10:13:40 +01:00
|
|
|
dndSelection, 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom, &u.i,
|
|
|
|
&u.l, &u.l, &p_data);
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("message_type=%ld, data=%ld,%ld,%ld,%ld,%ld, msg=%s\n",
|
2002-06-01 01:06:46 +02:00
|
|
|
event->message_type, event->data.l[0], event->data.l[1],
|
1998-12-07 10:13:40 +01:00
|
|
|
event->data.l[2], event->data.l[3], event->data.l[4],
|
|
|
|
p_data);
|
|
|
|
#endif
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("unrecognized ClientMessage\n" );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-01 14:03:52 +02:00
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
/**********************************************************************
|
2000-04-14 16:09:50 +02:00
|
|
|
* X11DRV_EVENT_SetInputMethod
|
1999-11-07 22:25:57 +01:00
|
|
|
*/
|
2000-04-14 16:09:50 +02:00
|
|
|
INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type)
|
1999-11-07 22:25:57 +01:00
|
|
|
{
|
|
|
|
INPUT_TYPE prev = current_input_type;
|
|
|
|
|
|
|
|
/* Flag not used yet */
|
|
|
|
in_transition = FALSE;
|
|
|
|
current_input_type = type;
|
|
|
|
|
|
|
|
return prev;
|
|
|
|
}
|
1999-04-01 14:03:52 +02:00
|
|
|
|
1999-12-12 20:42:47 +01:00
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_EVENT_SetDGAStatus
|
|
|
|
*/
|
|
|
|
void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base)
|
|
|
|
{
|
|
|
|
if (event_base < 0) {
|
|
|
|
DGAUsed = FALSE;
|
|
|
|
DGAhwnd = 0;
|
|
|
|
} else {
|
|
|
|
DGAUsed = TRUE;
|
|
|
|
DGAhwnd = hwnd;
|
|
|
|
DGAMotionEventType = event_base + MotionNotify;
|
|
|
|
DGAButtonPressEventType = event_base + ButtonPress;
|
|
|
|
DGAButtonReleaseEventType = event_base + ButtonRelease;
|
|
|
|
DGAKeyPressEventType = event_base + KeyPress;
|
|
|
|
DGAKeyReleaseEventType = event_base + KeyRelease;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|