blob: d688fb5d7e7bf757262c43581e219d11c6de6f9d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkOSWindow_Unix_DEFINED
11#define SkOSWindow_Unix_DEFINED
12
13#include "SkWindow.h"
14#include <X11/Xlib.h>
Scroggo9df214e2011-04-15 14:48:08 +000015#include <GL/glx.h>
reed@android.com8a1c16f2008-12-17 15:59:43 +000016
scroggob7e9aee2011-03-15 15:15:15 +000017class SkBitmap;
18class SkEvent;
19
reed@android.com8a1c16f2008-12-17 15:59:43 +000020struct SkUnixWindow {
21 Display* fDisplay;
22 Window fWin;
23 size_t fOSWin;
scroggob7e9aee2011-03-15 15:15:15 +000024 GC fGc;
Scroggo9df214e2011-04-15 14:48:08 +000025 GLXContext fGLContext;
26 bool fGLCreated;
reed@android.com8a1c16f2008-12-17 15:59:43 +000027};
28
29class SkOSWindow : public SkWindow {
30public:
scroggob7e9aee2011-03-15 15:15:15 +000031 SkOSWindow(void*);
32 ~SkOSWindow();
reed@android.com8a1c16f2008-12-17 15:59:43 +000033
scroggob7e9aee2011-03-15 15:15:15 +000034 void* getHWND() const { return (void*)fUnixWindow.fWin; }
35 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
36 void* getUnixWindow() const { return (void*)&fUnixWindow; }
Scroggo9df214e2011-04-15 14:48:08 +000037 void loop();
38 void post_linuxevent();
bsalomon@google.comc8ad63e2011-03-18 14:29:44 +000039 bool attachGL();
scroggob7e9aee2011-03-15 15:15:15 +000040 void detachGL();
41 void presentGL();
reed@android.com8a1c16f2008-12-17 15:59:43 +000042
scroggob7e9aee2011-03-15 15:15:15 +000043 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
reed@android.com8a1c16f2008-12-17 15:59:43 +000044
scroggob7e9aee2011-03-15 15:15:15 +000045 //static bool WndProc(SkUnixWindow* w, XEvent &e);
reed@android.com8a1c16f2008-12-17 15:59:43 +000046
47protected:
48 // overrides from SkWindow
scroggob7e9aee2011-03-15 15:15:15 +000049 virtual bool onEvent(const SkEvent&);
reed@android.com8a1c16f2008-12-17 15:59:43 +000050 virtual void onHandleInval(const SkIRect&);
scroggob7e9aee2011-03-15 15:15:15 +000051 virtual bool onHandleChar(SkUnichar);
52 virtual bool onHandleKey(SkKey);
53 virtual bool onHandleKeyUp(SkKey);
54 virtual void onSetTitle(const char title[]);
reed@android.com8a1c16f2008-12-17 15:59:43 +000055
56private:
57 SkUnixWindow fUnixWindow;
Scroggo9df214e2011-04-15 14:48:08 +000058 bool fGLAttached;
Scroggo9df214e2011-04-15 14:48:08 +000059
60 // Needed for GL
61 XVisualInfo* fVi;
reed@android.com8a1c16f2008-12-17 15:59:43 +000062
63 void doPaint();
Scroggo9df214e2011-04-15 14:48:08 +000064 void mapWindowAndWait();
reed@android.com8a1c16f2008-12-17 15:59:43 +000065
reed@android.com8a1c16f2008-12-17 15:59:43 +000066 typedef SkWindow INHERITED;
67};
68
69#endif
70