1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkOSWindow_Unix_DEFINED
11#define SkOSWindow_Unix_DEFINED
12
13#include "SkWindow.h"
14#include <X11/Xlib.h>
15#include <GL/glx.h>
16
17class SkBitmap;
18class SkEvent;
19
20struct SkUnixWindow {
21  Display* fDisplay;
22  Window fWin;
23  size_t fOSWin;
24  GC fGc;
25  GLXContext fGLContext;
26  bool fGLCreated;
27};
28
29class SkOSWindow : public SkWindow {
30public:
31    SkOSWindow(void*);
32    ~SkOSWindow();
33
34    void* getHWND() const { return (void*)fUnixWindow.fWin; }
35    void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
36    void* getUnixWindow() const { return (void*)&fUnixWindow; }
37    void loop();
38    void post_linuxevent();
39    bool attachGL();
40    void detachGL();
41    void presentGL();
42
43    //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
44
45    //static bool WndProc(SkUnixWindow* w,  XEvent &e);
46
47protected:
48    // overrides from SkWindow
49    virtual bool onEvent(const SkEvent&);
50    virtual void onHandleInval(const SkIRect&);
51    virtual bool onHandleChar(SkUnichar);
52    virtual bool onHandleKey(SkKey);
53    virtual bool onHandleKeyUp(SkKey);
54    virtual void onSetTitle(const char title[]);
55
56private:
57    SkUnixWindow  fUnixWindow;
58    bool fGLAttached;
59
60    // Needed for GL
61    XVisualInfo* fVi;
62
63    void    doPaint();
64    void    mapWindowAndWait();
65
66    typedef SkWindow INHERITED;
67};
68
69#endif
70
71