ReactOS  0.4.15-dev-3187-ge372f2b
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 414 of file clipboard.c.

415 {
416  PWINSTATION_OBJECT pWinStaObj;
417 
418  pWinStaObj = IntGetWinStaForCbAccess();
419  if (!pWinStaObj)
420  return;
421 
422  if (pWindow == pWinStaObj->spwndClipOwner)
423  {
424  /* The owner window was destroyed */
425  pWinStaObj->spwndClipOwner = NULL;
426  }
427 
428  /* Check if clipboard is not locked by this window, if yes, unlock it */
429  if (pWindow == pWinStaObj->spwndClipOpen)
430  {
431  /* The window that opens the clipboard was destroyed */
432  pWinStaObj->spwndClipOpen = NULL;
433  pWinStaObj->ptiClipLock = NULL;
434  }
435  /* Remove window from window chain */
436  if (pWindow == pWinStaObj->spwndClipViewer)
437  pWinStaObj->spwndClipViewer = NULL;
438 
439  ObDereferenceObject(pWinStaObj);
440 }
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define NULL
Definition: types.h:112
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  if (!pWindow)
379  return;
380 
381  pWinStaObj = IntGetWinStaForCbAccess();
382  if (!pWinStaObj)
383  return;
384 
386 
387  /* If the window being destroyed is the current clipboard owner... */
388  if (pWindow == pWinStaObj->spwndClipOwner)
389  {
390  /* ... make it release the clipboard */
391  pWinStaObj->spwndClipOwner = NULL;
392  }
393 
394  if (pWinStaObj->fClipboardChanged)
395  {
396  /* Add synthesized formats - they are rendered later */
397  IntAddSynthesizedFormats(pWinStaObj);
398 
399  /* Notify viewer windows in chain */
400  pWinStaObj->fClipboardChanged = FALSE;
401  if (pWinStaObj->spwndClipViewer)
402  {
403  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
404  // For 32-bit applications this message is sent as a notification
406  }
407  }
408 
409  ObDereferenceObject(pWinStaObj);
410 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define WM_RENDERALLFORMATS
Definition: winuser.h:1850
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipViewer
Definition: winsta.h:29
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:665
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1852
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
#define NULL
Definition: types.h:112
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by IntSendDestroyMsg().

◆ UserCloseClipboard()

BOOL NTAPI UserCloseClipboard ( VOID  )

Definition at line 545 of file clipboard.c.

546 {
547  BOOL bRet = FALSE;
548  PWINSTATION_OBJECT pWinStaObj;
549 
550  pWinStaObj = IntGetWinStaForCbAccess();
551  if (!pWinStaObj)
552  goto cleanup;
553 
554  /* Check if the clipboard has been opened */
555  if (!IntIsClipboardOpenByMe(pWinStaObj))
556  {
558  goto cleanup;
559  }
560 
561  /* Clipboard is no longer open */
562  pWinStaObj->spwndClipOpen = NULL;
563  pWinStaObj->ptiClipLock = NULL;
564  bRet = TRUE;
565 
566  if (pWinStaObj->fClipboardChanged)
567  {
568  /* Add synthesized formats - they are rendered later */
569  IntAddSynthesizedFormats(pWinStaObj);
570 
571  /* Notify viewer windows in chain */
572  pWinStaObj->fClipboardChanged = FALSE;
573  if (pWinStaObj->spwndClipViewer)
574  {
575  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
576  // For 32-bit applications this message is sent as a notification
578  }
579  }
580 
581 cleanup:
582  if (pWinStaObj)
583  ObDereferenceObject(pWinStaObj);
584 
585  return bRet;
586 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define TRUE
Definition: types.h:120
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:665
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1852
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
#define NULL
Definition: types.h:112
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 680 of file clipboard.c.

681 {
682  BOOL bRet = FALSE;
683  PWINSTATION_OBJECT pWinStaObj;
684 
685  pWinStaObj = IntGetWinStaForCbAccess();
686  if (!pWinStaObj)
687  return FALSE;
688 
689  /* Check if the clipboard has been opened */
690  if (!IntIsClipboardOpenByMe(pWinStaObj))
691  {
693  goto cleanup;
694  }
695 
696  UserEmptyClipboardData(pWinStaObj);
697 
698  if (pWinStaObj->spwndClipOwner)
699  {
700  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
701  // For 32-bit applications this message is sent as a notification
703  }
704 
705  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
706 
707  pWinStaObj->iClipSerialNumber++;
708  pWinStaObj->iClipSequenceNumber++;
709  pWinStaObj->fClipboardChanged = TRUE;
710  pWinStaObj->fInDelayedRendering = FALSE;
711 
712  bRet = TRUE;
713 
714 cleanup:
715  if (pWinStaObj)
716  ObDereferenceObject(pWinStaObj);
717 
718  return bRet;
719 }
INT fClipboardChanged
Definition: winsta.h:35
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:354
#define TRUE
Definition: types.h:120
INT fInDelayedRendering
Definition: winsta.h:36
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
INT iClipSerialNumber
Definition: winsta.h:33
THRDESKHEAD head
Definition: ntuser.h:665
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1851
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 443 of file clipboard.c.

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

489 {
490  PWND pWindow = NULL;
491  BOOL bRet = FALSE;
492  PWINSTATION_OBJECT pWinStaObj = NULL;
493 
494  if (hWnd)
495  {
496  pWindow = UserGetWindowObject(hWnd);
497  if (!pWindow)
498  goto cleanup;
499  }
500 
501  pWinStaObj = IntGetWinStaForCbAccess();
502  if (!pWinStaObj)
503  goto cleanup;
504 
505  /* Check if we already opened the clipboard */
506  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
507  {
508  bRet = TRUE;
509  goto cleanup;
510  }
511 
512  /* If the clipboard was already opened by somebody else, bail out */
513  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
514  {
515  ERR("Access denied!\n");
517  goto cleanup;
518  }
519 
520  /* Open the clipboard */
521  pWinStaObj->spwndClipOpen = pWindow;
523  bRet = TRUE;
524 
525 cleanup:
526  if (pWinStaObj)
527  ObDereferenceObject(pWinStaObj);
528 
529  return bRet;
530 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:663
#define NULL
Definition: types.h:112
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 1023 of file clipboard.c.

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