clipboard.c 14.5 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
2
 * WIN32 clipboard implementation
Alexandre Julliard's avatar
Alexandre Julliard committed
3 4
 *
 * Copyright 1994 Martin Ayotte
Alexandre Julliard's avatar
Alexandre Julliard committed
5
 *	     1996 Alex Korobka
6
 *	     1999 Noel Borthwick
7
 *	     2003 Ulrich Czekalla for CodeWeavers
8
 *
9 10 11 12 13 14 15 16 17 18 19 20
 * 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
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22
 *
23 24 25 26 27 28 29
 * NOTES:
 *    This file contains the implementation for the WIN32 Clipboard API
 * and Wine's internal clipboard cache.
 * The actual contents of the clipboard are held in the clipboard cache.
 * The internal implementation talks to a "clipboard driver" to fill or
 * expose the cache to the native device. (Currently only the X11 and
 * TTY clipboard  driver are available)
Alexandre Julliard's avatar
Alexandre Julliard committed
30
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
31

32
#include "config.h"
33
#include "wine/port.h"
34

35
#include <stdarg.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
36
#include <stdlib.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
37 38
#include <sys/types.h>
#include <fcntl.h>
39 40 41
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
42
#include <string.h>
43

44
#include "windef.h"
45
#include "winbase.h"
46
#include "wingdi.h"
47
#include "winuser.h"
48
#include "winerror.h"
49
#include "user_private.h"
50
#include "win.h"
51

52
#include "wine/debug.h"
53
#include "wine/unicode.h"
54
#include "wine/server.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
55

56
WINE_DEFAULT_DEBUG_CHANNEL(clipboard);
57

58
#define  CF_REGFORMATBASE  0xC000
Alexandre Julliard's avatar
Alexandre Julliard committed
59

60 61 62 63 64 65 66 67
typedef struct
{
    HWND hWndOpen;
    HWND hWndOwner;
    HWND hWndViewer;
    UINT seqno;
    UINT flags;
} CLIPBOARDINFO, *LPCLIPBOARDINFO;
68

69 70
/*
 * Indicates if data has changed since open.
71
 */
72
static BOOL bCBHasChanged = FALSE;
73 74 75


/**************************************************************************
76
 *                      CLIPBOARD_SetClipboardOwner
77 78 79
 *
 * Set the global wineserver clipboard owner. The current process will
 * be the owner and <hWnd> will get the render notifications.
80
 */
81
static BOOL CLIPBOARD_SetClipboardOwner(HWND hWnd)
Alexandre Julliard's avatar
Alexandre Julliard committed
82
{
83
    BOOL bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
84

85
    TRACE(" hWnd(%p)\n", hWnd);
86

87 88 89
    SERVER_START_REQ( set_clipboard_info )
    {
        req->flags = SET_CB_OWNER;
90 91
        req->owner = wine_server_user_handle( hWnd );
        bRet = !wine_server_call_err( req );
92 93
    }
    SERVER_END_REQ;
Alexandre Julliard's avatar
Alexandre Julliard committed
94

95
    return bRet;
96 97
}

Alexandre Julliard's avatar
Alexandre Julliard committed
98 99

/**************************************************************************
100
 *                      CLIPBOARD_GetClipboardInfo
Alexandre Julliard's avatar
Alexandre Julliard committed
101
 */
102
static BOOL CLIPBOARD_GetClipboardInfo(LPCLIPBOARDINFO cbInfo)
Alexandre Julliard's avatar
Alexandre Julliard committed
103
{
104
    BOOL bRet;
105 106

    SERVER_START_REQ( set_clipboard_info )
Pascal Cuoq's avatar
Pascal Cuoq committed
107
    {
108 109
        req->flags = 0;

110
        if (((bRet = !wine_server_call_err( req ))))
111
        {
112 113 114
            cbInfo->hWndOpen = wine_server_ptr_handle( reply->old_clipboard );
            cbInfo->hWndOwner = wine_server_ptr_handle( reply->old_owner );
            cbInfo->hWndViewer = wine_server_ptr_handle( reply->old_viewer );
115 116 117
            cbInfo->seqno = reply->seqno;
            cbInfo->flags = reply->flags;
        }
Alexandre Julliard's avatar
Alexandre Julliard committed
118
    }
119
    SERVER_END_REQ;
Alexandre Julliard's avatar
Alexandre Julliard committed
120

121
    return bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
122 123
}

124

125
/**************************************************************************
126
 *	CLIPBOARD_ReleaseOwner
127
 */
