ReactOS  0.4.14-dev-49-gfb4591c
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 411 of file clipboard.c.

412 {
413  PWINSTATION_OBJECT pWinStaObj;
414 
415  pWinStaObj = IntGetWinStaForCbAccess();
416  if (!pWinStaObj)
417  return;
418 
419  if (pWindow == pWinStaObj->spwndClipOwner)
420  {
421  /* The owner window was destroyed */
422  pWinStaObj->spwndClipOwner = NULL;
423  }
424 
425  /* Check if clipboard is not locked by this window, if yes, unlock it */
426  if (pWindow == pWinStaObj->spwndClipOpen)
427  {
428  /* The window that opens the clipboard was destroyed */
429  pWinStaObj->spwndClipOpen = NULL;
430  pWinStaObj->ptiClipLock = NULL;
431  }
432  /* Remove window from window chain */
433  if (pWindow == pWinStaObj->spwndClipViewer)
434  pWinStaObj->spwndClipViewer = NULL;
435 
436  ObDereferenceObject(pWinStaObj);
437 }
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 374 of file clipboard.c.

375 {
376  PWINSTATION_OBJECT pWinStaObj;
377 
378  pWinStaObj = IntGetWinStaForCbAccess();
379  if (!pWinStaObj)
380  return;
381 
383 
384  /* If the window being destroyed is the current clipboard owner... */
385  if (pWindow == pWinStaObj->spwndClipOwner)
386  {
387  /* ... make it release the clipboard */
388  pWinStaObj->spwndClipOwner = NULL;
389  }
390 
391  if (pWinStaObj->fClipboardChanged)
392  {
393  /* Add synthesized formats - they are rendered later */
394  IntAddSynthesizedFormats(pWinStaObj);
395 
396  /* Notify viewer windows in chain */
397  pWinStaObj->fClipboardChanged = FALSE;
398  if (pWinStaObj->spwndClipViewer)
399  {
400  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
401  // For 32-bit applications this message is sent as a notification
403  }
404  }
405 
406  ObDereferenceObject(pWinStaObj);
407 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define WM_RENDERALLFORMATS
Definition: winuser.h:1849
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:1851
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 542 of file clipboard.c.

543 {
544  BOOL bRet = FALSE;
545  PWINSTATION_OBJECT pWinStaObj;
546 
547  pWinStaObj = IntGetWinStaForCbAccess();
548  if (!pWinStaObj)
549  goto cleanup;
550 
551  /* Check if the clipboard has been opened */
552  if (!IntIsClipboardOpenByMe(pWinStaObj))
553  {
555  goto cleanup;
556  }
557 
558  /* Clipboard is no longer open */
559  pWinStaObj->spwndClipOpen = NULL;
560  pWinStaObj->ptiClipLock = NULL;
561  bRet = TRUE;
562 
563  if (pWinStaObj->fClipboardChanged)
564  {
565  /* Add synthesized formats - they are rendered later */
566  IntAddSynthesizedFormats(pWinStaObj);
567 
568  /* Notify viewer windows in chain */
569  pWinStaObj->fClipboardChanged = FALSE;
570  if (pWinStaObj->spwndClipViewer)
571  {
572  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
573  // For 32-bit applications this message is sent as a notification
575  }
576  }
577 
578 cleanup:
579  if (pWinStaObj)
580  ObDereferenceObject(pWinStaObj);
581 
582  return bRet;
583 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
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:136
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:1851
#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 677 of file clipboard.c.

678 {
679  BOOL bRet = FALSE;
680  PWINSTATION_OBJECT pWinStaObj;
681 
682  pWinStaObj = IntGetWinStaForCbAccess();
683  if (!pWinStaObj)
684  return FALSE;
685 
686  /* Check if the clipboard has been opened */
687  if (!IntIsClipboardOpenByMe(pWinStaObj))
688  {
690  goto cleanup;
691  }
692 
693  UserEmptyClipboardData(pWinStaObj);
694 
695  if (pWinStaObj->spwndClipOwner)
696  {
697  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
698  // For 32-bit applications this message is sent as a notification
700  }
701 
702  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
703 
704  pWinStaObj->iClipSerialNumber++;
705  pWinStaObj->iClipSequenceNumber++;
706  pWinStaObj->fClipboardChanged = TRUE;
707  pWinStaObj->fInDelayedRendering = FALSE;
708 
709  bRet = TRUE;
710 
711 cleanup:
712  if (pWinStaObj)
713  ObDereferenceObject(pWinStaObj);
714 
715  return bRet;
716 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:354
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:136
#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:1850
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 440 of file clipboard.c.

441 {
442  UINT Ret = 0;
443  PCLIP pElement;
444  PWINSTATION_OBJECT pWinStaObj;
445 
446  pWinStaObj = IntGetWinStaForCbAccess();
447  if (!pWinStaObj)
448  goto cleanup;
449 
450  /* Check if the clipboard has been opened */
451  if (!IntIsClipboardOpenByMe(pWinStaObj))
452  {
454  goto cleanup;
455  }
456 
457  if (fmt == 0)
458  {
459  /* Return first format */
460  if (pWinStaObj->pClipBase)
461  Ret = pWinStaObj->pClipBase[0].fmt;
462  }
463  else
464  {
465  /* Return next format */
466  pElement = IntGetFormatElement(pWinStaObj, fmt);
467  if (pElement != NULL)
468  {
469  ++pElement;
470  if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
471  {
472  Ret = pElement->fmt;
473  }
474  }
475  }
476 
477 cleanup:
478  if (pWinStaObj)
479  ObDereferenceObject(pWinStaObj);
480 
481  return Ret;
482 }
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:136
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 485 of file clipboard.c.

486 {
487  PWND pWindow = NULL;
488  BOOL bRet = FALSE;
489  PWINSTATION_OBJECT pWinStaObj = NULL;
490 
491  if (hWnd)
492  {
493  pWindow = UserGetWindowObject(hWnd);
494  if (!pWindow)
495  goto cleanup;
496  }
497 
498  pWinStaObj = IntGetWinStaForCbAccess();
499  if (!pWinStaObj)
500  goto cleanup;
501 
502  /* Check if we already opened the clipboard */
503  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
504  {
505  bRet = TRUE;
506  goto cleanup;
507  }
508 
509  /* If the clipboard was already opened by somebody else, bail out */
510  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
511  {
512  ERR("Access denied!\n");
514  goto cleanup;
515  }
516 
517  /* Open the clipboard */
518  pWinStaObj->spwndClipOpen = pWindow;
520  bRet = TRUE;
521 
522 cleanup:
523  if (pWinStaObj)
524  ObDereferenceObject(pWinStaObj);
525 
526  return bRet;
527 }
#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:136
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 1020 of file clipboard.c.

1021 {
1022  HANDLE hRet = NULL;
1023  PWINSTATION_OBJECT pWinStaObj;
1024 
1025  pWinStaObj = IntGetWinStaForCbAccess();
1026  if (!pWinStaObj)
1027  goto cleanup;
1028 
1029  if (!fmt || !pWinStaObj->ptiClipLock)
1030  {
1031  ERR("Access denied!\n");
1033  goto cleanup;
1034  }
1035 
1036  if (scd->fIncSerialNumber)
1037  pWinStaObj->iClipSerialNumber++;
1038 
1039  /* Is it a delayed rendering? */
1040  if (hData)
1041  {
1042  /* Is it a bitmap? */
1043  if (fmt == CF_BITMAP)
1044  {
1045  /* Make bitmap public */
1047  }
1048 
1049  /* Save data in the clipboard */
1050  IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE);
1051  TRACE("hData stored\n");
1052 
1053  /* If the serial number was increased, increase also the sequence number */
1054  if (scd->fIncSerialNumber)
1055  pWinStaObj->iClipSequenceNumber++;
1056 
1057  pWinStaObj->fClipboardChanged = TRUE;
1058 
1059  /* Note: Synthesized formats are added in NtUserCloseClipboard */
1060  }
1061  else
1062  {
1063  /* This is a delayed rendering */
1064  IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
1065  TRACE("SetClipboardData delayed format: %u\n", fmt);
1066  }
1067 
1068  /* Return hData on success */
1069  hRet = hData;
1070 
1071 cleanup:
1072  TRACE("NtUserSetClipboardData returns: %p\n", hRet);
1073 
1074  if (pWinStaObj)
1075  ObDereferenceObject(pWinStaObj);
1076 
1077  return hRet;
1078 }
INT fClipboardChanged
Definition: winsta.h:35
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1252
#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:84
#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().