[Spice-commits] 2 commits - client/controller.cpp client/controller.h client/x11

Hans de Goede jwrdegoede at kemper.freedesktop.org
Mon Oct 25 02:34:43 PDT 2010


 client/controller.cpp     |   39 ++++++++++++++++++---------------------
 client/controller.h       |    2 +-
 client/x11/red_window.cpp |   10 ++++++----
 client/x11/red_window_p.h |    2 +-
 4 files changed, 26 insertions(+), 27 deletions(-)

New commits:
commit a1cef5b81a60c439c87637507f818a49fe96c60e
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Oct 21 17:33:15 2010 +0200

    controller: Make menu text utf-8
    
    We are making all text send over the controller socket utf-8, rather then
    having somethings as 8 bit (hostname) and others (title, menu) unicode16,
    this patch completes this change by converting the menu handling.

diff --git a/client/controller.cpp b/client/controller.cpp
index 6d1272c..eabbcd4 100644
--- a/client/controller.cpp
+++ b/client/controller.cpp
@@ -326,7 +326,7 @@ bool ControllerConnection::handle_message(ControllerMsg *hdr)
         _handler->hide_me();
         break;
     case CONTROLLER_CREATE_MENU:
-        return create_menu((wchar_t*)data);
+        return create_menu((char*)data);
     case CONTROLLER_DELETE_MENU:
         _handler->delete_menu();
         break;
@@ -339,18 +339,18 @@ bool ControllerConnection::handle_message(ControllerMsg *hdr)
 }
 
 #ifdef WIN32
-#define next_tok(str, delim, state) wcstok(str, delim)
+#define next_tok(str, delim, state) strtok(str, delim)
 #else
-#define next_tok(str, delim, state) wcstok(str, delim, state)
+#define next_tok(str, delim, state) strtok_r(str, delim, state)
 #endif
 
-bool ControllerConnection::create_menu(wchar_t* resource)
+bool ControllerConnection::create_menu(char* resource)
 {
     bool ret = true;
-    wchar_t* item_state = 0;
-    wchar_t* item_dup;
-    wchar_t* param;
-    std::string text;
+    char* item_state = 0;
+    char* item_dup;
+    const char* param;
+    const char* text;
     int parent_id;
     int flags;
     int state;
@@ -359,30 +359,27 @@ bool ControllerConnection::create_menu(wchar_t* resource)
     ASSERT(_handler);
     AutoRef<Menu> app_menu(_handler->get_app_menu());
     AutoRef<Menu> menu(new Menu((*app_menu)->get_target(), ""));
-    wchar_t* item = next_tok(resource, CONTROLLER_MENU_ITEM_DELIMITER, &item_state);
+    char* item = next_tok(resource, CONTROLLER_MENU_ITEM_DELIMITER, &item_state);
     while (item != NULL) {
-        item_dup = wcsdup(item);
+        item_dup = strdup(item);
         ret = ret && (param = next_tok(item_dup, CONTROLLER_MENU_PARAM_DELIMITER, &item_state)) &&
-              swscanf(param, L"%d", &parent_id);
+              sscanf(param, "%d", &parent_id);
         ret = ret && (param = next_tok(NULL, CONTROLLER_MENU_PARAM_DELIMITER, &item_state)) &&
-              swscanf(param, L"%d", &id);
-        ret = ret && (param = next_tok(NULL, CONTROLLER_MENU_PARAM_DELIMITER, &item_state));
-        if (ret) {
-            string_printf(text, "%S", param);
-        }
+              sscanf(param, "%d", &id);
+        ret = ret && (text = next_tok(NULL, CONTROLLER_MENU_PARAM_DELIMITER, &item_state));
         ret = ret && (param = next_tok(NULL, CONTROLLER_MENU_PARAM_DELIMITER, &item_state)) &&
-              swscanf(param, L"%d", &flags);
+              sscanf(param, "%d", &flags);
         free(item_dup);
 
         if (!ret) {
-            DBG(0, "item parsing failed %S", item);
+            DBG(0, "item parsing failed %s", item);
             break;
         }
-        DBG(0, "parent_id=%d, id=%d, text=%s, flags=%d", parent_id, id, text.c_str(), flags);
+        DBG(0, "parent_id=%d, id=%d, text=%s, flags=%d", parent_id, id, text, flags);
 
         AutoRef<Menu> sub_menu((*menu)->find_sub(parent_id));
         if (!(ret = !!*sub_menu)) {
-            DBG(0, "submenu not found %S", item);
+            DBG(0, "submenu not found %s", item);
             break;
         }
 
@@ -406,7 +403,7 @@ bool ControllerConnection::create_menu(wchar_t* resource)
             }
             (*sub_menu)->add_command(text, id, state);
         }