128
BOOL CLIPBOARD_ReleaseOwner(void)
129
{
130
    BOOL bRet = FALSE;
131

132
    SERVER_START_REQ( set_clipboard_info )
133
    {
134
        req->flags = SET_CB_RELOWNER | SET_CB_SEQNO;
135

136 137 138 139 140 141 142 143
        if (wine_server_call_err( req ))
        {
            ERR("Failed to set clipboard.\n");
        }
        else
        {
            bRet = TRUE;
        }
144
    }
145 146 147
    SERVER_END_REQ;

    return bRet;
148 149
}

150

Alexandre Julliard's avatar
Alexandre Julliard committed
151
/**************************************************************************
152
 *		CLIPBOARD_OpenClipboard
Alexandre Julliard's avatar
Alexandre Julliard committed
153
 */
154
static BOOL CLIPBOARD_OpenClipboard(HWND hWnd)
Alexandre Julliard's avatar
Alexandre Julliard committed
155
{
156
    BOOL bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
157

158
    SERVER_START_REQ( set_clipboard_info )
Alexandre Julliard's avatar
Alexandre Julliard committed
159
    {
160
        req->flags = SET_CB_OPEN;
161 162
        req->clipboard = wine_server_user_handle( hWnd );
        bRet = !wine_server_call( req );
Alexandre Julliard's avatar
Alexandre Julliard committed
163
    }
164 165 166
    SERVER_END_REQ;

    return bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
167 168
}

169

170
/**************************************************************************
171
 *		CLIPBOARD_CloseClipboard
172
 */
173
static BOOL CLIPBOARD_CloseClipboard(void)
174
{
175
    BOOL bRet;
176 177

    TRACE(" Changed=%d\n", bCBHasChanged);
178

179
    SERVER_START_REQ( set_clipboard_info )
180
    {
181
        req->flags = SET_CB_CLOSE;
182 183
        if (bCBHasChanged) req->flags |= SET_CB_SEQNO;
        bRet = !wine_server_call_err( req );
184
    }
185
    SERVER_END_REQ;
186

187
    return bRet;
188 189
}

190 191 192
/**************************************************************************
 *		CLIPBOARD_SetClipboardViewer
 */
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
static HWND CLIPBOARD_SetClipboardViewer( HWND hWnd )
{
    HWND hwndPrev = 0;

    SERVER_START_REQ( set_clipboard_info )
    {
        req->flags = SET_CB_VIEWER;
        req->viewer = wine_server_user_handle( hWnd );
        if (!wine_server_call_err( req ))
            hwndPrev = wine_server_ptr_handle( reply->old_viewer );
    }
    SERVER_END_REQ;

    return hwndPrev;
}
208

209
/**************************************************************************
210 211
 *                WIN32 Clipboard implementation
 **************************************************************************/
212

213
/**************************************************************************
Jacek Caban's avatar
Jacek Caban committed
214
 *		RegisterClipboardFormatW (USER32.@)
215
 */
216
UINT WINAPI RegisterClipboardFormatW( LPCWSTR name )
217
{
218
    return GlobalAddAtomW( name );
219 220
}

221

222
/**************************************************************************
Jacek Caban's avatar
Jacek Caban committed
223
 *		RegisterClipboardFormatA (USER32.@)
224
 */
225
UINT WINAPI RegisterClipboardFormatA( LPCSTR name )
226
{
227
    return GlobalAddAtomA( name );
228 229
}

230

231
/**************************************************************************
Jacek Caban's avatar
Jacek Caban committed
232
 *		GetClipboardFormatNameW (USER32.@)
233
 */
Jacek Caban's avatar
Jacek Caban committed
234
INT WINAPI GetClipboardFormatNameW(UINT wFormat, LPWSTR retStr, INT maxlen)
235
{
236 237
    if (wFormat < MAXINTATOM) return 0;
    return GlobalGetAtomNameW( wFormat, retStr, maxlen );
238 239
}

240

241
/**************************************************************************
Jacek Caban's avatar
Jacek Caban committed
242
 *		GetClipboardFormatNameA (USER32.@)
243
 */
Jacek Caban's avatar
Jacek Caban committed
244
INT WINAPI GetClipboardFormatNameA(UINT wFormat, LPSTR retStr, INT maxlen)
245
{
246 247
    if (wFormat < MAXINTATOM) return 0;
    return GlobalGetAtomNameA( wFormat, retStr, maxlen );
248 249 250
}


Alexandre Julliard's avatar
Alexandre Julliard committed
251
/**************************************************************************
252
 *		OpenClipboard (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
253 254
 *
 * Note: Netscape uses NULL hWnd to open the clipboard.
Alexandre Julliard's avatar
Alexandre Julliard committed
255
 */
