1038_merged_head.patch

Naush, 10/15/2010 09:41 pm

Download (16.9 kB)

b/code/nel/include/nel/3d/driver.h Fri Oct 15 21:33:52 2010 +0200
1215 1215
	// get the number of call to swapBuffer since the driver was created
1216 1216
	virtual uint64			getSwapBufferCounter() const = 0;
1217 1217

1218
	virtual bool copyTextToClipboard(const ucstring &text) = 0;
1219

1220
	virtual bool pasteTextFromClipboard(ucstring &text) = 0;
1221

1218 1222
	/** Set cull mode
1219 1223
	  * Useful for mirrors / cube map rendering or when the scene must be rendered upside down
1220 1224
	  */
b/code/nel/include/nel/3d/driver_user.h Fri Oct 15 21:33:52 2010 +0200
535 535
	virtual void		  deleteWaterEnvMap(UWaterEnvMap *map);
536 536
	// @}
537 537

538
	virtual bool copyTextToClipboard(const ucstring &text);
539

540
	virtual bool pasteTextFromClipboard(ucstring &text);
538 541

539 542
	virtual uint64	getSwapBufferCounter();
540 543

b/code/nel/include/nel/3d/u_driver.h Fri Oct 15 21:33:52 2010 +0200
816 816

817 817
	virtual uint64	getSwapBufferCounter() = 0;
818 818

819
	virtual bool copyTextToClipboard(const ucstring &text) =0;
820

821
	virtual bool pasteTextFromClipboard(ucstring &text) =0;
822

819 823
public:
820 824

821 825
	/**
b/code/nel/include/nel/misc/event_emitter_multi.h Fri Oct 15 21:33:52 2010 +0200
48 48
	/// From IEventEmitter. This call submitEvents on all the emitters
49 49
	virtual void submitEvents(CEventServer &server, bool allWindows);
50 50
	virtual void emulateMouseRawMode(bool enable);
51
	virtual bool copyTextToClipboard(const ucstring &text);
52

53
	virtual bool pasteTextFromClipboard(ucstring &text);
51 54
private:
52 55
	typedef std::vector<std::pair<IEventEmitter *, bool> > TEmitterCont;
53 56
	TEmitterCont	_Emitters;
b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp Fri Oct 15 21:33:52 2010 +0200
292 292

293 293
	_SumTextureMemoryUsed = false;
294 294

295

296 295
	_DesktopGammaRampValid = false;
296
	// initialize COM
297
	HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
297 298
}
298 299

299 300
// ***************************************************************************
......
3831 3832
		}
3832 3833
	}
3833 3834
}
3834

3835
bool CDriverD3D::copyTextToClipboard(const ucstring &text)
3836
{
3837
	return _EventEmitter.copyTextToClipboard(text);
3838
}
3839

3840
bool CDriverD3D::pasteTextFromClipboard(ucstring &text)
3841
{
3842
	return _EventEmitter.pasteTextFromClipboard(text);
3843
}
3835 3844
} // NL3D
b/code/nel/src/3d/driver/direct3d/driver_direct3d.h Fri Oct 15 21:33:52 2010 +0200
2392 2392
	void deleteIndexBuffer(CIBDrvInfosD3D *ib);
2393 2393
	// Build 16 bit index buffer for quad
2394 2394
	bool buildQuadIndexBuffer();
2395
	virtual bool copyTextToClipboard(const ucstring &text);
2396

2397
	virtual bool pasteTextFromClipboard(ucstring &text);
2398

2395 2399
public:
2396 2400
	#ifdef 	NL_DEBUG
2397 2401
		std::set<CVBDrvInfosD3D *> _LockedBuffers;
b/code/nel/src/3d/driver/opengl/driver_opengl.cpp Fri Oct 15 21:33:52 2010 +0200
322 322

323 323
	_TextureTargetCubeFace = 0;
324 324
	_TextureTargetUpload = false;
325
#ifdef NL_OS_WINDOWS
326
	// initialize COM
327
	HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
328
#endif
325 329
}
326 330

327 331
// ***************************************************************************
......
2704 2708
{
2705 2709
}
2706 2710

2711
bool CDriverGL::copyTextToClipboard(const ucstring &text)
2712
{
2713
	return _EventEmitter.copyTextToClipboard(text);
2714
}
2715

2716
bool CDriverGL::pasteTextFromClipboard(ucstring &text)
2717
{
2718
	return _EventEmitter.pasteTextFromClipboard(text);
2719
}
2720

2707 2721
} // NL3D
2708 2722

2709 2723
// ***************************************************************************
b/code/nel/src/3d/driver/opengl/driver_opengl.h Fri Oct 15 21:33:52 2010 +0200
325 325
	{
326 326
		return _win;
327 327
	}
328
	virtual bool copyTextToClipboard(const ucstring &text);
329

330
	virtual bool pasteTextFromClipboard(ucstring &text);
328 331

329 332
	virtual uint32			getAvailableVertexAGPMemory ();
330 333
	virtual uint32			getAvailableVertexVRAMMemory ();
b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp Fri Oct 15 21:33:52 2010 +0200
32 32
	// just forwarding to our cocoa adapter
33 33
	NL3D::MAC::emulateMouseRawMode(enable);
34 34
}
35
bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text)
36
{
37
	return false;
38
}
39
bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text)
40
{
41
	return false;
42
}
35 43

36 44
}
b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h Fri Oct 15 21:33:52 2010 +0200
27 27
public:
28 28
	virtual void submitEvents(CEventServer & server, bool allWindows);
29 29
	virtual void emulateMouseRawMode(bool enable);
30
};
30
	/**
31
	 *
32
	 */
