ReactOS  0.4.13-dev-39-g8b6696f
clipboard.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CLIP
 

Typedefs

typedef struct _CLIP CLIP
 
typedef struct _CLIPPCLIP
 

Functions

UINT APIENTRY UserEnumClipboardFormats (UINT uFormat)
 
VOID FASTCALL UserClipboardRelease (PWND pWindow)
 
VOID FASTCALL UserClipboardFreeWindow (PWND pWindow)
 
BOOL NTAPI UserOpenClipboard (HWND hWnd)
 
BOOL NTAPI UserCloseClipboard (VOID)
 
BOOL NTAPI UserEmptyClipboard (VOID)
 
VOID NTAPI UserEmptyClipboardData (struct _WINSTATION_OBJECT *pWinSta)
 
HANDLE NTAPI UserSetClipboardData (UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
 

Typedef Documentation

◆ CLIP

typedef struct _CLIP CLIP

◆ PCLIP

typedef struct _CLIP * PCLIP

Function Documentation

◆ UserClipboardFreeWindow()

VOID FASTCALL UserClipboardFreeWindow ( PWND  pWindow)

Definition at line 396 of file clipboard.c.

397 {
398  PWINSTATION_OBJECT pWinStaObj;
399 
400  pWinStaObj = IntGetWinStaForCbAccess();
401  if (!pWinStaObj)
402  return;
403 
404  if (pWindow == pWinStaObj->spwndClipOwner)
405  {
406  /* The owner window was destroyed */
407  pWinStaObj->spwndClipOwner = NULL;
408  }
409 
410  /* Check if clipboard is not locked by this window, if yes, unlock it */
411  if (pWindow == pWinStaObj->spwndClipOpen)
412  {
413  /* The window that opens the clipboard was destroyed */
414  pWinStaObj->spwndClipOpen = NULL;
415  pWinStaObj->ptiClipLock = NULL;
416  }
417  /* Remove window from window chain */
418  if (pWindow == pWinStaObj->spwndClipViewer)
419  pWinStaObj->spwndClipViewer = NULL;
420 
421  ObDereferenceObject(pWinStaObj);
422 }
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
smooth NULL
Definition: ftsmooth.c:416
PTHREADINFO ptiClipLock
Definition: winsta.h:26
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by co_UserFreeWindow().

◆ UserClipboardRelease()

VOID FASTCALL UserClipboardRelease ( PWND  pWindow)

Definition at line 359 of file clipboard.c.

360 {
361  PWINSTATION_OBJECT pWinStaObj;
362 
363  pWinStaObj = IntGetWinStaForCbAccess();
364  if (!pWinStaObj)
365  return;
366 
368 
369  /* If the window being destroyed is the current clipboard owner... */
370  if (pWindow == pWinStaObj->spwndClipOwner)
371  {
372  /* ... make it release the clipboard */
373  pWinStaObj->spwndClipOwner = NULL;
374  }
375 
376  if (pWinStaObj->fClipboardChanged)
377  {
378  /* Add synthesized formats - they are rendered later */
379  IntAddSynthesizedFormats(pWinStaObj);
380 
381  /* Notify viewer windows in chain */
382  pWinStaObj->fClipboardChanged = FALSE;
383  if (pWinStaObj->spwndClipViewer)
384  {
385  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
386  // For 32-bit applications this message is sent as a notification
388  }
389  }
390 
391  ObDereferenceObject(pWinStaObj);
392 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:286
#define WM_RENDERALLFORMATS
Definition: winuser.h:1828
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1830
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1547
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by IntSendDestroyMsg().

◆ UserCloseClipboard()

BOOL NTAPI UserCloseClipboard ( VOID  )

Definition at line 527 of file clipboard.c.

528 {
529  BOOL bRet = FALSE;
530  PWINSTATION_OBJECT pWinStaObj;
531 
532  pWinStaObj = IntGetWinStaForCbAccess();
533  if (!pWinStaObj)
534  goto cleanup;
535 
536  /* Check if the clipboard has been opened */
537  if (!IntIsClipboardOpenByMe(pWinStaObj))
538  {
540  goto cleanup;
541  }
542 
543  /* Clipboard is no longer open */
544  pWinStaObj->spwndClipOpen = NULL;
545  pWinStaObj->ptiClipLock = NULL;
546  bRet = TRUE;
547 
548  if (pWinStaObj->fClipboardChanged)
549  {
550  /* Add synthesized formats - they are rendered later */
551  IntAddSynthesizedFormats(pWinStaObj);
552 
553  /* Notify viewer windows in chain */
554  pWinStaObj->fClipboardChanged = FALSE;
555  if (pWinStaObj->spwndClipViewer)
556  {
557  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
558  // For 32-bit applications this message is sent as a notification
560  }
561  }
562 
563 cleanup:
564  if (pWinStaObj)
565  ObDereferenceObject(pWinStaObj);
566 
567  return bRet;
568 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:286
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:659
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:131
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1830
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1547
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), ExitThreadCallback(), NtUserCloseClipboard(), and SnapWindow().

◆ UserEmptyClipboard()

BOOL NTAPI UserEmptyClipboard ( VOID  )

Definition at line 662 of file clipboard.c.

663 {
664  BOOL bRet = FALSE;
665  PWINSTATION_OBJECT pWinStaObj;
666 
667  pWinStaObj = IntGetWinStaForCbAccess();
668  if (!pWinStaObj)
669  return FALSE;
670 
671  /* Check if the clipboard has been opened */
672  if (!IntIsClipboardOpenByMe(pWinStaObj))
673  {
675  goto cleanup;
676  }
677 
678  UserEmptyClipboardData(pWinStaObj);
679 
680  if (pWinStaObj->spwndClipOwner)
681  {
682  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
683  // For 32-bit applications this message is sent as a notification
685  }
686 
687  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
688 
689  pWinStaObj->iClipSerialNumber++;
690  pWinStaObj->iClipSequenceNumber++;
691  pWinStaObj->fClipboardChanged = TRUE;
692  pWinStaObj->fInDelayedRendering = FALSE;
693 
694  bRet = TRUE;
695 
696 cleanup:
697  if (pWinStaObj)
698  ObDereferenceObject(pWinStaObj);
699 
700  return bRet;
701 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:339
INT fInDelayedRendering
Definition: winsta.h:36
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipOpen
Definition: winsta.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
INT iClipSerialNumber
Definition: winsta.h:33
THRDESKHEAD head
Definition: ntuser.h:659
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:131
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1829
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
INT iClipSequenceNumber
Definition: winsta.h:34
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserEmptyClipboard(), and SnapWindow().

◆ UserEmptyClipboardData()

VOID NTAPI UserEmptyClipboardData ( struct _WINSTATION_OBJECT pWinSta)

◆ UserEnumClipboardFormats()

UINT APIENTRY UserEnumClipboardFormats ( UINT  uFormat)

Definition at line 425 of file clipboard.c.

426 {
427  UINT Ret = 0;
428  PCLIP pElement;
429  PWINSTATION_OBJECT pWinStaObj;
430 
431  pWinStaObj = IntGetWinStaForCbAccess();
432  if (!pWinStaObj)
433  goto cleanup;
434 
435  /* Check if the clipboard has been opened */
436  if (!IntIsClipboardOpenByMe(pWinStaObj))
437  {
439  goto cleanup;
440  }
441 
442  if (fmt == 0)
443  {
444  /* Return first format */
445  if (pWinStaObj->pClipBase)
446  Ret = pWinStaObj->pClipBase[0].fmt;
447  }
448  else
449  {
450  /* Return next format */
451  pElement = IntGetFormatElement(pWinStaObj, fmt);
452  if (pElement != NULL)
453  {
454  ++pElement;
455  if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
456  {
457  Ret = pElement->fmt;
458  }
459  }
460  }
461 
462 cleanup:
463  if (pWinStaObj)
464  ObDereferenceObject(pWinStaObj);
465 
466  return Ret;
467 }
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UINT fmt
Definition: clipboard.h:5
Definition: clipboard.h:3
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:131
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
DWORD cNumClipFormats
Definition: winsta.h:32
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
unsigned int UINT
Definition: ndis.h:50
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtUserCallOneParam().

◆ UserOpenClipboard()

BOOL NTAPI UserOpenClipboard ( HWND  hWnd)

Definition at line 470 of file clipboard.c.

471 {
472  PWND pWindow = NULL;
473  BOOL bRet = FALSE;
474  PWINSTATION_OBJECT pWinStaObj = NULL;
475 
476  if (hWnd)
477  {
478  pWindow = UserGetWindowObject(hWnd);
479  if (!pWindow)
480  goto cleanup;
481  }
482 
483  pWinStaObj = IntGetWinStaForCbAccess();
484  if (!pWinStaObj)
485  goto cleanup;
486 
487  /* Check if we already opened the clipboard */
488  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
489  {
490  bRet = TRUE;
491  goto cleanup;
492  }
493 
494  /* If the clipboard was already opened by somebody else, bail out */
495  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
496  {
497  ERR("Access denied!\n");
499  goto cleanup;
500  }
501 
502  /* Open the clipboard */
503  pWinStaObj->spwndClipOpen = pWindow;
505  bRet = TRUE;
506 
507 cleanup:
508  if (pWinStaObj)
509  ObDereferenceObject(pWinStaObj);
510 
511  return bRet;
512 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipOpen
Definition: winsta.h:28
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:131
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserOpenClipboard(), and SnapWindow().

◆ UserSetClipboardData()

HANDLE NTAPI UserSetClipboardData ( UINT  fmt,
HANDLE  hData,
PSETCLIPBDATA  scd 
)

Definition at line 995 of file clipboard.c.

996 {
997  HANDLE hRet = NULL;
998  PWINSTATION_OBJECT pWinStaObj;
999 
1000  pWinStaObj = IntGetWinStaForCbAccess();
1001  if (!pWinStaObj)
1002  goto cleanup;
1003 
1004  if (!fmt || !pWinStaObj->ptiClipLock)
1005  {
1006  ERR("Access denied!\n");
1008  goto cleanup;
1009  }
1010 
1011  if (scd->fIncSerialNumber)
1012  pWinStaObj->iClipSerialNumber++;
1013 
1014  /* Is it a delayed rendering? */
1015  if (hData)
1016  {
1017  /* Is it a bitmap? */
1018  if (fmt == CF_BITMAP)
1019  {
1020  /* Make bitmap public */
1022  }
1023 
1024  /* Save data in the clipboard */
1025  IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE);
1026  TRACE("hData stored\n");
1027 
1028  /* If the serial number was increased, increase also the sequence number */
1029  if (scd->fIncSerialNumber)
1030  pWinStaObj->iClipSequenceNumber++;
1031 
1032  pWinStaObj->fClipboardChanged = TRUE;
1033 
1034  /* Note: Synthesized formats are added in NtUserCloseClipboard */
1035  }
1036  else
1037  {
1038  /* This is a delayed rendering */
1039  IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
1040  TRACE("SetClipboardData delayed format: %u\n", fmt);
1041  }
1042 
1043  /* Return hData on success */
1044  hRet = hData;
1045 
1046 cleanup:
1047  TRACE("NtUserSetClipboardData returns: %p\n", hRet);
1048 
1049  if (pWinStaObj)
1050  ObDereferenceObject(pWinStaObj);
1051 
1052  return hRet;
1053 }
INT fClipboardChanged
Definition: winsta.h:35
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
#define TRUE
Definition: types.h:120
#define DATA_DELAYED
Definition: clipboard.c:14
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
INT iClipSerialNumber
Definition: winsta.h:33
BOOL fGlobalHandle
Definition: ntuser.h:1117
#define CF_BITMAP
Definition: constants.h:397
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
static PCLIP NTAPI IntAddFormatedData(PWINSTATION_OBJECT pWinStaObj, UINT fmt, HANDLE hData, BOOLEAN fGlobalHandle, BOOL bEnd)
Definition: clipboard.c:79
#define ERR(fmt,...)
Definition: debug.h:109
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
BOOL fIncSerialNumber
Definition: ntuser.h:1118
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
INT iClipSequenceNumber
Definition: winsta.h:34
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserSetClipboardData(), and SnapWindow().