256
BOOL WINAPI OpenClipboard( HWND hWnd )
Alexandre Julliard's avatar
Alexandre Julliard committed
257
{
258
    BOOL bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
259

260
    TRACE("(%p)...\n", hWnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
261

262
    bRet = CLIPBOARD_OpenClipboard(hWnd);
263

264
    TRACE(" returning %i\n", bRet);
Alexandre Julliard's avatar
Alexandre Julliard committed
265 266

    return bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
267 268 269
}


Alexandre Julliard's avatar
Alexandre Julliard committed
270
/**************************************************************************
271
 *		CloseClipboard (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
272
 */
273
BOOL WINAPI CloseClipboard(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
274
{
275 276
    BOOL bRet = FALSE;

277
    TRACE("() Changed=%d\n", bCBHasChanged);
Alexandre Julliard's avatar
Alexandre Julliard committed
278

279
    if (CLIPBOARD_CloseClipboard())
Alexandre Julliard's avatar
Alexandre Julliard committed
280
    {
281 282
        if (bCBHasChanged)
        {
283 284
            HWND hWndViewer = GetClipboardViewer();

285
            USER_Driver->pEndClipboardUpdate();
286

287 288
            bCBHasChanged = FALSE;

289
            if (hWndViewer)
290
                SendMessageW(hWndViewer, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0);
291
        }
Alexandre Julliard's avatar
Alexandre Julliard committed
292

293
        bRet = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
294
    }
295 296

    return bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
297 298 299
}


Alexandre Julliard's avatar
Alexandre Julliard committed
300
/**************************************************************************
301
 *		EmptyClipboard (USER32.@)
302
 * Empties and acquires ownership of the clipboard
Alexandre Julliard's avatar
Alexandre Julliard committed
303
 */
304
BOOL WINAPI EmptyClipboard(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
305
{
306
    CLIPBOARDINFO cbinfo;
307

308
    TRACE("()\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
309

310 311
    if (!CLIPBOARD_GetClipboardInfo(&cbinfo) ||
        ~cbinfo.flags & CB_OPEN)
312
    {
313
        WARN("Clipboard not opened by calling task!\n");
314
        SetLastError(ERROR_CLIPBOARD_NOT_OPEN);
315 316
        return FALSE;
    }
317

318
    /* Destroy private objects */
319
    if (cbinfo.hWndOwner)
320
        SendMessageW(cbinfo.hWndOwner, WM_DESTROYCLIPBOARD, 0, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
321

322 323
    /* Tell the driver to acquire the selection. The current owner
     * will be signaled to delete it's own cache. */
324 325 326

    /* Assign ownership of the clipboard to the current client. We do
     * this before acquiring the selection so that when we do acquire the
327
     * selection and the selection loser gets notified, it can check if
328 329
     * it has lost the Wine clipboard ownership. If it did then it knows
     * that a WM_DESTORYCLIPBOARD has already been sent. Otherwise it
330
     * lost the selection to a X app and it should send the
331 332 333 334
     * WM_DESTROYCLIPBOARD itself. */
    CLIPBOARD_SetClipboardOwner(cbinfo.hWndOpen);

    /* Acquire the selection. This will notify the previous owner
335
     * to clear it's cache. */
336
    USER_Driver->pAcquireClipboard(cbinfo.hWndOpen);
337

338
    /* Empty the local cache */
339
    USER_Driver->pEmptyClipboard(FALSE);
340

341
    bCBHasChanged = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
342

Alexandre Julliard's avatar
Alexandre Julliard committed
343 344 345 346
    return TRUE;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
347
/**************************************************************************
348
 *		GetClipboardOwner (USER32.@)
349
 *  FIXME: Can't return the owner if the clipboard is owned by an external X-app
Alexandre Julliard's avatar
Alexandre Julliard committed
350
 */
351
HWND WINAPI GetClipboardOwner(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
352
{
353 354
    HWND hWndOwner = 0;

355 356 357
    SERVER_START_REQ( set_clipboard_info )
    {
        req->flags = 0;
358
        if (!wine_server_call_err( req )) hWndOwner = wine_server_ptr_handle( reply->old_owner );
359 360
    }
    SERVER_END_REQ;
361 362 363 364

    TRACE(" hWndOwner(%p)\n", hWndOwner);

    return hWndOwner;
Alexandre Julliard's avatar
Alexandre Julliard committed
365 366 367 368
}


/**************************************************************************
369
 *		GetOpenClipboardWindow (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
370
 */
371
HWND WINAPI GetOpenClipboardWindow(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
372
{
373
    HWND hWndOpen = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
374

375 376 377
    SERVER_START_REQ( set_clipboard_info )
    {
        req->flags = 0;
378
        if (!wine_server_call_err( req )) hWndOpen = wine_server_ptr_handle( reply->old_clipboard );
379 380
    }
    SERVER_END_REQ;
Alexandre Julliard's avatar
Alexandre Julliard committed
381

382
    TRACE(" hWndClipWindow(%p)\n", hWndOpen);
Alexandre Julliard's avatar
Alexandre Julliard committed
383

384 385
    return hWndOpen;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
386 387


388 389 390 391 392
/**************************************************************************
 *		SetClipboardViewer (USER32.@)
 */
HWND WINAPI SetClipboardViewer( HWND hWnd )
{
393
    HWND hwndPrev = CLIPBOARD_SetClipboardViewer(hWnd);
394

395 396
    if (hWnd)
        SendMessageW(hWnd, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0);
397
    TRACE("(%p): returning %p\n", hWnd, hwndPrev);
398

399
    return hwndPrev;
Alexandre Julliard's avatar
Alexandre Julliard committed
400 401
}

Alexandre Julliard's avatar
Alexandre Julliard committed
402 403

/**************************************************************************
404
 *              GetClipboardViewer (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
405
 */
406
HWND WINAPI GetClipboardViewer(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
407
{
408
    HWND hWndViewer = 0;
Pascal Cuoq's avatar
Pascal Cuoq committed
409

410 411 412
    SERVER_START_REQ( set_clipboard_info )
    {
        req->flags = 0;
413
        if (!wine_server_call_err( req )) hWndViewer = wine_server_ptr_handle( reply->old_viewer );
414 415
    }
    SERVER_END_REQ;
Pascal Cuoq's avatar
Pascal Cuoq committed
416

417
    TRACE(" hWndViewer=%p\n", hWndViewer);
Pascal Cuoq's avatar
Pascal Cuoq committed
418

419 420
    return hWndViewer;
}
Pascal Cuoq's avatar
Pascal Cuoq committed
421 422


423
/**************************************************************************
424
 *              ChangeClipboardChain (USER32.@)
425 426 427 428 429 430 431
 */
BOOL WINAPI ChangeClipboardChain(HWND hWnd, HWND hWndNext)
{
    BOOL bRet = TRUE;
    HWND hWndViewer = GetClipboardViewer();

    if (hWndViewer)
Pascal Cuoq's avatar
Pascal Cuoq committed
432
    {
433
        if (WIN_GetFullHandle(hWnd) == hWndViewer)
434
            CLIPBOARD_SetClipboardViewer(WIN_GetFullHandle(hWndNext));
435
        else
436
            bRet = !SendMessageW(hWndViewer, WM_CHANGECBCHAIN, (WPARAM)hWnd, (LPARAM)hWndNext);
Pascal Cuoq's avatar
Pascal Cuoq committed
437
    }
438
    else
439
        ERR("hWndViewer is lost\n");
440

441
    return bRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
442 443 444 445
}


/**************************************************************************
446
 *		SetClipboardData (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
447
 */
448
HANDLE WINAPI SetClipboardData(UINT wFormat, HANDLE hData)
Alexandre Julliard's avatar
Alexandre Julliard committed
449
{
450 451
    CLIPBOARDINFO cbinfo;
    HANDLE hResult = 0;
Pascal Cuoq's avatar
Pascal Cuoq committed
452

453
    TRACE("(%04X, %p) !\n", wFormat, hData);
454

455 456
    /* If it's not owned, data can only be set if the format isn't
       available and its rendering is not delayed */
457 458
    if (!CLIPBOARD_GetClipboardInfo(&cbinfo) ||
       (!(cbinfo.flags & CB_OWNER) && !hData))
459 460 461 462 463
    {
        WARN("Clipboard not owned by calling task. Operation failed.\n");
        return 0;
    }

464
    if (USER_Driver->pSetClipboardData(wFormat, hData, cbinfo.flags & CB_OWNER))
Pascal Cuoq's avatar
Pascal Cuoq committed
465
    {
466 467
        hResult = hData;
        bCBHasChanged = TRUE;
Pascal Cuoq's avatar
Pascal Cuoq committed
468 469
    }

470
    return hResult;
Alexandre Julliard's avatar
Alexandre Julliard committed
471 472
}

473

Alexandre Julliard's avatar
Alexandre Julliard committed
474
/**************************************************************************
475
 *		CountClipboardFormats (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
476
 */
477
INT WINAPI CountClipboardFormats(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
478
{
479
    INT count = USER_Driver->pCountClipboardFormats();
480 481
    TRACE("returning %d\n", count);
    return count;
Alexandre Julliard's avatar
Alexandre Julliard committed
482 483
}

484

Alexandre Julliard's avatar
Alexandre Julliard committed
485
/**************************************************************************
486
 *		EnumClipboardFormats (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
487
 */
488
UINT WINAPI EnumClipboardFormats(UINT wFormat)
Alexandre Julliard's avatar
Alexandre Julliard committed
489
{
490 491
    CLIPBOARDINFO cbinfo;

492
    TRACE("(%04X)\n", wFormat);
Alexandre Julliard's avatar
Alexandre Julliard committed
493

494 495
    if (!CLIPBOARD_GetClipboardInfo(&cbinfo) ||
        (~cbinfo.flags & CB_OPEN))
496
    {
497 498
        WARN("Clipboard not opened by calling task.\n");
        SetLastError(ERROR_CLIPBOARD_NOT_OPEN);
499 500
        return 0;
    }
501
    return USER_Driver->pEnumClipboardFormats(wFormat);
Alexandre Julliard's avatar
Alexandre Julliard committed
502 503 504
}


Alexandre Julliard's avatar
Alexandre Julliard committed
505
/**************************************************************************
506
 *		IsClipboardFormatAvailable (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
507
 */
508
BOOL WINAPI IsClipboardFormatAvailable(UINT wFormat)
Alexandre Julliard's avatar
Alexandre Julliard committed
509
{
510
    BOOL bret = USER_Driver->pIsClipboardFormatAvailable(wFormat);
511 512
    TRACE("%04x, returning %d\n", wFormat, bret);
    return bret;
Alexandre Julliard's avatar
Alexandre Julliard committed
513 514 515
}


Alexandre Julliard's avatar
Alexandre Julliard committed
516
/**************************************************************************
517
 *		GetClipboardData (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
518
 */
519
HANDLE WINAPI GetClipboardData(UINT wFormat)
Alexandre Julliard's avatar
Alexandre Julliard committed
520
{
521 522
    HANDLE hData = 0;
    CLIPBOARDINFO cbinfo;
Alexandre Julliard's avatar
Alexandre Julliard committed
523

524
    TRACE("%04x\n", wFormat);
Alexandre Julliard's avatar
Alexandre Julliard committed
525

526 527
    if (!CLIPBOARD_GetClipboardInfo(&cbinfo) ||
        (~cbinfo.flags & CB_OPEN))
528
    {
529 530 531
        WARN("Clipboard not opened by calling task.\n");
        SetLastError(ERROR_CLIPBOARD_NOT_OPEN);
        return 0;
532
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
533

534
    hData = USER_Driver->pGetClipboardData( wFormat );
Alexandre Julliard's avatar
Alexandre Julliard committed
535

536 537
    TRACE("returning %p\n", hData);
    return hData;
Alexandre Julliard's avatar
Alexandre Julliard committed
538 539 540
}


Alexandre Julliard's avatar
Alexandre Julliard committed
541
/**************************************************************************
542
 *		GetPriorityClipboardFormat (USER32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
543
 */
544
INT WINAPI GetPriorityClipboardFormat(UINT *list, INT nCount)
Alexandre Julliard's avatar
Alexandre Julliard committed
545
{
546
    int i;
547

548
    TRACE("()\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
549

550 551
    if(CountClipboardFormats() == 0)
        return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
552

553
    for (i = 0; i < nCount; i++)
554 555 556
        if (IsClipboardFormatAvailable(list[i]))
            return list[i];

Alexandre Julliard's avatar
Alexandre Julliard committed
557
    return -1;
Alexandre Julliard's avatar
Alexandre Julliard committed
558 559
}

560 561

/**************************************************************************
562
 *		GetClipboardSequenceNumber (USER32.@)
563 564 565 566 567 568 569 570
 * Supported on Win2k/Win98
 * MSDN: Windows clipboard code keeps a serial number for the clipboard
 * for each window station.  The number is incremented whenever the
 * contents change or are emptied.
 * If you do not have WINSTA_ACCESSCLIPBOARD then the function returns 0
 */
DWORD WINAPI GetClipboardSequenceNumber(VOID)
{
571
    DWORD seqno = 0;
572

573
    SERVER_START_REQ( set_clipboard_info )
574
    {
575 576
        req->flags = 0;
        if (!wine_server_call_err( req )) seqno = reply->seqno;
577
    }
578
    SERVER_END_REQ;
579

580
    TRACE("returning %x\n", seqno);
581
    return seqno;
582
}