33
	virtual bool copyTextToClipboard(const ucstring &text);
31 34
	
35
	/*
36
	 *
37
	 */
38
	virtual bool pasteTextFromClipboard(ucstring &text);};
32 39
}
33 40

34 41
#endif
b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp Fri Oct 15 21:33:52 2010 +0200
19 19

20 20
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
21 21

22
#include <X11/Xlib.h> 
23
#include <X11/Xatom.h>
22 24
#include <X11/keysym.h>
23 25
#include <GL/gl.h>
24 26
#include <GL/glx.h>
......
33 35
{
34 36
	_im = 0;
35 37
	_ic = 0;
38
	_SelectionOwned=false;
36 39
}
37 40

38 41
CUnixEventEmitter::~CUnixEventEmitter()
......
47 50
	_win = win;
48 51
	_driver = driver;
49 52

50
	XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask);
53
	XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask);
54
	_PrecomputedAtom[0] = XInternAtom(dpy, "CLIPBOARD",False);
55
	#define XA_CLIPBOARD _PrecomputedAtom[0]
56
	_PrecomputedAtom[1] = XInternAtom(dpy, "UTF8_STRING",False);
57
	#define XA_UTF8_STRING _PrecomputedAtom[1]
58
	_PrecomputedAtom[2] = XInternAtom(dpy, "TARGETS",False);
59
	#define XA_TARGETS _PrecomputedAtom[2]
60
	_PrecomputedAtom[3] = XInternAtom(dpy, "ATOM",False);
61
	//#define XA_ATOM _PrecomputedAtom[3]
62
	_PrecomputedAtom[4] = XInternAtom(dpy, "NeL_SEL",False);
63
	#define XA_NEL_SEL _PrecomputedAtom[4]
64
	_PrecomputedAtom[5] = XInternAtom(dpy, "TEXT",False);
65
	#define XA_TEXT _PrecomputedAtom[5]
51 66

52 67
/*
53 68
	TODO: implements all useful events processing
54 69
	EnterWindowMask|LeaveWindowMask|ButtonMotionMask|Button1MotionMask|Button2MotionMask|
55
	Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|ExposureMask|
70
	Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|
56 71
	SubstructureNotifyMask|VisibilityChangeMask|FocusChangeMask|PropertyChangeMask|
57 72
	ColormapChangeMask|OwnerGrabButtonMask
58 73
*/
......
578 593
		}
579 594
		break;
580 595
	}
596
	case SelectionRequest:
597
	{
598
		XEvent respond;
599
		XSelectionRequestEvent *req=&(event.xselectionrequest);
600

601
		respond.xselection.type= SelectionNotify;
602
		respond.xselection.display= req->display;
603
		respond.xselection.requestor= req->requestor;
604
		respond.xselection.selection=req->selection;
605
		respond.xselection.target= req->target;
606
		respond.xselection.time = req->time;
607
		respond.xselection.property = req->property;
608
		if (req->property == None)
609
		{
610
			respond.xselection.property=req->target;
611
		}
612
		if (req->target == XA_TARGETS)
613
		{
614
			nlwarning("Client is asking for TARGETS");
615
			Atom targets[] = {
616
				  XA_TARGETS
617
				, XA_TEXT
618
				, XA_UTF8_STRING
619
			};
620
			respond.xselection.property = req->property;
621

622
			XChangeProperty(req->display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char *)targets, 3 /* number of element */);
623
		}
624
		else if (req->target == XInternAtom(_dpy, "TEXT", False) || req->target == XA_STRING )
