blob: 1b008e1ac403c71c3b11fb549bf79cdc2ae7d7d4 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkOSWindow_Unix_DEFINED
18#define SkOSWindow_Unix_DEFINED
19
20#include "SkWindow.h"
21#include <X11/Xlib.h>
22
scroggob7e9aee2011-03-15 15:15:15 +000023class SkBitmap;
24class SkEvent;
25
reed@android.com8a1c16f2008-12-17 15:59:43 +000026struct SkUnixWindow {
27 Display* fDisplay;
28 Window fWin;
29 size_t fOSWin;
scroggob7e9aee2011-03-15 15:15:15 +000030 GC fGc;
reed@android.com8a1c16f2008-12-17 15:59:43 +000031};
32
33class SkOSWindow : public SkWindow {
34public:
scroggob7e9aee2011-03-15 15:15:15 +000035 SkOSWindow(void*);
36 ~SkOSWindow();
reed@android.com8a1c16f2008-12-17 15:59:43 +000037
scroggob7e9aee2011-03-15 15:15:15 +000038 void* getHWND() const { return (void*)fUnixWindow.fWin; }
39 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
40 void* getUnixWindow() const { return (void*)&fUnixWindow; }
41 void setUnixWindow(Display*, Window, size_t, GC);
42 bool attachGL(const SkBitmap* offscreen);
43 void detachGL();
44 void presentGL();
reed@android.com8a1c16f2008-12-17 15:59:43 +000045
scroggob7e9aee2011-03-15 15:15:15 +000046 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
reed@android.com8a1c16f2008-12-17 15:59:43 +000047
scroggob7e9aee2011-03-15 15:15:15 +000048 //static bool WndProc(SkUnixWindow* w, XEvent &e);
reed@android.com8a1c16f2008-12-17 15:59:43 +000049
50protected:
51 // overrides from SkWindow
scroggob7e9aee2011-03-15 15:15:15 +000052 virtual bool onEvent(const SkEvent&);
reed@android.com8a1c16f2008-12-17 15:59:43 +000053 virtual void onHandleInval(const SkIRect&);
scroggob7e9aee2011-03-15 15:15:15 +000054 virtual bool onHandleChar(SkUnichar);
55 virtual bool onHandleKey(SkKey);
56 virtual bool onHandleKeyUp(SkKey);
57 virtual void onSetTitle(const char title[]);
reed@android.com8a1c16f2008-12-17 15:59:43 +000058
59private:
60 SkUnixWindow fUnixWindow;
61
62 void doPaint();
63
reed@android.com8a1c16f2008-12-17 15:59:43 +000064 typedef SkWindow INHERITED;
65};
66
67#endif
68