| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #include <X11/keysym.h> | 36 #include <X11/keysym.h> |
| 37 #include <gdk/gdkx.h> | 37 #include <gdk/gdkx.h> |
| 38 #include <gdk/gdkkeysyms.h> | 38 #include <gdk/gdkkeysyms.h> |
| 39 #include "base/at_exit.h" | 39 #include "base/at_exit.h" |
| 40 #include "base/command_line.h" | 40 #include "base/command_line.h" |
| 41 #include "base/logging.h" | 41 #include "base/logging.h" |
| 42 #include "base/scoped_ptr.h" | 42 #include "base/scoped_ptr.h" |
| 43 #include "plugin/cross/main.h" | 43 #include "plugin/cross/main.h" |
| 44 #include "plugin/cross/out_of_memory.h" | 44 #include "plugin/cross/out_of_memory.h" |
| 45 #include "plugin/linux/envvars.h" |
| 45 | 46 |
| 46 using glue::_o3d::PluginObject; | 47 using glue::_o3d::PluginObject; |
| 47 using glue::StreamManager; | 48 using glue::StreamManager; |
| 48 using o3d::DisplayWindowLinux; | 49 using o3d::DisplayWindowLinux; |
| 49 using o3d::Event; | 50 using o3d::Event; |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 // We would normally make this a stack variable in main(), but in a | 53 // We would normally make this a stack variable in main(), but in a |
| 53 // plugin, that's not possible, so we make it a global. When the DLL is loaded | 54 // plugin, that's not possible, so we make it a global. When the DLL is loaded |
| 54 // this it gets constructed and when it is unlooaded it is destructed. Note | 55 // this it gets constructed and when it is unlooaded it is destructed. Note |
| 55 // that this cannot be done in NP_Initialize and NP_Shutdown because those | 56 // that this cannot be done in NP_Initialize and NP_Shutdown because those |
| 56 // calls do not necessarily signify the DLL being loaded and unloaded. If the | 57 // calls do not necessarily signify the DLL being loaded and unloaded. If the |
| 57 // DLL is not unloaded then the values of global variables are preserved. | 58 // DLL is not unloaded then the values of global variables are preserved. |
| 58 base::AtExitManager g_at_exit_manager; | 59 base::AtExitManager g_at_exit_manager; |
| 59 | 60 |
| 60 bool g_xembed_support = false; | 61 bool g_xembed_support = false; |
| 61 | 62 |
| 63 // This is a #define set on the build command-line for greater flexibility. |
| 64 static const char *kEnvVarsFilePath = O3D_PLUGIN_ENV_VARS_FILE; |
| 65 |
| 62 static void DrawPlugin(PluginObject *obj) { | 66 static void DrawPlugin(PluginObject *obj) { |
| 63 // Limit drawing to no more than once every timer tick. | 67 // Limit drawing to no more than once every timer tick. |
| 64 if (!obj->draw_) return; | 68 if (!obj->draw_) return; |
| 65 obj->client()->RenderClient(true); | 69 obj->client()->RenderClient(true); |
| 66 obj->draw_ = false; | 70 obj->draw_ = false; |
| 67 } | 71 } |
| 68 | 72 |
| 69 // Xt support functions | 73 // Xt support functions |
| 70 | 74 |
| 71 void LinuxTimer(XtPointer data, XtIntervalId* id) { | 75 void LinuxTimer(XtPointer data, XtIntervalId* id) { |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return NPERR_MODULE_LOAD_FAILED_ERROR; | 621 return NPERR_MODULE_LOAD_FAILED_ERROR; |
| 618 | 622 |
| 619 CommandLine::Init(0, NULL); | 623 CommandLine::Init(0, NULL); |
| 620 InitLogging("debug.log", | 624 InitLogging("debug.log", |
| 621 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 625 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| 622 logging::DONT_LOCK_LOG_FILE, | 626 logging::DONT_LOCK_LOG_FILE, |
| 623 logging::APPEND_TO_OLD_LOG_FILE); | 627 logging::APPEND_TO_OLD_LOG_FILE); |
| 624 | 628 |
| 625 DLOG(INFO) << "NP_Initialize"; | 629 DLOG(INFO) << "NP_Initialize"; |
| 626 | 630 |
| 631 // Before doing anything more, we first load our environment variables file. |
| 632 // This file is a newline-delimited list of any system-specific environment |
| 633 // variables that need to be set in the browser. Since we are a shared library |
| 634 // and not an executable, we can't set them at browser start time, so we |
| 635 // instead set them in every process that loads our shared library. It is |
| 636 // important that we do this as early as possible so that any relevant |
| 637 // variables are already set when we initialize our shared library |
| 638 // dependencies. |
| 639 o3d::LoadEnvironmentVariablesFile(kEnvVarsFilePath); |
| 640 |
| 627 // Check for XEmbed support in the browser. | 641 // Check for XEmbed support in the browser. |
| 628 NPBool xembed_support = 0; | 642 NPBool xembed_support = 0; |
| 629 NPError err = NPN_GetValue(NULL, NPNVSupportsXEmbedBool, &xembed_support); | 643 NPError err = NPN_GetValue(NULL, NPNVSupportsXEmbedBool, &xembed_support); |
| 630 if (err != NPERR_NO_ERROR) | 644 if (err != NPERR_NO_ERROR) |
| 631 xembed_support = 0; | 645 xembed_support = 0; |
| 632 | 646 |
| 633 if (xembed_support) { | 647 if (xembed_support) { |
| 634 // Check for Gtk2 toolkit support in the browser. | 648 // Check for Gtk2 toolkit support in the browser. |
| 635 NPNToolkitType toolkit = static_cast<NPNToolkitType>(0); | 649 NPNToolkitType toolkit = static_cast<NPNToolkitType>(0); |
| 636 err = NPN_GetValue(NULL, NPNVToolkit, &toolkit); | 650 err = NPN_GetValue(NULL, NPNVToolkit, &toolkit); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 client()->SendResizeEvent(renderer()->width(), renderer()->height(), | 958 client()->SendResizeEvent(renderer()->width(), renderer()->height(), |
| 945 false); | 959 false); |
| 946 SetGtkEventSource(gtk_container_); | 960 SetGtkEventSource(gtk_container_); |
| 947 gtk_widget_destroy(gtk_fullscreen_container_); | 961 gtk_widget_destroy(gtk_fullscreen_container_); |
| 948 gtk_widget_unref(gtk_fullscreen_container_); | 962 gtk_widget_unref(gtk_fullscreen_container_); |
| 949 gtk_fullscreen_container_ = NULL; | 963 gtk_fullscreen_container_ = NULL; |
| 950 fullscreen_ = false; | 964 fullscreen_ = false; |
| 951 } | 965 } |
| 952 } // namespace _o3d | 966 } // namespace _o3d |
| 953 } // namespace glue | 967 } // namespace glue |
| OLD | NEW |