625
		{
626
			nlwarning("client want TEXT");
627
			respond.xselection.property=req->property;
628
			std::string str=_CopiedString.toString();
629
			XChangeProperty(req->display, req->requestor, req->property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), strlen(str.c_str()));
630
		}
631
		else if (req->target == XInternAtom(_dpy, "UTF8_STRING", False))
632
		{
633
			nlwarning("Client want UTF8 STRING");
634
			respond.xselection.property=req->property;
635
			std::string str=_CopiedString.toUtf8();
636
			XChangeProperty(req->display, req->requestor, respond.xselection.property, XInternAtom(_dpy, "UTF8_STRING", False), 8, PropModeReplace, (const unsigned char*)str.c_str(), strlen((char*)str.c_str()));
637
		}
638
		else
639
		{
640
			nlwarning("Target doesn't want a string %u",req->target); // Note: Calling XGetAtomName with arbitrary value crash the client, maybe req->target have been sanitized by X11 server
641
			respond.xselection.property= None;
642
		}
643
		XSendEvent (_dpy, req->requestor,0,0,&respond);
644
		break;
645
	}
646
	case SelectionClear:
647
		nlwarning("SelectionClear:");
648
		_SelectionOwned=false;
649
		_CopiedString="";
650
		break;
581 651
	case FocusIn:
582 652
		// keyboard focus
583 653
		if (_ic) XSetICFocus(_ic);
......
605 675
	return true;
606 676
}
607 677

678
/**
679
 * This function copy a selection into propertyName.
680
 * It is subject to timeout.
681
 *
682
 * @param selection: A Selection Atom
683
 * @param requestedFormat: Target format Atom
684
 * @param propertyName: Target property Atom
685
 * @return true if successfull, false if timeout occured or X11 call failed
686
 */
687
bool CUnixEventEmitter::prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName)
688
{
689
	XConvertSelection(_dpy, selection, requestedFormat, propertyName, _win, CurrentTime);
690
	XSync (_dpy, False);
691
	int i=0;
692
	bool gotReply=false;
693
	do {
694
		XEvent event;
695
		usleep(500);
696
		gotReply = XCheckTypedWindowEvent(_dpy, _win, SelectionNotify, &event);
697
		if (gotReply)
698
		{
699
			return true;
700
		}
701
		i++;
702
	} while (i<20);
703
	return false;
704
}
705

706
bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text)
707
{
708
	_CopiedString=text;
709
	XSetSelectionOwner (_dpy,  XA_CLIPBOARD, _win, CurrentTime);
710
	{
711
		Window selectionOwner=XGetSelectionOwner (_dpy, XA_CLIPBOARD);
712
		if ( selectionOwner != _win )
713
		{
714
			nlwarning("Can't aquire selection");
715
			return false;
716
		}
717
		_SelectionOwned=true;
718
		nlwarning("Owning selection");
719
		return true;
720
	}
721
	nlwarning("Paste: Can't acquire selection.");
722
	return false;
723
}
724

725
bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text)
726
{
727
	// check if we own the selection
728
	if (_SelectionOwned)
729
	{
730
		text=_CopiedString;
731
		return true;
732
	}
733
	Window selectionOwner=XGetSelectionOwner (_dpy, XA_CLIPBOARD);
734
	if (selectionOwner!=None)
735
	{
736
		Atom *supportedTargets, type;
737
		uint8 *data;
738
		int result;
739
		unsigned long nitems, bytesLeft;
740
		Atom actualType;
741
		int  actualFormat;
742
		int bestTargetElect=0, bestTarget=0;
743
		nlwarning("Selection owner is %u",selectionOwner);
744

745
		// Find supported methods
746
		bool bres=prepareSelectionContent(XA_CLIPBOARD, XA_TARGETS, XA_NEL_SEL);
747
		if (!bres)
748
		{
749
			nlwarning("Paste: Cannot ennumerate TARGETS");
750
			return false;
751
		}
752
		result=XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &supportedTargets);
753
		if (result != Success)
754
		{
755
			return false;
756
		}
757
		if ( bytesLeft>0 )
758
		{
759
			nlwarning("Paste: Supported TARGETS list too long."); // We hope we find what we need in the first packet.
760
		}
761
		// Elect best type
762
		for (unsigned int i=0; i < nitems; i++)
763
		{
764
			nldebug(" - Type=%s", XGetAtomName(_dpy, supportedTargets[i]));
765
			if (supportedTargets[i] == XA_STRING )
766
			{
767
				if (bestTargetElect < 1)
768
				{
769
					bestTarget=XA_STRING;
770
					bestTargetElect=1;
771
				}
772
			}
773
			if (supportedTargets[i] == XA_UTF8_STRING )
774
			{
775
				if (bestTargetElect < 2)
776
				{
777
					bestTarget=XA_STRING;
778
					bestTargetElect=2;
779
				}
780
			}
781
		}
782
		XFree(supportedTargets);
783
		if (!bestTargetElect)
784
		{
785
			nlwarning("Paste buffer is not a text buffer.");
786
			return false;
787
		}
788
		
789
		// Ask for selection lenght && copy to buffer
790
		bres=prepareSelectionContent(XA_CLIPBOARD, bestTarget, XA_NEL_SEL);
791
		if (!bres)
792
		{
793
			nlwarning ("Paste: cannot obtain data. Aborting.");
794
			return false;
795
		}
796
		XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &data);
