[Spice-devel] [RFC] patch to remove CEGUI dependency

Attila Sukosd attila.sukosd at gmail.com
Wed Jun 30 23:45:48 PDT 2010


On Wed, Jun 30, 2010 at 8:57 PM, Alon Levy <alevy at redhat.com> wrote:

> This has been tested a little, just to get my n900 to run spicec (it does
> now :)
>  * patch adds a --enable-cegui flag, defaults to disabled
>  * so default becomes:
>  * quit if no -h and -p arguments supplied (instead of showing dialog)
>  * if vm quits for any reason we quit (instead of returning to dialog)
>
> The define is called "HAVE_CEGUI" but should really be USE_GUI or something
> like that.
>
> commit 138bdba17a725a4f09400b1399dd652df6dbd254
> Author: Alon Levy <alevy at redhat.com>
> Date:   Wed Jun 30 20:50:26 2010 +0300
>
>    CEGUI made optional
>
> diff --git a/client/application.cpp b/client/application.cpp
> index 482215c..9744083 100644
> --- a/client/application.cpp
> +++ b/client/application.cpp
> @@ -24,6 +24,8 @@
>  #include <io.h>
>  #endif
>
> +#include <assert.h>
> +
>  #include "application.h"
>  #include "screen.h"
>  #include "utils.h"
> @@ -42,7 +44,9 @@
>  #include "cmd_line_parser.h"
>  #include "tunnel_channel.h"
>  #include "rect.h"
> +#ifdef HAVE_CEGUI
>  #include "gui/gui.h"
> +#endif
>  #include <stdarg.h>
>  #include <stdio.h>
>  #include <time.h>
> @@ -102,6 +106,7 @@ void SwitchHostEvent::response(AbstractProcessLoop&
> events_loop)
>  }
>
>  //todo: add inactive visual appearance
> +#ifdef HAVE_CEGUI
>  class GUIBarrier: public ScreenLayer {
>  public:
>     GUIBarrier(int id)
> @@ -147,6 +152,7 @@ private:
>     int _id;
>     AutoRef<LocalCursor> _cursor;
>  };
> +#endif // HAVE_CEGUI
>
>  class InfoLayer: public ScreenLayer {
>  public:
> @@ -279,6 +285,7 @@ void StickyKeyTimer::response(AbstractProcessLoop&
> events_loop)
>     app->deactivate_interval_timer(this);
>  }
>
> +#ifdef HAVE_CEGUI
>  class GUITimer: public Timer {
>  public:
>     GUITimer(GUI& gui)
> @@ -314,6 +321,7 @@ private:
>  };
>  #endif
>
> +#endif // HAVE_CEGUI
>
>  static MouseHandler default_mouse_handler;
>  static KeyHandler default_key_handler;
> @@ -330,7 +338,9 @@ enum AppCommands {
>     APP_CMD_CONNECT,
>     APP_CMD_DISCONNECT,
>  #endif
> +#ifdef HAVE_CEGUI
>     APP_CMD_SHOW_GUI,
> +#endif // HAVE_CEGUI
>  };
>
>  Application::Application()
> @@ -351,7 +361,9 @@ Application::Application()
>     , _monitors (NULL)
>     , _title (L"SPICEc:%d")
>     , _sys_key_intercept_mode (false)
> +#ifdef HAVE_CEGUI
>     , _gui_mode (GUI_MODE_FULL)
> +#endif // HAVE_CEGUI
>     , _during_host_switch(false)
>     , _state (DISCONNECTED)
>  {
> @@ -371,7 +383,9 @@ Application::Application()
>     _commands_map["connect"] = APP_CMD_CONNECT;
>     _commands_map["disconnect"] = APP_CMD_DISCONNECT;
>  #endif
> +#ifdef HAVE_CEGUI
>     _commands_map["show-gui"] = APP_CMD_SHOW_GUI;
> +#endif // HAVE_CEGUI
>
>     _canvas_types.resize(1);
>  #ifdef WIN32
> @@ -391,7 +405,9 @@ Application::Application()
>
> ",connect=shift+f5"
>
> ",disconnect=shift+f6"
>  #endif
> +#ifdef HAVE_CEGUI
>
> ",show-gui=shift+f7"
> +#endif // HAVE_CEGUI
>                                                           ,
> _commands_map));
>     _hot_keys = parser->get();
>
> @@ -402,6 +418,7 @@ Application::Application()
>     _sticky_info.key  = REDKEY_INVALID;
>     _sticky_info.timer.reset(new StickyKeyTimer());
>
> +#ifdef HAVE_CEGUI
>     _gui.reset(new GUI(*this, DISCONNECTED));
>     _gui_timer.reset(new GUITimer(*_gui.get()));
>     activate_interval_timer(*_gui_timer, 1000 / 30);
> @@ -409,6 +426,7 @@ Application::Application()
>     _gui_test_timer.reset(new TestTimer(*this));
>     activate_interval_timer(*_gui_test_timer, 1000 * 30);
>  #endif
> +#endif // HAVE_CEGUI
>     for (int i = SPICE_CHANNEL_MAIN; i < SPICE_END_CHANNEL; i++) {
>         _peer_con_opt[i] = RedPeer::ConnectionOptions::CON_OP_BOTH;
>     }
> @@ -416,12 +434,14 @@ Application::Application()
>
>  Application::~Application()
>  {
> +#ifdef HAVE_CEGUI
>     deactivate_interval_timer(*_gui_timer);
>  #ifdef GUI_DEMO
>     deactivate_interval_timer(*_gui_test_timer);
>  #endif
>     destroyed_gui_barriers();
>     _gui->set_screen(NULL);
> +#endif // HAVE_CEGUI
>
>     if (_info_layer->screen()) {
>         _main_screen->detach_layer(*_info_layer);
> @@ -511,7 +531,11 @@ void Application::remove_mouse_handler(MouseHandler&
> handler)
>
>  void Application::capture_mouse()
>  {
> -    if (!_active_screen || _gui->screen()) {
> +    if (!_active_screen
> +#ifdef HAVE_CEGUI
> +        || _gui->screen()
> +#endif // HAVE_CEGUI
> +        ) {
>         return;
>     }
>     _active_screen->capture_mouse();
> @@ -568,11 +592,15 @@ void Application::switch_host(const std::string&
> host, int port, int sport,
>
>  int Application::run()
>  {
> +#ifdef HAVE_CEGUI
>     if (_gui_mode != GUI_MODE_FULL) {
>         connect();
>     }
>
>     show_gui();
> +#else
> +    connect();
> +#endif // HAVE_GUI
>     _exit_code = ProcessLoop::run();
>     return _exit_code;
>  }
> @@ -630,7 +658,9 @@ RedScreen* Application::get_screen(int id)
>             size.y = SCREEN_INIT_HEIGHT;
>         }
>         screen = _screens[id] = new RedScreen(*this, id, _title, size.x,
> size.y);
> +#ifdef HAVE_CEGUI
>         create_gui_barrier(*screen, id);
> +#endif // HAVE_CEGUI
>
>         if (id != 0) {
>             if (_full_screen) {
> @@ -658,6 +688,7 @@ RedScreen* Application::get_screen(int id)
>     return screen;
>  }
>
> +#ifdef HAVE_CEGUI
>  void Application::attach_gui_barriers()
>  {
>     GUIBarriers::iterator iter = _gui_barriers.begin();
> @@ -710,12 +741,15 @@ void Application::destroyed_gui_barrier(int id)
>         }
>     }
>  }
> +#endif // HAVE_CEGUI
>
>  void Application::on_screen_destroyed(int id, bool was_captured)
>  {
>     bool reposition = false;
>
> +#ifdef HAVE_CEGUI
>     destroyed_gui_barrier(id);
> +#endif // HAVE_CEGUI
>
>     if ((int)_screens.size() < id + 1 || !_screens[id]) {
>         THROW("no screen");
> @@ -772,10 +806,12 @@ void Application::set_state(State state)
>         return;
>     }
>     _state = state;
> +#ifdef HAVE_CEGUI
>     _gui->set_state(_state);
>     if (_gui->screen() && !_gui->is_visible()) {
>         hide_gui();
>     }
> +#endif // HAVE_CEGUI
>     reset_sticky();
>  }
>
> @@ -789,7 +825,11 @@ void Application::on_connected()
>  void Application::on_disconnected(int error_code)
>  {
>     bool host_switch = _during_host_switch && (error_code ==
> SPICEC_ERROR_CODE_SUCCESS);
> -    if (_gui_mode != GUI_MODE_FULL && !host_switch) {
> +    if (
> +#ifdef HAVE_CEGUI
> +    _gui_mode != GUI_MODE_FULL &&
> +#endif // HAVE_CEGUI
> +    !host_switch) {
>         _during_host_switch = false;
>         ProcessLoop::quit(error_code);
>         return;
> @@ -884,6 +924,7 @@ void Application::message_box_test()
>
>  #endif
>
> +#ifdef HAVE_CEGUI
>  void Application::show_gui()
>  {
>     if (_gui->screen() || !_gui->prepare_dialog()) {
> @@ -906,6 +947,7 @@ void Application::hide_gui()
>     detach_gui_barriers();
>     show_info_layer();
>  }
> +#endif // HAVE_CEGUI
>
>  void Application::do_command(int command)
>  {
> @@ -936,9 +978,11 @@ void Application::do_command(int command)
>         do_disconnect();
>         break;
>  #endif
> +#ifdef HAVE_CEGUI
>     case APP_CMD_SHOW_GUI:
>         show_gui();
>         break;
> +#endif // HAVE_CEGUI
>     }
>  }
>
> @@ -1661,7 +1705,11 @@ void Application::hide_me()
>
>  bool Application::is_disconnect_allowed()
>  {
> +#ifdef HAVE_CEGUI
>     return _gui_mode == GUI_MODE_FULL;
> +#else // HAVE_CEGUI
> +    return true; // XXX???
> +#endif // HAVE_CEGUI
>  }
>
>  const std::string& Application::get_host()
> @@ -1910,14 +1958,18 @@ bool Application::process_cmd_line(int argc, char**
> argv)
>         SPICE_OPT_CANVAS_TYPE,
>     };
>
> +#ifdef HAVE_CEGUI
>     if (argc == 1) {
>         _gui_mode = GUI_MODE_FULL;
>         register_channels();
>         _main_screen->show(true, NULL);
>         return true;
>     }
> +#endif // HAVE_CEGUI
>
> +#ifdef HAVE_CEGUI
>     _gui_mode = GUI_MODE_ACTIVE_SESSION;
> +#endif // HAVE_CEGUI
>
>     CmdLineParser parser("Spice client", false);
>
> diff --git a/client/application.h b/client/application.h
> index 1e48ab5..c9b5198 100644
> --- a/client/application.h
> +++ b/client/application.h
> @@ -35,6 +35,8 @@ class InputsHandler;
>  class Monitor;
>  class CmdLineParser;
>  class Menu;
> +
> +#ifdef HAVE_CEGUI
>  class GUI;
>  class GUITimer;
>  class GUIBarrier;
> @@ -42,6 +44,7 @@ class GUIBarrier;
>  #ifdef GUI_DEMO
>  class TestTimer;
>  #endif
> +#endif // HAVE_CEGUI
>
>
>  class ConnectedEvent: public Event {
> @@ -131,7 +134,9 @@ typedef struct StickyInfo {
>
>
>  typedef std::list<KeyHandler*> KeyHandlersStack;
> +#ifdef HAVE_CEGUI
>  typedef std::list<GUIBarrier*> GUIBarriers;
> +#endif // HAVE_CEGUI
>
>  class Application : public ProcessLoop,
>                     public Platform::EventListener,
> @@ -147,11 +152,13 @@ public:
>         DISCONECTING,
>     };
>
> +#ifdef HAVE_CEGUI
>     enum GuiMode {
>         GUI_MODE_FULL,
>         GUI_MODE_ACTIVE_SESSION,
>         GUI_MODE_MINIMAL,
>     };
> +#endif // HAVE_CEGUI
>
>     Application();
>     virtual ~Application();
> @@ -272,6 +279,7 @@ private:
>
>     void show_info_layer();
>     void hide_info_layer();
> +#ifdef HAVE_CEGUI
>     void attach_gui_barriers();
>     void detach_gui_barriers();
>     void show_gui();
> @@ -279,6 +287,11 @@ private:
>     void create_gui_barrier(RedScreen& screen, int id);
>     void destroyed_gui_barrier(int id);
>     void destroyed_gui_barriers();
> +#else // HAVE_CEGUI
> +    void show_gui() {}
> +    void hide_gui() {}
> +
> +#endif // HAVE_CEGUI
>
>     // returns the press value before operation (i.e., if it was already
> pressed)
>     bool press_key(RedKey key);
> @@ -324,6 +337,7 @@ private:
>     StickyInfo _sticky_info;
>     std::vector<int> _canvas_types;
>     AutoRef<Menu> _app_menu;
> +#ifdef HAVE_CEGUI
>     std::auto_ptr<GUI> _gui;
>     AutoRef<GUITimer> _gui_timer;
>     GUIBarriers _gui_barriers;
> @@ -331,6 +345,7 @@ private:
>  #ifdef GUI_DEMO
>     AutoRef<TestTimer> _gui_test_timer;
>  #endif
> +#endif // HAVE_CEGUI
>     bool _during_host_switch;
>
>     State _state;
> diff --git a/client/gui/gui.h b/client/gui/gui.h
> index d51a8c8..624fe83 100644
> --- a/client/gui/gui.h
> +++ b/client/gui/gui.h
> @@ -22,7 +22,9 @@ public:
>     void set_screen(RedScreen* screen); //show and hide
>
>     Application& get_application() { return _app;}
> +#ifdef HAVE_CEGUI
>     CEGUI::System& gui_system() { return *_gui_system;}
> +#endif // HAVE_CEGUI
>
>     void set_state(Application::State state);
>     bool is_visible() { return !!_dialog;}
> @@ -87,8 +89,10 @@ private:
>     Application& _app;
>     Application::State _state;
>     RedPixmapSw* _pixmap;
> +#ifdef HAVE_CEGUI
>     CEGUI::SoftRenderer* _renderer;
>     CEGUI::System* _gui_system;
> +#endif // HAVE_CEGUI
>     Dialog* _dialog;
>     uint64_t _prev_time;
>     TabFactorys _tab_factorys;
> @@ -100,7 +104,9 @@ class GUI::Tab {
>  public:
>     virtual ~Tab() {}
>
> +#ifdef HAVE_CEGUI
>     virtual CEGUI::Window& get_root_window() = 0;
> +#endif // HAVE_CEGUI
>     virtual const std::string& get_name() = 0;
>  };
>
> diff --git a/client/hot_keys.cpp b/client/hot_keys.cpp
> index 1d3c874..d6564b7 100644
> --- a/client/hot_keys.cpp
> +++ b/client/hot_keys.cpp
> @@ -138,7 +138,9 @@ void HotKeysParser::add_hotkey(const std::string&
> hotkey, const CommandsMap& com
>     CommandsMap::const_iterator command = commands_map.find(command_name);
>
>     if (commands_map.find(command_name) == commands_map.end()) {
> -        THROW("invalid action bname");
> +        char buf[1000];
> +        sprintf(buf, "invalid action bname %s", command_name.c_str());
> +        THROW(buf);
>     }
>     int command_id = commands_map.find(command_name)->second;
>     std::string keys = hotkey.substr(key_start + 1);
> diff --git a/client/x11/Makefile.am b/client/x11/Makefile.am
> index eaa0314..8cd4cd3 100644
> --- a/client/x11/Makefile.am
> +++ b/client/x11/Makefile.am
> @@ -116,15 +116,22 @@ RED_COMMON_SRCS =                                 \
>        $(CLIENT_DIR)/zlib_decoder.cpp                  \
>        $(CLIENT_DIR)/zlib_decoder.h                    \
>        $(CLIENT_DIR)/icon.h                            \
> +       $(NULL)
> +
> +if SUPPORT_CEGUI
> +RED_CEGUI_SRCS =                                                       \
>        $(CLIENT_DIR)/gui/softrenderer.h                \
>        $(CLIENT_DIR)/gui/softrenderer.cpp              \
>        $(CLIENT_DIR)/gui/softtexture.h                 \
>        $(CLIENT_DIR)/gui/softtexture.cpp               \
>        $(CLIENT_DIR)/gui/resource_provider.h           \
> -       $(CLIENT_DIR)/gui/resource_provider.cpp         \
> +       $(CLIENT_DIR)/gui/resource_provider.cpp \
>        $(CLIENT_DIR)/gui/gui.h                         \
> -       $(CLIENT_DIR)/gui/gui.cpp                       \
> -       $(NULL)
> +       $(CLIENT_DIR)/gui/gui.cpp
> +else
> +RED_CEGUI_SRCS =
> +endif
> +
>
>  if SUPPORT_GL
>  RED_OGL_SRCS =                                         \
> @@ -167,6 +174,7 @@ spicec_SOURCES =                    \
>        x_icon.h                        \
>        x_platform.h                    \
>        $(RED_COMMON_SRCS)              \
> +       $(RED_CEGUI_SRCS)               \
>        $(RED_OGL_SRCS)                 \
>        $(NULL)
>
> diff --git a/configure.ac b/configure.ac
> index c78d167..a22b87c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -97,6 +97,12 @@ AC_ARG_ENABLE(tunnel,
>  [  have_tunnel=yes])
>  AM_CONDITIONAL(SUPPORT_TUNNEL, test "x$have_tunnel" = "xyes")
>
> +have_cegui=no
> +AC_ARG_ENABLE(cegui,
> +[  --enable-cegui         Enable start dialog with CEGUI],
> +[  have_cegui=yes])
> +AM_CONDITIONAL(SUPPORT_CEGUI, test "x$have_cegui" = "xyes")
> +
>  have_opengl=no
>  AC_ARG_ENABLE(opengl,
>  [  --enable-opengl         Enable opengl requirement / support (not
> recommended)],
> @@ -121,10 +127,13 @@ SPICE_NONPKGCONFIG_LIBS+=" -pthread $LIBM $LIBRT"
>
>  SPICE_REQUIRES=""
>
> -PKG_CHECK_MODULES(CEGUI, CEGUI >= 0.6.0 CEGUI < 0.7.0)
> -AC_SUBST(CEGUI_CFLAGS)
> -AC_SUBST(CEGUI_LIBS)
> -SPICE_REQUIRES+=" CEGUI"
> +if test "x$have_cegui" = "xyes"; then
> +    PKG_CHECK_MODULES(CEGUI, CEGUI >= 0.6.0 CEGUI < 0.7.0)
> +    AC_SUBST(CEGUI_CFLAGS)
> +    AC_SUBST(CEGUI_LIBS)
> +    SPICE_REQUIRES+=" CEGUI"
> +    CEGUI_CFLAGS+="-DHAVE_CEGUI"
> +fi
>
>  if test "x$have_tunnel" = "xyes"; then
>        PKG_CHECK_MODULES(SLIRP, slirp)
> @@ -366,5 +375,7 @@ echo "
>
>         OpenGL:                   ${have_opengl}
>
> +        CEGUI:                    ${have_cegui}
> +
>         Now type 'make' to build $PACKAGE
>  "
> diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
> index 715bfb6..539c18e 100644
> --- a/server/red_dispatcher.c
> +++ b/server/red_dispatcher.c
> @@ -29,7 +29,9 @@
>  #include "red_worker.h"
>  #include "quic.h"
>  #include "sw_canvas.h"
> +#ifdef USE_OGL
>  #include "gl_canvas.h"
> +#endif // USE_OGL
>  #include "reds.h"
>  #include "red_dispatcher.h"
>  #include "red_parse_qxl.h"
> @@ -496,7 +498,9 @@ RedDispatcher *red_dispatcher_init(QXLInstance *qxl)
>
>     quic_init();
>     sw_canvas_init();
> +#ifdef USE_OGL
>     gl_canvas_init();
> +#endif // USE_OGL
>
>     if (socketpair(AF_LOCAL, SOCK_STREAM, 0, channels) == -1) {
>         red_error("socketpair failed %s", strerror(errno));
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>


Nice, I've been wanting to do this myself too :) Btw, did you need to mod
anything to get it to run on the n900? Once I'll have a bit of free time, I
will try to get it to run on my n810 and maybe some Android devices aswell.

Rgrds,

Attila
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20100701/a088aab1/attachment-0001.html>


More information about the Spice-devel mailing list