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 #include <GL/glx.h> 23 24 class SkBitmap; 25 class SkEvent; 26 27 struct SkUnixWindow { 28 Display* fDisplay; 29 Window fWin; 30 size_t fOSWin; 31 GC fGc; 32 GLXContext fGLContext; 33 bool fGLCreated; 34 }; 35 36 class SkOSWindow : public SkWindow { 37 public: 38 SkOSWindow(void*); 39 ~SkOSWindow(); 40 41 void* getHWND() const { return (void*)fUnixWindow.fWin; } 42 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } 43 void* getUnixWindow() const { return (void*)&fUnixWindow; } 44 void loop(); 45 void post_linuxevent(); 46 bool attachGL(); 47 void detachGL(); 48 void presentGL(); 49 50 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); 51 52 //static bool WndProc(SkUnixWindow* w, XEvent &e); 53 54 protected: 55 // overrides from SkWindow 56 virtual bool onEvent(const SkEvent&); 57 virtual void onHandleInval(const SkIRect&); 58 virtual bool onHandleChar(SkUnichar); 59 virtual bool onHandleKey(SkKey); 60 virtual bool onHandleKeyUp(SkKey); 61 virtual void onSetTitle(const char title[]); 62 63 private: 64 SkUnixWindow fUnixWindow; 65 bool fGLAttached; 66 67 // Needed for GL 68 XVisualInfo* fVi; 69 70 void doPaint(); 71 void mapWindowAndWait(); 72 73 typedef SkWindow INHERITED; 74 }; 75 76 #endif 77 78