797
		switch (bestTargetElect)
798
		{
799
			case 1: // XA_STRING
800
				text=(const char*)data;
801
				XFree(data);
802
				return true;
803
			break;
804
			case 2:
805
				text=ucstring::makeFromUtf8((const char*)data);
806
				XFree(data);
807
				return true;
808
			default:
809
				break;
810
		}
811
		nlwarning("Paste: buffer is not a text buffer.");
812
	}
813
	nlwarning("Paste: error !");
814
	return false;
815
}
816

817

608 818
} // NLMISC
609 819

610 820
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
b/code/nel/src/3d/driver/opengl/unix_event_emitter.h Fri Oct 15 21:33:52 2010 +0200
65 65
	 */
66 66
	bool processMessage(XEvent &event, CEventServer *server = NULL);
67 67

68
	/**
69
	 *
70
	 */
71
        virtual bool copyTextToClipboard(const ucstring &text);
72

73
	/*
74
	 *
75
	 */
76
	virtual bool pasteTextFromClipboard(ucstring &text);
77

68 78
private:
69 79

70 80
	// Private internal server message
......
88 98
	};
89 99

90 100
	void createIM();
101
	bool prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName);
91 102

92 103
	Display*				_dpy;
93 104
	Window					_win;
......
97 108
	bool					_emulateRawMode;
98 109
	NL3D::IDriver*			_driver;
99 110
	CUnixEventServer		_InternalServer;
111
	ucstring		_CopiedString;
112
	Atom			_PrecomputedAtom[6];
113
	bool			_SelectionOwned;
100 114
};
101 115

102 116

b/code/nel/src/3d/driver_user.cpp Fri Oct 15 21:33:52 2010 +0200
1938 1938

1939 1939
	return result;
1940 1940
}
1941
bool CDriverUser::copyTextToClipboard(const ucstring &text)
1942
{
1943
	return _Driver->copyTextToClipboard(text);
1944
}
1945

1946
bool CDriverUser::pasteTextFromClipboard(ucstring &text)
1947
{
1948
	return _Driver->pasteTextFromClipboard(text);
1949
}
1950

1941 1951

1942 1952
} // NL3D
b/code/nel/src/misc/event_emitter_multi.cpp Fri Oct 15 21:33:52 2010 +0200
16 16

17 17
#include "stdmisc.h"
18 18
#include "nel/misc/event_emitter_multi.h"
19

19
#include "nel/misc/system_utils.h"
20 20

21 21
namespace NLMISC
22 22
{
......
99 99
	return _Emitters[index].first;
100 100
}
101 101

102

102
bool CEventEmitterMulti::copyTextToClipboard(const ucstring &text)
103
{
104
	// Naush: wrapped to old API to avoid duplicate code
105
	return CSystemUtils::copyTextToClipboard(text);
106
}
107
bool CEventEmitterMulti::pasteTextFromClipboard(ucstring &text)
108
{
109
	// Naush: wrapped to old API to avoid duplicate code
110
	return CSystemUtils::pasteTextFromClipboard(text);
111
}
103 112

104 113

105 114
} // NLMISC
b/code/ryzom/client/src/interface_v3/group_editbox.cpp Fri Oct 15 21:33:52 2010 +0200
332 332
	stopParentBlink();
333 333

334 334
	// get the selection and copy it
335
	if (CSystemUtils::copyTextToClipboard(getSelection()))
335
	if (Driver->copyTextToClipboard(getSelection()))
336 336
		nlinfo ("Chat input was copied in the clipboard");
337 337
}
338 338

......
351 351
	makeTopWindow();
352 352

353 353
	ucstring sString;
354

355
	if (CSystemUtils::pasteTextFromClipboard(sString))
354
	if (Driver->pasteTextFromClipboard(sString))
356 355
	{
357 356
		sint length = (sint)sString.length();
358 357