hw/xwin: Add controls for enabling/disabling monitoring of PRIMARY selection

xwinclip: Add -noprimary option
Xwin: Add -primary and -noprimary options and tray-menu control

v2:
Use Bool type for fPrimarySelection
Add -noprimary to usage message
Fix indentation in hw/xwin/winwndproc.c

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2013-09-24 15:09:22 +01:00
parent 851b504199
commit c03f9e23c2
11 changed files with 77 additions and 3 deletions

View File

@ -793,6 +793,10 @@ winUseMsg(void)
#ifdef XWIN_CLIPBOARD
ErrorF("-nounicodeclipboard\n"
"\tDo not use Unicode clipboard even if on a NT-based platform.\n");
ErrorF("-[no]primary\n"
"\tWhen clipboard integration is enabled, map the X11 PRIMARY selection\n"
"\tto the Windows clipboard. Default is enabled.\n");
#endif
ErrorF("-refresh rate_in_Hz\n"

View File

@ -93,6 +93,7 @@ BEGIN
POPUP "TRAYICON_MENU"
BEGIN
MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT
MENUITEM "Clipboard may use &PRIMARY selection", ID_APP_MONITOR_PRIMARY
MENUITEM "&About...", ID_APP_ABOUT
MENUITEM SEPARATOR
MENUITEM "E&xit...", ID_APP_EXIT

View File

@ -174,7 +174,7 @@ on remote hosts, when that information is available and it's useful to do so.
.SH OPTIONS CONTROLLING WINDOWS INTEGRATION
.TP 8
.B \-[no]clipboard
Enables [disables] the integration between the Cygwin/X clipboard and
Enables [disables] the integration between the X11 clipboard and
\fIWindows\fP clipboard. The default is enabled.
.TP 8
.B "\-emulate3buttons [\fItimeout\fP]"
@ -200,6 +200,10 @@ prevents the \fIWindows\fP mouse cursor from being drawn on top of the X
cursor.
This parameter has no effect unless \fB-swcursor\fP is also specified.
.TP 8
.B \-[no]primary
Clipboard integration may [will not] use the PRIMARY selection.
The default is enabled.
.TP 8
.B \-swcursor
Disable the usage of the \fIWindows\fP cursor and use the X11 software cursor instead.
.TP 8

View File

@ -33,4 +33,6 @@ void winFixClipboardChain(void);
void winClipboardWindowDestroy(void);
extern Bool fPrimarySelection;
#endif

View File

@ -44,11 +44,13 @@
#endif
#include <limits.h>
#include "internal.h"
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xfixes.h>
#include "winclipboard.h"
#include "internal.h"
/*
* Constants
*/
@ -63,6 +65,7 @@
*/
extern int xfixes_event_base;
Bool fPrimarySelection = TRUE;
/*
* Local variables
@ -793,7 +796,7 @@ winClipboardFlushXEvents(HWND hwnd,
winDebug("winClipboardFlushXEvents - XFixesSetSelectionOwnerNotify\n");
/* Save selection owners for monitored selections, ignore other selections */
if (e->selection == XA_PRIMARY) {
if ((e->selection == XA_PRIMARY) && fPrimarySelection) {
MonitorSelection(e, CLIP_OWN_PRIMARY);
}
else if (e->selection == atomClipboard) {

View File

@ -92,6 +92,13 @@ main (int argc, char *argv[])
continue;
}
/* Look for -noprimary */
if (!strcmp (argv[i], "-noprimary"))
{
fPrimarySelection = False;
continue;
}
/* Yack when we find a parameter that we don't know about */
printf ("Unknown parameter: %s\nExiting.\n", argv[i]);
exit (1);

View File

@ -29,6 +29,9 @@ Specifies the X server display to connect to.
.TP 8
.B \-nounicodeclipboard
Do not use unicode text on the clipboard.
.TP 8
.B \-noprimary
Do not monitor the PRIMARY selection.
.SH "SEE ALSO"
XWin(1)

View File

@ -37,6 +37,10 @@ from The Open Group.
#include "winmsg.h"
#include "winmonitors.h"
#ifdef XWIN_CLIPBOARD
#include "winclipboard/winclipboard.h"
#endif
/*
* Function prototypes
*/
@ -707,6 +711,26 @@ ddxProcessArgument(int argc, char *argv[], int i)
/* Indicate that we have processed this argument */
return 1;
}
/*
* Look for the '-primary' argument
*/
if (IS_OPTION("-primary")) {
fPrimarySelection = TRUE;
/* Indicate that we have processed this argument */
return 1;
}
/*
* Look for the '-noprimary' argument
*/
if (IS_OPTION("-noprimary")) {
fPrimarySelection = FALSE;
/* Indicate that we have processed this argument */
return 1;
}
#endif
/*

View File

@ -43,6 +43,7 @@
#define ID_APP_HIDE_ROOT 201
#define ID_APP_ALWAYS_ON_TOP 202
#define ID_APP_ABOUT 203
#define ID_APP_MONITOR_PRIMARY 204
#define ID_ABOUT_WEBSITE 303

View File

@ -32,9 +32,13 @@
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
#include <shellapi.h>
#include "winprefs.h"
#ifdef XWIN_CLIPBOARD
#include "winclipboard/winclipboard.h"
#endif
/*
* Initialize the tray icon
@ -170,6 +174,21 @@ winHandleIconMessage(HWND hwnd, UINT message,
RemoveMenu(hmenuTray, ID_APP_HIDE_ROOT, MF_BYCOMMAND);
}
#ifdef XWIN_CLIPBOARD
if (g_fClipboard) {
/* Set menu state to indicate if 'Monitor Primary' is enabled or not */
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE;
mii.fState = fPrimarySelection ? MFS_CHECKED : MFS_UNCHECKED;
SetMenuItemInfo(hmenuTray, ID_APP_MONITOR_PRIMARY, FALSE, &mii);
}
else {
/* Remove 'Monitor Primary' menu item */
RemoveMenu(hmenuTray, ID_APP_MONITOR_PRIMARY, MF_BYCOMMAND);
}
#endif
SetupRootMenu(hmenuTray);
/*

View File

@ -1218,6 +1218,12 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
#endif
#ifdef XWIN_CLIPBOARD
case ID_APP_MONITOR_PRIMARY:
fPrimarySelection = !fPrimarySelection;
return 0;
#endif
case ID_APP_ABOUT:
/* Display the About box */
winDisplayAboutDialog(s_pScreenPriv);