|
|
@@ -53,6 +53,16 @@
|
|
|
void put_scrap(int type, int srclen, const char *src);
|
|
|
void get_scrap(int type, int *dstlen, char **dst);
|
|
|
// end SDL scrap
|
|
|
+
|
|
|
+// X11 cursor
|
|
|
+#include <X11/cursorfont.h>
|
|
|
+
|
|
|
+namespace {
|
|
|
+ void set_cursor(int cursorType);
|
|
|
+ void free_cursors();
|
|
|
+} // namespace
|
|
|
+// end X11 cursor
|
|
|
+
|
|
|
#endif
|
|
|
|
|
|
using namespace Polycode;
|
|
|
@@ -111,11 +121,13 @@ SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool
|
|
|
SDL_JoystickOpen(i);
|
|
|
input->addJoystick(i);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+#ifdef USE_X11
|
|
|
// Start listening to clipboard events.
|
|
|
// (Yes on X11 you need to actively listen to
|
|
|
// clipboard events and respond to them)
|
|
|
init_scrap();
|
|
|
+#endif // USE_X11
|
|
|
|
|
|
((OpenGLRenderer*)renderer)->Init();
|
|
|
CoreServices::getInstance()->installModule(new GLSLShaderModule());
|
|
|
@@ -184,6 +196,9 @@ vector<Polycode::Rectangle> SDLCore::getVideoModes() {
|
|
|
}
|
|
|
|
|
|
SDLCore::~SDLCore() {
|
|
|
+#ifdef USE_X11
|
|
|
+ free_cursors();
|
|
|
+#endif // USE_X11
|
|
|
SDL_Quit();
|
|
|
}
|
|
|
|
|
|
@@ -396,7 +411,9 @@ bool SDLCore::Update() {
|
|
|
}
|
|
|
|
|
|
void SDLCore::setCursor(int cursorType) {
|
|
|
-
|
|
|
+#ifdef USE_X11
|
|
|
+ set_cursor(cursorType);
|
|
|
+#endif // USE_X11
|
|
|
}
|
|
|
|
|
|
void SDLCore::warpCursor(int x, int y) {
|
|
|
@@ -446,7 +463,7 @@ void SDLCore::copyDiskItem(const String& itemPath, const String& destItemPath) {
|
|
|
int childExitStatus;
|
|
|
pid_t pid = fork();
|
|
|
if (pid == 0) {
|
|
|
- execl("/bin/cp", "/bin/cp", "-R", itemPath.c_str(), destItemPath.c_str(), (char *)0);
|
|
|
+ execl("/bin/cp", "/bin/cp", "-RT", itemPath.c_str(), destItemPath.c_str(), (char *)0);
|
|
|
} else {
|
|
|
pid_t ws = waitpid( pid, &childExitStatus, 0);
|
|
|
}
|
|
|
@@ -860,4 +877,69 @@ PRIVATE int clipboard_filter(const SDL_Event *event)
|
|
|
return(1);
|
|
|
}
|
|
|
|
|
|
+// X11 cursor
|
|
|
+
|
|
|
+namespace {
|
|
|
+
|
|
|
+// WARNING: These functions rely on the SDL_Display and SDL_Window previously initialized by init_scrap
|
|
|
+
|
|
|
+const int CURSOR_COUNT = 7;
|
|
|
+Cursor defined_cursors[CURSOR_COUNT] = {0};
|
|
|
+
|
|
|
+void set_cursor(int cursorType) {
|
|
|
+ Cursor cursor = 0;
|
|
|
+
|
|
|
+ if(cursorType >= 0 && cursorType < CURSOR_COUNT) {
|
|
|
+ cursor = defined_cursors[cursorType];
|
|
|
+ if(!cursor) {
|
|
|
+ switch(cursorType) {
|
|
|
+ case Polycode::Core::CURSOR_TEXT:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_xterm);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_POINTER:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_hand1);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_CROSSHAIR:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_crosshair);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_RESIZE_LEFT_RIGHT:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_sb_h_double_arrow);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_RESIZE_UP_DOWN:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_sb_v_double_arrow);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_OPEN_HAND:
|
|
|
+ cursor = XCreateFontCursor (SDL_Display, XC_fleur);
|
|
|
+ break;
|
|
|
+ case Polycode::Core::CURSOR_ARROW:
|
|
|
+ cursor = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ defined_cursors[cursorType] = cursor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!cursor) {
|
|
|
+ // Restore the normal cursor.
|
|
|
+ XUndefineCursor(SDL_Display, SDL_Window);
|
|
|
+ } else {
|
|
|
+ XDefineCursor(SDL_Display, SDL_Window, cursor);
|
|
|
+ }
|
|
|
+
|
|
|
+ XFlush(SDL_Display);
|
|
|
+}
|
|
|
+
|
|
|
+void free_cursors() {
|
|
|
+ XUndefineCursor(SDL_Display, SDL_Window);
|
|
|
+ for(int i = 0; i < CURSOR_COUNT; i++) {
|
|
|
+ if(defined_cursors[i]) {
|
|
|
+ XFreeCursor(SDL_Display, defined_cursors[i]);
|
|
|
+ defined_cursors[i] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+} // namespace
|
|
|
+// end X11 cursor
|
|
|
+
|
|
|
#endif // USE_X11
|