Add a sample application that runs on unix.
git-svn-id: http://skia.googlecode.com/svn/trunk@938 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/utils/unix/XkeysToSkKeys.h b/include/utils/unix/XkeysToSkKeys.h
new file mode 100644
index 0000000..3d41a22
--- /dev/null
+++ b/include/utils/unix/XkeysToSkKeys.h
@@ -0,0 +1,23 @@
+#include "X11/Xlib.h"
+#include "X11/keysym.h"
+
+#include "SkKey.h"
+
+#ifndef XKEYS_TOSKKEYS_H
+#define XKEYS_TOSKKEYS_H
+
+SkKey XKeyToSkKey(KeySym keysym) {
+ switch (keysym) {
+ case XK_Right:
+ return kRight_SkKey;
+ case XK_Left:
+ return kLeft_SkKey;
+ case XK_Down:
+ return kDown_SkKey;
+ case XK_Up:
+ return kUp_SkKey;
+ default:
+ return kNONE_SkKey;
+ }
+}
+#endif
diff --git a/include/utils/unix/keysym2ucs.h b/include/utils/unix/keysym2ucs.h
new file mode 100644
index 0000000..1ae6fe4
--- /dev/null
+++ b/include/utils/unix/keysym2ucs.h
@@ -0,0 +1,8 @@
+/*
+ * This module converts keysym values into the corresponding ISO 10646-1
+ * (UCS, Unicode) values.
+ */
+
+#include <X11/X.h>
+
+long keysym2ucs(KeySym keysym);
diff --git a/include/views/SkOSWindow_Unix.h b/include/views/SkOSWindow_Unix.h
index 26f51be..1b008e1 100644
--- a/include/views/SkOSWindow_Unix.h
+++ b/include/views/SkOSWindow_Unix.h
@@ -20,39 +20,47 @@
#include "SkWindow.h"
#include <X11/Xlib.h>
+class SkBitmap;
+class SkEvent;
+
struct SkUnixWindow {
Display* fDisplay;
Window fWin;
size_t fOSWin;
+ GC fGc;
};
class SkOSWindow : public SkWindow {
public:
- SkOSWindow(Display* display, Window win);
+ SkOSWindow(void*);
+ ~SkOSWindow();
- void* getHWND() const { return (void*)fUnixWindow.fWin; }
- void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
- void* getUnixWindow() const { return (void*)&fUnixWindow; }
- void setSize(int width, int height);
- void updateSize();
+ void* getHWND() const { return (void*)fUnixWindow.fWin; }
+ void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
+ void* getUnixWindow() const { return (void*)&fUnixWindow; }
+ void setUnixWindow(Display*, Window, size_t, GC);
+ bool attachGL(const SkBitmap* offscreen);
+ void detachGL();
+ void presentGL();
- static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
+ //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
- static bool WndProc(SkUnixWindow* w, XEvent &e);
+ //static bool WndProc(SkUnixWindow* w, XEvent &e);
protected:
// overrides from SkWindow
+ virtual bool onEvent(const SkEvent&);
virtual void onHandleInval(const SkIRect&);
- // overrides from SkView
- virtual void onAddMenu(const SkOSMenu*);
+ virtual bool onHandleChar(SkUnichar);
+ virtual bool onHandleKey(SkKey);
+ virtual bool onHandleKeyUp(SkKey);
+ virtual void onSetTitle(const char title[]);
private:
SkUnixWindow fUnixWindow;
void doPaint();
- void* fMBar;
-
typedef SkWindow INHERITED;
};
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index 5deefd5..ffba275 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -111,7 +111,7 @@
#include "SkOSWindow_Mac.h"
#elif defined(SK_BUILD_FOR_WIN)
#include "SkOSWindow_Win.h"
-#elif defined(SK_BUILD_FOR_UNIXx)
+#elif defined(SK_BUILD_FOR_UNIX)
#include "SkOSWindow_Unix.h"
#elif defined(SK_BUILD_FOR_SDL)
#include "SkOSWindow_SDL.h"