1 // Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 #ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ 31 #define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ 32 #pragma once 33 34 #include "include/internal/cef_types_linux.h" 35 #include "include/internal/cef_types_wrappers.h" 36 37 // Handle types. 38 #define CefCursorHandle cef_cursor_handle_t 39 #define CefEventHandle cef_event_handle_t 40 #define CefWindowHandle cef_window_handle_t 41 42 struct CefMainArgsTraits { 43 typedef cef_main_args_t struct_type; 44 initCefMainArgsTraits45 static inline void init(struct_type* s) {} clearCefMainArgsTraits46 static inline void clear(struct_type* s) {} 47 setCefMainArgsTraits48 static inline void set(const struct_type* src, 49 struct_type* target, 50 bool copy) { 51 target->argc = src->argc; 52 target->argv = src->argv; 53 } 54 }; 55 56 // Class representing CefExecuteProcess arguments. 57 class CefMainArgs : public CefStructBase<CefMainArgsTraits> { 58 public: 59 typedef CefStructBase<CefMainArgsTraits> parent; 60 CefMainArgs()61 CefMainArgs() : parent() {} CefMainArgs(const cef_main_args_t & r)62 explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} CefMainArgs(const CefMainArgs & r)63 explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} CefMainArgs(int argc_arg,char ** argv_arg)64 CefMainArgs(int argc_arg, char** argv_arg) : parent() { 65 argc = argc_arg; 66 argv = argv_arg; 67 } 68 }; 69 70 struct CefWindowInfoTraits { 71 typedef cef_window_info_t struct_type; 72 initCefWindowInfoTraits73 static inline void init(struct_type* s) {} 74 clearCefWindowInfoTraits75 static inline void clear(struct_type* s) { 76 cef_string_clear(&s->window_name); 77 } 78 setCefWindowInfoTraits79 static inline void set(const struct_type* src, 80 struct_type* target, 81 bool copy) { 82 cef_string_set(src->window_name.str, src->window_name.length, 83 &target->window_name, copy); 84 target->bounds = src->bounds; 85 target->parent_window = src->parent_window; 86 target->windowless_rendering_enabled = src->windowless_rendering_enabled; 87 target->shared_texture_enabled = src->shared_texture_enabled; 88 target->external_begin_frame_enabled = src->external_begin_frame_enabled; 89 target->window = src->window; 90 } 91 }; 92 93 // Class representing window information. 94 class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { 95 public: 96 typedef CefStructBase<CefWindowInfoTraits> parent; 97 CefWindowInfo()98 CefWindowInfo() : parent() {} CefWindowInfo(const cef_window_info_t & r)99 explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} CefWindowInfo(const CefWindowInfo & r)100 explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} 101 102 /// 103 // Create the browser as a child window. 104 /// SetAsChild(CefWindowHandle parent,const CefRect & bounds)105 void SetAsChild(CefWindowHandle parent, const CefRect& bounds) { 106 parent_window = parent; 107 this->bounds = bounds; 108 } 109 110 /// 111 // Create the browser using windowless (off-screen) rendering. No window 112 // will be created for the browser and all rendering will occur via the 113 // CefRenderHandler interface. The |parent| value will be used to identify 114 // monitor info and to act as the parent window for dialogs, context menus, 115 // etc. If |parent| is not provided then the main screen monitor will be used 116 // and some functionality that requires a parent window may not function 117 // correctly. In order to create windowless browsers the 118 // CefSettings.windowless_rendering_enabled value must be set to true. 119 // Transparent painting is enabled by default but can be disabled by setting 120 // CefBrowserSettings.background_color to an opaque value. 121 /// SetAsWindowless(CefWindowHandle parent)122 void SetAsWindowless(CefWindowHandle parent) { 123 windowless_rendering_enabled = true; 124 parent_window = parent; 125 } 126 }; 127 128 #endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ 129