Commit d09c3289 authored by Alexandre Julliard's avatar Alexandre Julliard

Intern all the atoms we'll need in one step to avoid multiple server

round trips.
parent f01e7c63
......@@ -69,6 +69,7 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
MSG msg;
HWND hwnd;
WND *win;
Atom atom = x11drv_atom(WM_DELETE_WINDOW);
NtCurrentTeb()->driver_data = driver_data;
display = thread_display();
......@@ -82,7 +83,8 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
wine_tsx11_lock();
XSetWMProtocols( display, root_window, &wmDeleteWindow, 1 );
XChangeProperty ( display, root_window, x11drv_atom(WM_PROTOCOLS),
XA_ATOM, 32, PropModeReplace, (char *)&atom, 1 );
XMapWindow( display, root_window );
wine_tsx11_unlock();
......
......@@ -56,12 +56,6 @@ WINE_DECLARE_DEBUG_CHANNEL(clipboard);
/* 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;
extern Atom netwmPing;
#define DndNotDnd -1 /* OffiX drag&drop */
#define DndUnknown 0
#define DndRawData 1
......@@ -434,7 +428,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
if (!protocol) return;
if (protocol == wmDeleteWindow)
if (protocol == x11drv_atom(WM_DELETE_WINDOW))
{
/* Ignore the delete window request if the window has been disabled
* and we are in managed mode. This is to disallow applications from
......@@ -442,7 +436,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
*/
if (IsWindowEnabled(hwnd)) PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
}
else if (protocol == wmTakeFocus)
else if (protocol == x11drv_atom(WM_TAKE_FOCUS))
{
Time event_time = (Time)event->data.l[1];
HWND last_focus = x11drv_thread_data()->last_focus;
......@@ -469,7 +463,9 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
if (!hwnd) hwnd = last_focus;
if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, event_time );
}
} else if (protocol == netwmPing) {
}
else if (protocol == x11drv_atom(_NET_WM_PING))
{
XClientMessageEvent xev;
xev = *event;
......@@ -513,7 +509,7 @@ static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
XSetICFocus( xic );
wine_tsx11_unlock();
}
if (wmTakeFocus) return; /* ignore FocusIn if we are using take focus */
if (use_take_focus) return; /* ignore FocusIn if we are using take focus */
if (!can_activate_window(hwnd))
{
......@@ -636,7 +632,7 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
return None;
/* Create TARGETS property list (First item in list is TARGETS itself) */
for (targets[0] = xaTargets, cTargets = 1, wFormat = 0;
for (targets[0] = x11drv_atom(TARGETS), cTargets = 1, wFormat = 0;
(wFormat = X11DRV_EnumClipboardFormats(wFormat));)
{
LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupFormat(wFormat);
......@@ -736,14 +732,17 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
for (i = 0; i < cTargetPropList; i+=2)
{
char *targetName = TSXGetAtomName(display, targetPropList[i]);
char *propName = TSXGetAtomName(display, targetPropList[i+1]);
XSelectionRequestEvent event;
if (TRACE_ON(event))
{
char *targetName = TSXGetAtomName(display, targetPropList[i]);
char *propName = TSXGetAtomName(display, targetPropList[i+1]);
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
i/2, targetName, propName);
TSXFree(targetName);
TSXFree(propName);
}
/* We must have a non "None" property to service a MULTIPLE target atom */
if ( !targetPropList[i+1] )
......@@ -798,7 +797,7 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
*/
if ( !bIsMultiple )
{
if (((event->selection != XA_PRIMARY) && (event->selection != xaClipboard)))
if (((event->selection != XA_PRIMARY) && (event->selection != x11drv_atom(CLIPBOARD))))
goto END;
}
......@@ -809,12 +808,12 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
if( rprop == None )
rprop = event->target;
if(event->target == xaTargets) /* Return a list of all supported targets */
if(event->target == x11drv_atom(TARGETS)) /* Return a list of all supported targets */
{
/* TARGETS selection request */
rprop = EVENT_SelectionRequest_TARGETS( display, request, event->target, rprop );
}
else if(event->target == xaMultiple) /* rprop contains a list of (target, property) atom pairs */
else if(event->target == x11drv_atom(MULTIPLE)) /* rprop contains a list of (target, property) atom pairs */
{
/* MULTIPLE selection request */
rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event );
......@@ -884,7 +883,7 @@ END:
*/
static void EVENT_SelectionClear( HWND hWnd, XSelectionClearEvent *event )
{
if (event->selection == XA_PRIMARY || event->selection == xaClipboard)
if (event->selection == XA_PRIMARY || event->selection == x11drv_atom(CLIPBOARD))
X11DRV_CLIPBOARD_ReleaseSelection( event->selection, event->window, hWnd );
}
......@@ -1029,7 +1028,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!bAccept) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
dndSelection, 0, 65535, FALSE,
x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y,
&data_length, &aux_long, &p_data);
......@@ -1118,7 +1117,7 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
dndSelection, 0, 65535, FALSE,
x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, &u.i,
&data_length, &aux_long, &p_data);
if (aux_long)
......@@ -1208,9 +1207,9 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event )
{
if (event->message_type != None && event->format == 32) {
if (event->message_type == wmProtocols)
if (event->message_type == x11drv_atom(WM_PROTOCOLS))
handle_wm_protocols_message( hWnd, event );
else if (event->message_type == dndProtocol)
else if (event->message_type == x11drv_atom(DndProtocol))
{
/* query window (drag&drop event contains only drag window) */
Window root, child;
......
......@@ -56,17 +56,35 @@ extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP );
/* X context to associate a hwnd to an X window */
XContext winContext = 0;
Atom wmProtocols = None;
Atom wmDeleteWindow = None;
Atom wmTakeFocus = None;
Atom dndProtocol = None;
Atom dndSelection = None;
Atom wmChangeState = None;
Atom mwmHints = None;
Atom kwmDockWindow = None;
Atom netwmPid = None;
Atom netwmPing = None;
Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */
Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
{
"CLIPBOARD",
"COMPOUND_TEXT",
"MULTIPLE",
"SELECTION_DATA",
"TARGETS",
"TEXT",
"UTF8_STRING",
"RAW_ASCENT",
"RAW_DESCENT",
"RAW_CAP_HEIGHT",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"WM_TAKE_FOCUS",
"KWM_DOCKWINDOW",
"DndProtocol",
"DndSelection",
"_MOTIF_WM_HINTS",
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
"_NET_WM_PID",
"_NET_WM_PING",
"_NET_WM_NAME",
"image/gif",
"text/rtf",
"text/richtext"
};
static LPCSTR whole_window_atom;
static LPCSTR client_window_atom;
......@@ -336,17 +354,19 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
Window group_leader;
XClassHint *class_hints;
XWMHints* wm_hints;
Atom protocols[2];
Atom protocols[3];
MwmHints mwm_hints;
int i;
wine_tsx11_lock();
/* wm protocols */
i = 0;
protocols[i++] = wmDeleteWindow;
if (wmTakeFocus) protocols[i++] = wmTakeFocus;
if (netwmPing) protocols[i++] = netwmPing;
XSetWMProtocols( display, data->whole_window, protocols, i );
protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
protocols[i++] = x11drv_atom(_NET_WM_PING);
if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
XA_ATOM, 32, PropModeReplace, (char *)protocols, i );
/* class hints */
if ((class_hints = XAllocClassHint()))
......@@ -373,11 +393,9 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
if (win->dwExStyle & WS_EX_TRAYWINDOW)
{
int val = 1;
if (kwmDockWindow != None)
XChangeProperty( display, data->whole_window, kwmDockWindow, kwmDockWindow,
32, PropModeReplace, (char*)&val, 1 );
if (_kde_net_wm_system_tray_window_for != None)
XChangeProperty( display, data->whole_window, _kde_net_wm_system_tray_window_for,
XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW),
x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace, (char*)&val, 1 );
XChangeProperty( display, data->whole_window, x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 );
}
......@@ -385,11 +403,9 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
/* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
i = getpid();
XChangeProperty(display, data->whole_window, netwmPid, XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_PID),
XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
if (mwmHints != None)
{
MwmHints mwm_hints;
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
mwm_hints.functions = 0;
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE;
......@@ -408,9 +424,9 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE;
if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE;
XChangeProperty( display, data->whole_window, mwmHints, mwmHints, 32,
PropModeReplace, (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
}
XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
(char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
wm_hints = XAllocWMHints();
wine_tsx11_unlock();
......@@ -675,17 +691,7 @@ static void create_desktop( Display *display, WND *wndPtr )
wine_tsx11_lock();
winContext = XUniqueContext();
wmProtocols = XInternAtom( display, "WM_PROTOCOLS", False );
wmDeleteWindow = XInternAtom( display, "WM_DELETE_WINDOW", False );
if (use_take_focus) wmTakeFocus = XInternAtom( display, "WM_TAKE_FOCUS", False );
dndProtocol = XInternAtom( display, "DndProtocol" , False );
dndSelection = XInternAtom( display, "DndSelection" , False );
wmChangeState = XInternAtom( display, "WM_CHANGE_STATE", False );
mwmHints = XInternAtom( display, _XA_MWM_HINTS, False );
kwmDockWindow = XInternAtom( display, "KWM_DOCKWINDOW", False );
_kde_net_wm_system_tray_window_for = XInternAtom( display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False );
netwmPid = XInternAtom( display, "_NET_WM_PID", False );
netwmPing = XInternAtom( display, "_NET_WM_PING", False );
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
wine_tsx11_unlock();
whole_window_atom = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" ));
......@@ -699,6 +705,8 @@ static void create_desktop( Display *display, WND *wndPtr )
SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window );
SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)XVisualIDFromVisual(visual) );
X11DRV_InitClipboard( display );
if (root_window != DefaultRootWindow(display)) X11DRV_create_desktop_thread();
}
......@@ -849,11 +857,8 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
according to the standard
( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
*/
XChangeProperty( display, win,
XInternAtom(display, "_NET_WM_NAME", False),
XInternAtom(display, "UTF8_STRING", False),
8, PropModeReplace, (unsigned char *) utf8_buffer,
count);
XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
8, PropModeReplace, (unsigned char *) utf8_buffer, count);
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, utf8_buffer );
......
......@@ -364,30 +364,43 @@ extern int use_xkb;
extern int use_take_focus;
extern int managed_mode;
extern Atom wmProtocols;
extern Atom wmDeleteWindow;
extern Atom wmTakeFocus;
extern Atom dndProtocol;
extern Atom dndSelection;
extern Atom wmChangeState;
extern Atom kwmDockWindow;
extern Atom _kde_net_wm_system_tray_window_for;
/* atoms */
/* X11 clipboard driver */
typedef struct tagPROPERTYFORMATMAP
enum x11drv_atoms
{
LPCSTR lpszProperty;
LPCSTR lpszFormat;
} PROPERTYFORMATMAP;
FIRST_XATOM = XA_LAST_PREDEFINED + 1,
XATOM_CLIPBOARD = FIRST_XATOM,
XATOM_COMPOUND_TEXT,
XATOM_MULTIPLE,
XATOM_SELECTION_DATA,
XATOM_TARGETS,
XATOM_TEXT,
XATOM_UTF8_STRING,
XATOM_RAW_ASCENT,
XATOM_RAW_DESCENT,
XATOM_RAW_CAP_HEIGHT,
XATOM_WM_PROTOCOLS,
XATOM_WM_DELETE_WINDOW,
XATOM_WM_TAKE_FOCUS,
XATOM_KWM_DOCKWINDOW,
XATOM_DndProtocol,
XATOM_DndSelection,
XATOM__MOTIF_WM_HINTS,
XATOM__KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
XATOM__NET_WM_PID,
XATOM__NET_WM_PING,
XATOM__NET_WM_NAME,
XATOM_image_gif,
XATOM_text_rtf,
XATOM_text_richtext,
NB_XATOMS
};
typedef struct tagPROPERTYALIASMAP
{
LPCSTR lpszProperty;
UINT drvDataProperty;
LPCSTR lpszAlias;
UINT drvDataAlias;
} PROPERTYALIASMAP;
extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
#define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
/* X11 clipboard driver */
typedef struct tagWINE_CLIPDATA {
UINT wFormatID;
......@@ -416,11 +429,7 @@ typedef struct tagWINE_CLIPFORMAT {
#define CF_FLAG_BUILTINFMT 1 /* Built-in windows format */
#define CF_FLAG_SYNTHESIZED 8 /* Implicitly converted data */
extern Atom xaClipboard;
extern Atom xaTargets;
extern Atom xaMultiple;
extern BOOL X11DRV_InitClipboard(Display *display);
extern void X11DRV_InitClipboard(Display *display);
extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
extern INT X11DRV_CountClipboardFormats(void);
extern UINT X11DRV_EnumClipboardFormats(UINT wFormat);
......
......@@ -379,13 +379,6 @@ static void process_attach(void)
ExitProcess(1);
}
/* Initialize clipboard */
if (!X11DRV_InitClipboard( display ))
{
ERR( "Couldn't Initialize clipboard.\n" );
ExitProcess(1);
}
#ifdef HAVE_LIBXXF86VM
/* initialize XVidMode */
X11DRV_XF86VM_Init();
......
......@@ -342,9 +342,6 @@ static int fontLF = -1, fontMRU = -1; /* last free, most recently used */
#define CHECK_PFONT(pFont) ( (((UINT)(pFont) & 0xFFFF0000) == X_PFONT_MAGIC) &&\
(((UINT)(pFont) & 0x0000FFFF) < fontCacheSize) )
static Atom RAW_ASCENT;
static Atom RAW_DESCENT;
/***********************************************************************
* Helper macros from X distribution
*/
......@@ -1067,8 +1064,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( pEL ) *pEL = 0;
if(XFT) {
Atom RAW_CAP_HEIGHT = TSXInternAtom(gdi_display, "RAW_CAP_HEIGHT", TRUE);
if(TSXGetFontProperty((XFontStruct*)x_fs, RAW_CAP_HEIGHT, &height))
if(TSXGetFontProperty((XFontStruct*)x_fs, x11drv_atom(RAW_CAP_HEIGHT), &height))
*pIL = XFT->ascent -
(INT)(XFT->pixelsize / 1000.0 * height);
else
......@@ -2033,12 +2029,9 @@ static XFontStruct *safe_XLoadQueryFont(Display *display, char *name)
{
XFontStruct *ret;
wine_tsx11_lock();
X11DRV_expect_error(display, XLoadQueryFont_ErrorHandler, NULL);
ret = XLoadQueryFont(display, name);
if (X11DRV_check_error()) ret = NULL;
wine_tsx11_unlock();
return ret;
}
......@@ -3020,12 +3013,6 @@ void X11DRV_FONT_InitX11Metrics( void )
XFONT_GrowFreeList(0, fontCacheSize - 1);
TRACE("done!\n");
/* update text caps parameter */
RAW_ASCENT = TSXInternAtom(gdi_display, "RAW_ASCENT", TRUE);
RAW_DESCENT = TSXInternAtom(gdi_display, "RAW_DESCENT", TRUE);
return;
}
/***********************************************************************
......@@ -3071,8 +3058,8 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo )
TSXFree(fontName);
HeapFree(GetProcessHeap(), 0, lfd);
TSXGetFontProperty( pfo->fs, RAW_ASCENT, &PX->RAW_ASCENT );
TSXGetFontProperty( pfo->fs, RAW_DESCENT, &PX->RAW_DESCENT );
TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT );
TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_DESCENT), &PX->RAW_DESCENT );
PX->pixelsize = hypot(PX->a, PX->b);
PX->ascent = PX->pixelsize / 1000.0 * PX->RAW_ASCENT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment