From 333e49d78bf84dd04c39485c3ef1b33754b12890 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Thu, 21 Apr 2005 17:31:50 +0000
Subject: [PATCH] Moved the UsePrimary config parameter to the x11drv section,
 renamed as UsePrimarySelection.

---
 dlls/x11drv/clipboard.c      | 21 ++++-----------------
 dlls/x11drv/x11drv.h         |  1 +
 dlls/x11drv/x11drv_main.c    |  4 ++++
 documentation/samples/config |  5 ++---
 4 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/dlls/x11drv/clipboard.c b/dlls/x11drv/clipboard.c
index fc81622b8c0..69974dd2ce0 100644
--- a/dlls/x11drv/clipboard.c
+++ b/dlls/x11drv/clipboard.c
@@ -138,7 +138,6 @@ typedef struct tagWINE_CLIPFORMAT {
 
 static int selectionAcquired = 0;              /* Contains the current selection masks */
 static Window selectionWindow = None;          /* The top level X window which owns the selection */
-static BOOL usePrimary = FALSE;                /* Use primary selection in additon to the clipboard selection */
 static Atom selectionCacheSrc = XA_PRIMARY;    /* The selection source from which the clipboard cache was filled */
 
 INT X11DRV_RegisterClipboardFormat(LPCWSTR FormatName);
@@ -315,8 +314,6 @@ static UINT ClipDataCount = 0;
  */
 static UINT wSeqNo = 0;
 
-#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
-
 /**************************************************************************
  *                Internal Clipboard implementation methods
  **************************************************************************/
@@ -347,16 +344,6 @@ static Window thread_selection_wnd(void)
 void X11DRV_InitClipboard(void)
 {
     UINT i;
-    HKEY hkey;
-
-    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Clipboard", &hkey))
-    {
-	char buffer[20];
-	DWORD type, count = sizeof(buffer);
-        if(!RegQueryValueExA(hkey, "UsePrimary", 0, &type, buffer, &count))
-            usePrimary = IS_OPTION_TRUE( buffer[0] );
-        RegCloseKey(hkey);
-    }
 
     /* Register known mapping between window formats and X properties */
     for (i = 0; i < sizeof(PropertyFormatMap)/sizeof(PropertyFormatMap[0]); i++)
@@ -1652,11 +1639,11 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
      * Query the selection owner for the TARGETS property
      */
     wine_tsx11_lock();
-    if ((usePrimary && XGetSelectionOwner(display,XA_PRIMARY)) ||
+    if ((use_primary_selection && XGetSelectionOwner(display,XA_PRIMARY)) ||
         XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
     {
         wine_tsx11_unlock();
-        if (usePrimary && (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, x11drv_atom(TARGETS), &xe)))
+        if (use_primary_selection && (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, x11drv_atom(TARGETS), &xe)))
             selectionCacheSrc = XA_PRIMARY;
         else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), x11drv_atom(TARGETS), &xe))
             selectionCacheSrc = x11drv_atom(CLIPBOARD);
@@ -2163,14 +2150,14 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
 
         wine_tsx11_lock();
         /* Grab PRIMARY selection if not owned */
-        if (usePrimary && !(selectionAcquired & S_PRIMARY))
+        if (use_primary_selection && !(selectionAcquired & S_PRIMARY))
             XSetSelectionOwner(display, XA_PRIMARY, owner, CurrentTime);
 
         /* Grab CLIPBOARD selection if not owned */
         if (!(selectionAcquired & S_CLIPBOARD))
             XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), owner, CurrentTime);
 
-        if (usePrimary && XGetSelectionOwner(display,XA_PRIMARY) == owner)
+        if (use_primary_selection && XGetSelectionOwner(display,XA_PRIMARY) == owner)
 	    selectionAcquired |= S_PRIMARY;
 
         if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h
index 4d0f761f6b5..df960fa96f3 100644
--- a/dlls/x11drv/x11drv.h
+++ b/dlls/x11drv/x11drv.h
@@ -536,6 +536,7 @@ extern unsigned int screen_depth;
 extern unsigned int text_caps;
 extern int use_xkb;
 extern int use_take_focus;
+extern int use_primary_selection;
 extern int managed_mode;
 
 extern BYTE key_state_table[256];
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index 4615f82e120..a66af96e4ac 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -74,6 +74,7 @@ int usexvidmode = 0;
 int usexrandr = 1;
 int use_xkb = 1;
 int use_take_focus = 1;
+int use_primary_selection = 0;
 int managed_mode = 1;
 int client_side_with_core = 1;
 int client_side_with_render = 1;
@@ -270,6 +271,9 @@ static void setup_options(void)
     if (!get_config_key( hkey, appkey, "UseTakeFocus", buffer, sizeof(buffer) ))
         use_take_focus = IS_OPTION_TRUE( buffer[0] );
 
+    if (!get_config_key( hkey, appkey, "UsePrimarySelection", buffer, sizeof(buffer) ))
+        use_primary_selection = IS_OPTION_TRUE( buffer[0] );
+
     screen_depth = 0;
     if (!get_config_key( hkey, appkey, "ScreenDepth", buffer, sizeof(buffer) ))
         screen_depth = atoi(buffer);
diff --git a/documentation/samples/config b/documentation/samples/config
index dbe30f280bf..b2f5f3855d3 100644
--- a/documentation/samples/config
+++ b/documentation/samples/config
@@ -66,6 +66,8 @@ WINE REGISTRY Version 2
 "UseXRandR" = "Y"
 ; Use the take focus protocol
 "UseTakeFocus" = "Y"
+; Use primary selection in addition to clipboard
+"UsePrimarySelection" = "N"
 ; Enable DirectX mouse grab
 "DXGrab" = "N"
 ; Create the desktop window with a double-buffered visual
@@ -138,9 +140,6 @@ WINE REGISTRY Version 2
 ;"SnoopExclude" = "RtlEnterCriticalSection;RtlLeaveCriticalSection"
 ;"SpyExclude" = "WM_SIZE;WM_TIMER;"
 
-[Clipboard]
-"UsePrimary" = "0"
-
 ; List of all directories directly contain .AFM files
 [afmdirs]
 "1" = "/usr/share/ghostscript/fonts"
-- 
GitLab