reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 23 | class SkBitmap; |
| 24 | class SkEvent; |
| 25 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | struct SkUnixWindow { |
| 27 | Display* fDisplay; |
| 28 | Window fWin; |
| 29 | size_t fOSWin; |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 30 | GC fGc; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | class SkOSWindow : public SkWindow { |
| 34 | public: |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 35 | SkOSWindow(void*); |
| 36 | ~SkOSWindow(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 38 | 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 46 | //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 47 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 48 | //static bool WndProc(SkUnixWindow* w, XEvent &e); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | |
| 50 | protected: |
| 51 | // overrides from SkWindow |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 52 | virtual bool onEvent(const SkEvent&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | virtual void onHandleInval(const SkIRect&); |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame^] | 54 | virtual bool onHandleChar(SkUnichar); |
| 55 | virtual bool onHandleKey(SkKey); |
| 56 | virtual bool onHandleKeyUp(SkKey); |
| 57 | virtual void onSetTitle(const char title[]); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | SkUnixWindow fUnixWindow; |
| 61 | |
| 62 | void doPaint(); |
| 63 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 64 | typedef SkWindow INHERITED; |
| 65 | }; |
| 66 | |
| 67 | #endif |
| 68 | |