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
|
|
|
*/
|
|
|
|
|
2003-01-03 20:12:55 +01:00
|
|
|
#define COM_NO_WINDOWS_H
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/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>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1998-12-07 10:13:40 +01:00
|
|
|
#include <string.h>
|
2000-09-16 22:58:06 +02:00
|
|
|
#include "wine/winuser16.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
2000-09-26 01:56:41 +02:00
|
|
|
#include "shlobj.h" /* DROPFILES */
|
2000-09-16 22:58:06 +02:00
|
|
|
|
2000-03-08 19:26:56 +01:00
|
|
|
#include "win.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"
|
2002-12-04 00:34:52 +01:00
|
|
|
#include "wine/debug.h"
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(event);
|
2003-06-24 01:02:02 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(clipboard);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-21 03:22:26 +01:00
|
|
|
extern BOOL ximInComposeMode;
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#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 */
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/* Event handlers */
|
|
|
|
static void EVENT_FocusIn( HWND hwnd, XEvent *event );
|
|
|
|
static void EVENT_FocusOut( HWND hwnd, XEvent *event );
|
|
|
|
static void EVENT_PropertyNotify( HWND hwnd, XEvent *event );
|
|
|
|
static void EVENT_ClientMessage( HWND hwnd, XEvent *event );
|
|
|
|
|
|
|
|
struct event_handler
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
int type; /* event type */
|
|
|
|
x11drv_event_handler handler; /* corresponding handler function */
|
1998-12-07 10:13:40 +01:00
|
|
|
};
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
#define MAX_EVENT_HANDLERS 64
|
|
|
|
|
|
|
|
static struct event_handler handlers[MAX_EVENT_HANDLERS] =
|
|
|
|
{
|
|
|
|
/* list must be sorted by event type */
|
|
|
|
{ KeyPress, X11DRV_KeyEvent },
|
|
|
|
{ KeyRelease, X11DRV_KeyEvent },
|
|
|
|
{ ButtonPress, X11DRV_ButtonPress },
|
|
|
|
{ ButtonRelease, X11DRV_ButtonRelease },
|
|
|
|
{ MotionNotify, X11DRV_MotionNotify },
|
|
|
|
{ EnterNotify, X11DRV_EnterNotify },
|
|
|
|
/* LeaveNotify */
|
|
|
|
{ FocusIn, EVENT_FocusIn },
|
|
|
|
{ FocusOut, EVENT_FocusOut },
|
|
|
|
{ KeymapNotify, X11DRV_KeymapNotify },
|
|
|
|
{ Expose, X11DRV_Expose },
|
|
|
|
/* GraphicsExpose */
|
|
|
|
/* NoExpose */
|
|
|
|
/* VisibilityNotify */
|
|
|
|
/* CreateNotify */
|
|
|
|
/* DestroyNotify */
|
|
|
|
{ UnmapNotify, X11DRV_UnmapNotify },
|
|
|
|
{ MapNotify, X11DRV_MapNotify },
|
|
|
|
/* MapRequest */
|
|
|
|
/* ReparentNotify */
|
|
|
|
{ ConfigureNotify, X11DRV_ConfigureNotify },
|
|
|
|
/* ConfigureRequest */
|
|
|
|
/* GravityNotify */
|
|
|
|
/* ResizeRequest */
|
|
|
|
/* CirculateNotify */
|
|
|
|
/* CirculateRequest */
|
|
|
|
{ PropertyNotify, EVENT_PropertyNotify },
|
|
|
|
{ SelectionClear, X11DRV_SelectionClear },
|
|
|
|
{ SelectionRequest, X11DRV_SelectionRequest },
|
|
|
|
/* SelectionNotify */
|
|
|
|
/* ColormapNotify */
|
|
|
|
{ ClientMessage, EVENT_ClientMessage },
|
|
|
|
{ MappingNotify, X11DRV_MappingNotify },
|
|
|
|
};
|
1999-09-20 17:42:47 +02:00
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
static int nb_event_handlers = 18; /* change this if you add handlers above */
|
1998-12-07 10:13:40 +01:00
|
|
|
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/* return the name of an X event */
|
|
|
|
static const char *dbgstr_event( int type )
|
|
|
|
{
|
|
|
|
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"
|
|
|
|
};
|
|
|
|
|
|
|
|
if (type >= KeyPress && type <= MappingNotify) return event_names[type - KeyPress];
|
|
|
|
return wine_dbg_sprintf( "Extension event %d", type );
|
|
|
|
}
|
|
|
|
|
1999-12-12 20:42:47 +01:00
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* find_handler
|
|
|
|
*
|
|
|
|
* Find the handler for a given event type. Caller must hold the x11 lock.
|
|
|
|
*/
|
|
|
|
static inline x11drv_event_handler find_handler( int type )
|
|
|
|
{
|
|
|
|
int min = 0, max = nb_event_handlers - 1;
|
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
int pos = (min + max) / 2;
|
|
|
|
if (handlers[pos].type == type) return handlers[pos].handler;
|
|
|
|
if (handlers[pos].type > type) max = pos - 1;
|
|
|
|
else min = pos + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_register_event_handler
|
|
|
|
*
|
|
|
|
* Register a handler for a given event type.
|
|
|
|
* If already registered, overwrite the previous handler.
|
|
|
|
*/
|
|
|
|
void X11DRV_register_event_handler( int type, x11drv_event_handler handler )
|
|
|
|
{
|
|
|
|
int min, max;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
min = 0;
|
|
|
|
max = nb_event_handlers - 1;
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
int pos = (min + max) / 2;
|
|
|
|
if (handlers[pos].type == type)
|
|
|
|
{
|
|
|
|
handlers[pos].handler = handler;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (handlers[pos].type > type) max = pos - 1;
|
|
|
|
else min = pos + 1;
|
|
|
|
}
|
|
|
|
/* insert it between max and min */
|
|
|
|
memmove( &handlers[min+1], &handlers[min], (nb_event_handlers - min) * sizeof(handlers[0]) );
|
|
|
|
handlers[min].type = type;
|
|
|
|
handlers[min].handler = handler;
|
|
|
|
nb_event_handlers++;
|
|
|
|
assert( nb_event_handlers <= MAX_EVENT_HANDLERS );
|
|
|
|
done:
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
TRACE("registered handler %p for event %d count %d\n", handler, type, nb_event_handlers );
|
|
|
|
}
|
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
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
static int process_events( Display *display )
|
1999-02-21 19:15:26 +01:00
|
|
|
{
|
1999-05-22 20:57:17 +02:00
|
|
|
XEvent event;
|
2005-02-26 18:49:38 +01:00
|
|
|
HWND hwnd;
|
|
|
|
int count;
|
|
|
|
x11drv_event_handler handler;
|
1999-02-21 19:15:26 +01:00
|
|
|
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_lock();
|
2005-02-26 18:49:38 +01:00
|
|
|
for (count = 0; XPending(display); count++)
|
1999-05-22 20:57:17 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XNextEvent( display, &event );
|
|
|
|
if (XFilterEvent( &event, None )) continue; /* filtered, ignore it */
|
|
|
|
|
|
|
|
if (!(handler = find_handler( event.type )))
|
|
|
|
{
|
|
|
|
TRACE( "%s, ignoring\n", dbgstr_event( event.type ));
|
|
|
|
continue; /* no handler, ignore it */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XFindContext( display, event.xany.window, winContext, (char **)&hwnd ) != 0)
|
|
|
|
hwnd = 0; /* not for a registered window */
|
|
|
|
if (!hwnd && event.xany.window == root_window) hwnd = GetDesktopWindow();
|
2003-01-23 02:29:58 +01:00
|
|
|
|
2001-01-15 23:31:24 +01:00
|
|
|
wine_tsx11_unlock();
|
2005-02-26 18:49:38 +01:00
|
|
|
TRACE( "%s for hwnd/window %p/%lx\n",
|
|
|
|
dbgstr_event( event.type ), hwnd, event.xany.window );
|
|
|
|
handler( hwnd, &event );
|
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();
|
2005-02-26 18:49:38 +01:00
|
|
|
if (count) TRACE( "processed %d events\n", count );
|
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
|
|
|
|
2003-05-19 21:07:32 +02:00
|
|
|
/* check whether only server queue handle was passed in */
|
|
|
|
if (count < 2) flags &= ~MWMO_WAITALL;
|
|
|
|
|
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++;
|
2005-02-26 18:49:38 +01:00
|
|
|
if (process_events( data->display )) ret = count;
|
2001-06-04 23:55:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = WaitForMultipleObjectsEx( count+1, new_handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
2005-02-26 18:49:38 +01:00
|
|
|
if (ret == count) process_events( data->display );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
data->process_event_count--;
|
|
|
|
return ret;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2005-01-14 18:06:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_x11_time_to_win32_time
|
|
|
|
*
|
|
|
|
* Make our timer and the X timer line up as best we can
|
|
|
|
* Pass 0 to retrieve the current adjustment value (times -1)
|
|
|
|
*/
|
|
|
|
DWORD EVENT_x11_time_to_win32_time(Time time)
|
|
|
|
{
|
|
|
|
static DWORD adjust = 0;
|
|
|
|
DWORD now = GetTickCount();
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (! adjust && time != 0)
|
|
|
|
{
|
|
|
|
ret = now;
|
|
|
|
adjust = time - now;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If we got an event in the 'future', then our clock is clearly wrong.
|
|
|
|
If we got it more than 10000 ms in the future, then it's most likely
|
|
|
|
that the clock has wrapped. */
|
|
|
|
|
|
|
|
ret = time - adjust;
|
|
|
|
if (ret > now && ((ret - now) < 10000) && time != 0)
|
|
|
|
{
|
|
|
|
adjust += ret - now;
|
|
|
|
ret -= ret - now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
2001-05-16 21:52:29 +02: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-31 03:38:20 +01:00
|
|
|
TRACE( "setting foreground window to %p\n", hwnd );
|
2002-10-12 01:41:06 +02:00
|
|
|
SetForegroundWindow( hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
focus = GetFocus();
|
2003-01-21 21:16:20 +01:00
|
|
|
if (focus) focus = GetAncestor( focus, GA_ROOT );
|
2002-09-19 01:09:50 +02:00
|
|
|
win = X11DRV_get_whole_window(focus);
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "setting focus to %p (%lx) time=%ld\n", focus, win, time );
|
2003-11-21 06:30:34 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetInputFocus( thread_display(), win, RevertToParent, time );
|
|
|
|
wine_tsx11_unlock();
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2005-03-01 12:52:02 +01:00
|
|
|
* handle_wm_protocols
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2005-03-01 12:52:02 +01:00
|
|
|
static void handle_wm_protocols( 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
|
|
|
|
2003-11-20 05:24:18 +01:00
|
|
|
if (protocol == x11drv_atom(WM_DELETE_WINDOW))
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
2005-02-23 22:47:32 +01:00
|
|
|
if (IsWindowEnabled(hwnd)) PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
2003-11-20 05:24:18 +01:00
|
|
|
else if (protocol == x11drv_atom(WM_TAKE_FOCUS))
|
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;
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "got take focus msg for %p, enabled=%d, focus=%p, active=%p, fg=%p, last=%p\n",
|
2002-09-19 01:09:50 +02:00
|
|
|
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,
|
2002-10-31 03:38:20 +01:00
|
|
|
(WPARAM)GetAncestor( hwnd, GA_ROOT ),
|
2002-09-19 01:09:50 +02:00
|
|
|
MAKELONG(HTCAPTION,WM_LBUTTONDOWN) );
|
|
|
|
if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE) set_focus( hwnd, event_time );
|
2002-10-31 03:38:20 +01:00
|
|
|
else TRACE( "not setting focus to %p (%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();
|
2003-01-21 21:16:20 +01:00
|
|
|
if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
|
2002-09-19 01:09:50 +02:00
|
|
|
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
|
|
|
}
|
2003-11-20 05:24:18 +01:00
|
|
|
}
|
|
|
|
else if (protocol == x11drv_atom(_NET_WM_PING))
|
|
|
|
{
|
2003-05-04 04:27:20 +02:00
|
|
|
XClientMessageEvent xev;
|
|
|
|
xev = *event;
|
|
|
|
|
|
|
|
TRACE("NET_WM Ping\n");
|
|
|
|
xev.window = DefaultRootWindow(xev.display);
|
|
|
|
XSendEvent(xev.display, xev.window, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&xev);
|
|
|
|
/* this line is semi-stolen from gtk2 */
|
|
|
|
TRACE("NET_WM Pong\n");
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char * const focus_details[] =
|
|
|
|
{
|
|
|
|
"NotifyAncestor",
|
|
|
|
"NotifyVirtual",
|
|
|
|
"NotifyInferior",
|
|
|
|
"NotifyNonlinear",
|
|
|
|
"NotifyNonlinearVirtual",
|
|
|
|
"NotifyPointer",
|
|
|
|
"NotifyPointerRoot",
|
|
|
|
"NotifyDetailNone"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_FocusIn
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
static void EVENT_FocusIn( HWND hwnd, XEvent *xev )
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XFocusChangeEvent *event = &xev->xfocus;
|
2003-01-23 02:29:58 +01:00
|
|
|
XIC xic;
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
if (!hwnd) return;
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "win %p xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );
|
2002-09-19 01:09:50 +02:00
|
|
|
|
|
|
|
if (event->detail == NotifyPointer) return;
|
|
|
|
|
2003-01-23 02:29:58 +01:00
|
|
|
if ((xic = X11DRV_get_ic( hwnd )))
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetICFocus( xic );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2003-11-20 05:24:18 +01:00
|
|
|
if (use_take_focus) return; /* ignore FocusIn if we are using take focus */
|
2003-01-23 02:29:58 +01:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (!can_activate_window(hwnd))
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
HWND hwnd = GetFocus();
|
2003-01-21 21:16:20 +01:00
|
|
|
if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
|
2002-09-19 01:09:50 +02:00
|
|
|
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
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
static void EVENT_FocusOut( HWND hwnd, XEvent *xev )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XFocusChangeEvent *event = &xev->xfocus;
|
2002-09-19 01:09:50 +02:00
|
|
|
HWND hwnd_tmp;
|
|
|
|
Window focus_win;
|
|
|
|
int revert;
|
2003-01-23 02:29:58 +01:00
|
|
|
XIC xic;
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2004-09-29 23:11:28 +02:00
|
|
|
if (!hwnd) return;
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "win %p xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );
|
2002-09-19 01:09:50 +02:00
|
|
|
|
|
|
|
if (event->detail == NotifyPointer) return;
|
2004-01-21 03:22:26 +01:00
|
|
|
if (ximInComposeMode) return;
|
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
x11drv_thread_data()->last_focus = hwnd;
|
2003-01-23 02:29:58 +01:00
|
|
|
if ((xic = X11DRV_get_ic( hwnd )))
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnsetICFocus( xic );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
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_PropertyNotify
|
|
|
|
* We use this to release resources like Pixmaps when a selection
|
|
|
|
* client no longer needs them.
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XPropertyEvent *event = &xev->xproperty;
|
1999-09-20 17:42:47 +02:00
|
|
|
/* 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:
|
|
|
|
{
|
2003-11-21 22:48:36 +01:00
|
|
|
TRACE("\tPropertyDelete for atom %ld on window %ld\n",
|
|
|
|
event->atom, (long)event->window);
|
1999-09-20 17:42:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PropertyNewValue:
|
|
|
|
{
|
2003-11-21 22:48:36 +01:00
|
|
|
TRACE("\tPropertyNewValue for atom %ld on window %ld\n\n",
|
|
|
|
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;
|
2005-01-17 20:17:47 +01:00
|
|
|
Window win, w_aux_root, w_aux_child;
|
2002-09-23 22:56:37 +02:00
|
|
|
WND* pWnd;
|
|
|
|
HWND hScope = hWnd;
|
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
win = X11DRV_get_whole_window(hWnd);
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
2005-01-17 20:17:47 +01:00
|
|
|
XQueryPointer( event->display, win, &w_aux_root, &w_aux_child,
|
2003-11-21 22:48:36 +01:00
|
|
|
&x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
|
|
|
|
(unsigned int*)&aux_long);
|
|
|
|
wine_tsx11_unlock();
|
2002-09-23 22:56:37 +02:00
|
|
|
|
2005-01-20 21:07:42 +01:00
|
|
|
pWnd = WIN_GetPtr(hWnd);
|
2005-01-17 20:17:47 +01:00
|
|
|
|
2002-09-23 22:56:37 +02:00
|
|
|
/* 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
|
|
|
}
|
2005-01-20 21:07:42 +01:00
|
|
|
WIN_ReleasePtr(pWnd);
|
2001-10-16 23:58:58 +02:00
|
|
|
|
|
|
|
if (!bAccept) return;
|
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
|
|
|
x11drv_atom(DndSelection), 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y,
|
|
|
|
&data_length, &aux_long, &p_data);
|
|
|
|
wine_tsx11_unlock();
|
2001-10-16 23:58:58 +02:00
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2005-01-20 21:07:42 +01:00
|
|
|
WND *pDropWnd = WIN_GetPtr( 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;
|
2005-01-20 21:07:42 +01:00
|
|
|
WIN_ReleasePtr(pDropWnd);
|
2001-10-16 23:58:58 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if( p_data ) XFree(p_data);
|
|
|
|
wine_tsx11_unlock();
|
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
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
|
|
|
x11drv_atom(DndSelection), 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom_aux, &u.i,
|
|
|
|
&data_length, &aux_long, &p_data);
|
|
|
|
wine_tsx11_unlock();
|
1998-12-07 10:13:40 +01:00
|
|
|
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 ) {
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux,
|
|
|
|
&x, &y, &u.i, &u.i, &u.i);
|
|
|
|
wine_tsx11_unlock();
|
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 ) {
|
2005-01-20 21:07:42 +01:00
|
|
|
WND *pDropWnd = WIN_GetPtr( 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);
|
2005-01-20 21:07:42 +01:00
|
|
|
WIN_ReleasePtr(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
|
|
|
}
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if( p_data ) XFree(p_data);
|
|
|
|
wine_tsx11_unlock();
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-01 12:52:02 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* handle_dnd_protocol
|
|
|
|
*/
|
|
|
|
static void handle_dnd_protocol( HWND hwnd, XClientMessageEvent *event )
|
|
|
|
{
|
|
|
|
Window root, child;
|
|
|
|
int root_x, root_y, child_x, child_y;
|
|
|
|
unsigned int u;
|
|
|
|
|
|
|
|
/* query window (drag&drop event contains only drag window) */
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct client_message_handler
|
|
|
|
{
|
|
|
|
int atom; /* protocol atom */
|
|
|
|
void (*handler)(HWND, XClientMessageEvent *); /* corresponding handler function */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct client_message_handler client_messages[] =
|
|
|
|
{
|
|
|
|
{ XATOM_WM_PROTOCOLS, handle_wm_protocols },
|
|
|
|
{ XATOM_DndProtocol, handle_dnd_protocol },
|
|
|
|
{ XATOM_XdndEnter, X11DRV_XDND_EnterEvent },
|
|
|
|
{ XATOM_XdndPosition, X11DRV_XDND_PositionEvent },
|
|
|
|
{ XATOM_XdndDrop, X11DRV_XDND_DropEvent },
|
|
|
|
{ XATOM_XdndLeave, X11DRV_XDND_LeaveEvent }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_ClientMessage
|
|
|
|
*/
|
2005-03-01 12:52:02 +01:00
|
|
|
static void EVENT_ClientMessage( HWND hwnd, XEvent *xev )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XClientMessageEvent *event = &xev->xclient;
|
2005-03-01 12:52:02 +01:00
|
|
|
unsigned int i;
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2005-03-01 12:52:02 +01:00
|
|
|
if (!hwnd) return;
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2005-03-01 12:52:02 +01:00
|
|
|
if (event->format != 32)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-01 12:52:02 +01:00
|
|
|
WARN( "Don't know how to handle format %d\n", event->format );
|
|
|
|
return;
|
1999-04-18 11:21:01 +02:00
|
|
|
}
|
2005-03-01 12:52:02 +01:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(client_messages)/sizeof(client_messages[0]); i++)
|
2003-11-20 23:09:51 +01:00
|
|
|
{
|
2005-03-01 12:52:02 +01:00
|
|
|
if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM])
|
|
|
|
{
|
|
|
|
client_messages[i].handler( hwnd, event );
|
|
|
|
return;
|
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2005-03-01 12:52:02 +01:00
|
|
|
TRACE( "no handler found for %ld\n", event->message_type );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2005-03-07 20:31:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_WindowMessage (X11DRV.@)
|
|
|
|
*/
|
|
|
|
LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_X11DRV_ACQUIRE_SELECTION:
|
|
|
|
X11DRV_AcquireClipboard( hwnd );
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
FIXME( "got window msg %x hwnd %p wp %x lp %lx\n", msg, hwnd, wp, lp );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|