Skip to contentSkip to conversation

Add xsetting-client in tree + fixes

PATCH In review Jussi Kukkonen 2 participants 6 messages Jul 11, 2016 Licenses and spdx stuff

lore
Share & tools
lore
#0 lore raw

cover Add xsetting-client in tree + fixes

Add an internal copy of xsettings-client into libmatchbox: it was never meant to be a shared library.

Other commits avoid deprecated API use or fix problems found by modern gcc with -Wall.

Jussi

The following changes since commit 9f7cf8895ae2d39c465c04cc78e918c157420269:

tests: link to X11 (2013-12-10 11:45:28 +0000)

are available in the git repository at:

git://github.com/jku/libmatchbox xsettings
https://github.com/jku/libmatchbox/tree/xsettings

Jussi Kukkonen (4):
Don't use deprecated XKeycodeToKeysym
Use correct size with memset calls
Remove unused pointer dereferences
Keep an internal copy of xsettings-client

 COPYING.MIT              |  18 ++
 configure.ac             |  68 ------
 libmb/Makefile.am        |   8 +-
 libmb/hash.c             |   2 +-
 libmb/mbexp.c            |   6 +-
 libmb/mbmenu.c           |  15 +-
 libmb/mbmenu.h           |   7 +-
 libmb/mbtray.c           |  61 +----
 libmb/xsettings-client.c | 577 +++++++++++++++++++++++++++++++++++++++++++++++
 libmb/xsettings-client.h |  72 ++++++
 libmb/xsettings-common.c | 264 ++++++++++++++++++++++
 libmb/xsettings-common.h | 110 +++++++++
 12 files changed, 1057 insertions(+), 151 deletions(-)
 create mode 100644 COPYING.MIT
 create mode 100644 libmb/xsettings-client.c
 create mode 100644 libmb/xsettings-client.h
 create mode 100644 libmb/xsettings-common.c
 create mode 100644 libmb/xsettings-common.h
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/4 Don't use deprecated XKeycodeToKeysym

---
 libmb/mbmenu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libmb/mbmenu.c +3 -1
index d25397b..5e4106e 100644
@@ -23,6 +23,8 @@
 #include "config.h"
 #endif
 
+#include <X11/XKBlib.h>
+
 #include "mbmenu.h"
 
 #define MBMAX(x,y) ((x>y)?(x):(y))