-        item = next_tok(item + wcslen(item) + 1, CONTROLLER_MENU_ITEM_DELIMITER, &item_state);
+        item = next_tok(item + strlen(item) + 1, CONTROLLER_MENU_ITEM_DELIMITER, &item_state);
     }
     if (ret) {
         _handler->set_menu(*menu);
diff --git a/client/controller.h b/client/controller.h
index 924f351..bf92707 100644
--- a/client/controller.h
+++ b/client/controller.h
@@ -90,7 +90,7 @@ private:
     bool read_msgs();
     bool handle_init(ControllerInit *init);
     bool handle_message(ControllerMsg *hdr);
-    bool create_menu(wchar_t* resource);
+    bool create_menu(char* resource);
     bool set_multi_val(uint32_t op, char* multi_val);
 
 private:
commit 18e6edb93adf45adeccf994f5561b7dc92012cf8
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Oct 21 16:22:06 2010 +0200

    spicec-x11: Do not set _NET_WM_USER_TIME to 0 on startup
    
    Setting _NET_WM_USER_TIME to 0 means we do not want focus, not good.

diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 416f6c7..c3ee1b0 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -801,7 +801,7 @@ void RedWindow_p::win_proc(XEvent& event)
     }
     case KeyPress:
         red_window->handle_key_press_event(*red_window, &event.xkey);
-        red_window->last_event_time = event.xkey.time;
+        red_window->_last_event_time = event.xkey.time;
         XChangeProperty(x_display, red_window->_win, wm_user_time,
                         XA_CARDINAL, 32, PropModeReplace,
                         (unsigned char *)&event.xkey.time, 1);
@@ -833,7 +833,7 @@ void RedWindow_p::win_proc(XEvent& event)
             break;
         }
         red_window->get_listener().on_mouse_button_press(button, state);
-        red_window->last_event_time = event.xkey.time;
+        red_window->_last_event_time = event.xkey.time;
         XChangeProperty(x_display, red_window->_win, wm_user_time,
                         XA_CARDINAL, 32, PropModeReplace,
                         (unsigned char *)&event.xbutton.time, 1);
@@ -1119,6 +1119,7 @@ RedWindow_p::RedWindow_p()
     , _ignore_pointer (false)
     ,_width (200)
     ,_height (200)
+    ,_last_event_time (0)
 {
 }
 
@@ -1534,8 +1535,9 @@ void RedWindow::show(int screen_id)
         XDeleteProperty(x_display, _win, wm_state);
         wait_parent = true;
     }
-    XChangeProperty(x_display, _win, wm_user_time, XA_CARDINAL, 32,
-                    PropModeReplace, (unsigned char *)&last_event_time, 1);
+    if (_last_event_time != 0)
+        XChangeProperty(x_display, _win, wm_user_time, XA_CARDINAL, 32,
+                        PropModeReplace, (unsigned char *)&_last_event_time, 1);
     XMapWindow(x_display, _win);
     move_to_current_desktop();
     _expect_parent = wait_parent;
diff --git a/client/x11/red_window_p.h b/client/x11/red_window_p.h
index 4ad5451..777a855 100644
--- a/client/x11/red_window_p.h
+++ b/client/x11/red_window_p.h
@@ -82,7 +82,7 @@ protected:
     RedWindow *_red_window;
     int _width;
     int _height;
-    Time last_event_time;
+    Time _last_event_time;
 };
 
 #endif


More information about the Spice-commits mailing list