@@ -802,7 +804,7 @@ mb_menu_handle_xevent(MBMenu *mb, XEvent *an_event)
     {
     case KeyPress:
       MENUDBG("%s() Keyevent recieved\n", __func__ );
-      switch (key = XKeycodeToKeysym (mb->dpy, an_event->xkey.keycode, 0))
+      switch (key = XkbKeycodeToKeysym (mb->dpy, an_event->xkey.keycode, 0, 0))
 	{
 	case XK_Left:
 	  if (mb->active_depth > 0)
Signature · 1 line
2.8.1
#2 lore raw

PATCH 2/4 Use correct size with memset calls

Found with -Wsizeof-pointer-memaccess.

---
 libmb/hash.c   | 2 +-
 libmb/mbmenu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
libmb/hash.c +1 -1
index 0226c7d..a867883 100644
@@ -75,7 +75,7 @@ struct nlist *hash_add(struct hash *h, char *key, char *val)
 
 void hash_empty(struct hash *h)
 {
-   memset(h->hashtab, 0, sizeof(h->hashtab));
+   memset(h->hashtab, 0, sizeof(*h->hashtab));
 }
 
 void 
libmb/mbmenu.c +1 -1
index 5e4106e..6e35bed 100644
@@ -1065,7 +1065,7 @@ static MBMenuMenu *
 new_menu(MBMenu *mb, char *title, int depth)
 {
   MBMenuMenu *menu = (MBMenuMenu *)malloc(sizeof(MBMenuMenu));
-   memset(menu, 0, sizeof(menu));
+   memset(menu, 0, sizeof(*menu));
    menu->items = NULL;
 
    MENUDBG("adding menu -> %s, (%i) \n", title, depth);
Signature · 1 line
2.8.1
#3 lore raw

PATCH 3/4 Remove unused pointer dereferences

In reply to Jussi Kukkonen
---
 libmb/mbexp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libmb/mbexp.c +3 -3
index c6e6046..bbe11d0 100644
@@ -1369,7 +1369,7 @@ mb_layout_get_geometry (MBLayout *layout, int *width, int *height)
 	 }
        else
 	 { 
-	   nbytes++; *txt++; 
+	   nbytes++; txt++;
 	 }
       
      line_width = mb_font_get_txt_width(layout->font, start, 
@@ -1703,14 +1703,14 @@ mb_util_next_utf8_char(unsigned char **string)
     return -1;
   }
 	    
-  *s++;
+  s++;
   tmp = length;
   while(tmp-- > 0) {
     if((*s & 0xc0) != 0x80) { /* trailer must be 10xxxxxx */
       /* ERROR */ 
       return -1;
     }
-    *s++;
+    s++;
   } 
   
   *string = s; 
Signature · 1 line
2.8.1
#4 lore raw

PATCH 4/4 Keep an internal copy of xsettings-client

In reply to Jussi Kukkonen

xsettings-client code was meant to be a copy-and-paste module, not a shared library. Grab a copy from
git://anongit.freedesktop.org/xdg/xdg-specs and include it in the sources.

Remove the build complications: always build with xsettings.

The new files are MIT (old style) licensed: add a COPYING.MIT file.

---
 COPYING.MIT              |  18 ++
 configure.ac             |  68 ------
 libmb/Makefile.am        |   8 +-
 libmb/mbmenu.c           |   9 -
 libmb/mbmenu.h           |   7 +-
 libmb/mbtray.c           |  61 +----
 libmb/xsettings-client.c | 577 +++++++++++++++++++++++++++++++++++++++++++++++
 libmb/xsettings-client.h |  72 ++++++
 libmb/xsettings-common.c | 264 ++++++++++++++++++++++
 libmb/xsettings-common.h | 110 +++++++++
 10 files changed, 1049 insertions(+), 145 deletions(-)
 create mode 100644 COPYING.MIT
 create mode 100644 libmb/xsettings-client.c
 create mode 100644 libmb/xsettings-client.h
 create mode 100644 libmb/xsettings-common.c
 create mode 100644 libmb/xsettings-common.h
COPYING.MIT new file +18 -0
new file mode 100644
index 0000000..f7bdbba
@@ -0,0 +1,18 @@
+This license applies to libmb/xsettings-*:
+
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Red Hat makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
configure.ac +0 -68

98 lines not on this page · raw message

libmb/Makefile.am +6 -2
index 633d76e..f78aee0 100644
@@ -6,6 +6,8 @@ source_h = mb.h           \
            mbutil.h       \
            mbexp.h        \
            mbconfig.h     \
+           xsettings-client.h \
+           xsettings-common.h \
            hash.h 
 
 source_c = mbmenu.c       \
@@ -14,6 +16,8 @@ source_c = mbmenu.c       \
            mbpixbuf.c     \
            mbutil.c       \
 	   mbexp.c        \
+           xsettings-client.c \
+           xsettings-common.c \
            hash.c
 
 DATADIR=$(datadir)
@@ -21,8 +25,8 @@ DATADIR=$(datadir)
 
 lib_LTLIBRARIES      = libmb.la
 libmb_la_SOURCES     = $(source_c) $(source_h)
-libmb_la_CPPFLAGS    = -I$(top_srcdir) @GCC_WARNINGS@ @XLIBS_CFLAGS@ @PANGO_CFLAGS@ @PNG_CFLAGS@ @XSET_CFLAGS@ -DDATADIR=\"$(datadir)\"
-libmb_la_LIBADD      = @XLIBS_LIBS@ @PANGO_LIBS@ @JPEG_LIBS@ @PNG_LIBS@ @XSET_LIBS@
+libmb_la_CPPFLAGS    = -I$(top_srcdir) @GCC_WARNINGS@ @XLIBS_CFLAGS@ @PANGO_CFLAGS@ @PNG_CFLAGS@ -DDATADIR=\"$(datadir)\"
+libmb_la_LIBADD      = @XLIBS_LIBS@ @PANGO_LIBS@ @JPEG_LIBS@ @PNG_LIBS@
 
 # http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
 # current : revision : age
libmb/mbmenu.c +0 -9
index 6e35bed..286ea0b 100644
@@ -71,7 +71,6 @@ static void remove_xmenus(MBMenu *mb,MBMenuMenu *active[]);
 
 static void menu_set_theme_from_root_prop(MBMenu *mb);
 
-#ifdef USE_XSETTINGS
 /*
  Gtk/FontName
 */
@@ -131,8 +130,6 @@ mbmenu_xsettings_notify_cb (const char       *name,
     }
 }
 
-#endif
-
 MBMenu *
 mb_menu_new(Display *dpy, int screen) 
 {
@@ -195,16 +192,12 @@ mb_menu_new(Display *dpy, int screen)
 
   menu_set_theme_from_root_prop(mbmenu);
 
-#ifdef USE_XSETTINGS
-
   /* This will trigger callbacks instantly so called last */
 
   mbmenu->xsettings_client = xsettings_client_new(mbmenu->dpy, mbmenu->screen,
 						  mbmenu_xsettings_notify_cb,
 						  NULL,
 						  (void *)mbmenu );
-#endif
-
   return mbmenu;
 }
 
@@ -786,10 +779,8 @@ mb_menu_handle_xevent(MBMenu *mb, XEvent *an_event)
       return;
     }
 
-#ifdef USE_XSETTINGS
   if (mb->xsettings_client != NULL)
     xsettings_client_process_event(mb->xsettings_client, an_event);
-#endif
 
   if (an_event->type == PropertyNotify 
       && an_event->xproperty.atom == mb->atom_mbtheme) 
libmb/mbmenu.h +1 -6
index 1046464..1393ab2 100644
@@ -42,10 +42,7 @@
 #include <X11/keysym.h>
 #include <X11/Xmd.h>
 
-#ifdef USE_XSETTINGS
-#include <xsettings-client.h>
-#endif 
-
+#include <libmb/xsettings-client.h>
 #include <libmb/mbpixbuf.h>
 #include <libmb/mbexp.h>
 
@@ -261,9 +258,7 @@ typedef struct _mbmemu
 
   struct _menu *keyboard_focus_menu;
 
-#ifdef USE_XSETTINGS
   XSettingsClient *xsettings_client;
-#endif 
 
 } MBMenu;
 
libmb/mbtray.c +1 -60

134 lines not on this page · raw message

libmb/xsettings-client.c new file +577 -0

577 lines not on this page · raw message

libmb/xsettings-client.h new file +72 -0

72 lines not on this page · raw message

libmb/xsettings-common.c new file +264 -0

264 lines not on this page · raw message

libmb/xsettings-common.h new file +110 -0

110 lines not on this page · raw message

Signature · 1 line
2.8.1
#5 lore raw
In reply to Jussi Kukkonen
Quoted 6 lines · Jussi Kukkonen

Add an internal copy of xsettings-client into libmatchbox: it was never meant to be a shared library.

Other commits avoid deprecated API use or fix problems found by modern gcc with -Wall.

Looks good, feel free to push.

Ross