look mom, I made an openbox toolkit
This commit is contained in:
parent
98dda05c4a
commit
ebce321a72
7 changed files with 177 additions and 24 deletions
33
Makefile.am
33
Makefile.am
|
@ -25,7 +25,8 @@ check_PROGRAMS = \
|
|||
|
||||
lib_LTLIBRARIES = \
|
||||
parser/libobparser.la \
|
||||
render/libobrender.la
|
||||
render/libobrender.la \
|
||||
obt/libobt.la
|
||||
|
||||
bin_PROGRAMS = \
|
||||
openbox/openbox \
|
||||
|
@ -109,6 +110,24 @@ parser_libobparser_la_SOURCES = \
|
|||
parser/parse.h \
|
||||
parser/parse.c
|
||||
|
||||
## obt ##
|
||||
|
||||
obt_libobt_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(XML_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\"Obt\" \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
-DDATADIR=\"$(datadir)\" \
|
||||
-DCONFIGDIR=\"$(configdir)\"
|
||||
obt_libobt_la_LDFLAGS = \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
||||
obt_libobt_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(XML_LIBS)
|
||||
obt_libobt_la_SOURCES = \
|
||||
obt/obt.h \
|
||||
obt/instance.c
|
||||
|
||||
## openbox ##
|
||||
|
||||
openbox_openbox_CPPFLAGS = \
|
||||
|
@ -144,7 +163,8 @@ openbox_openbox_LDADD = \
|
|||
$(EFENCE_LIBS) \
|
||||
$(LIBINTL) \
|
||||
render/libobrender.la \
|
||||
parser/libobparser.la
|
||||
parser/libobparser.la \
|
||||
obt/libobt.la
|
||||
openbox_openbox_LDFLAGS = -export-dynamic
|
||||
openbox_openbox_SOURCES = \
|
||||
gettext.h \
|
||||
|
@ -379,14 +399,16 @@ pubinclude_HEADERS = \
|
|||
render/mask.h \
|
||||
render/render.h \
|
||||
render/theme.h \
|
||||
parser/parse.h
|
||||
parser/parse.h \
|
||||
obt/obt.h
|
||||
|
||||
nodist_pubinclude_HEADERS = \
|
||||
version.h
|
||||
|
||||
nodist_pkgconfig_DATA = \
|
||||
render/obrender-3.0.pc \
|
||||
parser/obparser-3.0.pc
|
||||
parser/obparser-3.0.pc \
|
||||
obt/obt-4.0.pc
|
||||
|
||||
## data ##
|
||||
|
||||
|
@ -447,6 +469,7 @@ dist_noinst_DATA = \
|
|||
doc/openbox-kde-session.1.in \
|
||||
render/obrender-3.0.pc.in \
|
||||
parser/obparser-3.0.pc.in \
|
||||
obt/obt-4.0.pc.in \
|
||||
tools/themeupdate/themeupdate.py \
|
||||
tests/hideshow.py \
|
||||
tests/Makefile \
|
||||
|
@ -502,7 +525,7 @@ CLEANFILES = \
|
|||
# $(MAKE) -$(MAKEFLAGS) -C doc/doxygen doc
|
||||
|
||||
distclean-local:
|
||||
for d in . m4 po render; do \
|
||||
for d in . m4 po render parser obt openbox; do \
|
||||
for p in core core.* gmon.out *\~ *.orig *.rej .\#*; do \
|
||||
rm -f "$$d/$$p"; \
|
||||
done \
|
||||
|
|
|
@ -156,6 +156,7 @@ AC_CONFIG_FILES([
|
|||
po/Makefile.in
|
||||
render/obrender-3.0.pc
|
||||
parser/obparser-3.0.pc
|
||||
obt/obt-4.0.pc
|
||||
version.h
|
||||
])
|
||||
AC_CONFIG_COMMANDS([doc],
|
||||
|
|
56
obt/instance.c
Normal file
56
obt/instance.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "obt/obt.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
struct _ObtInstance
|
||||
{
|
||||
gint ref;
|
||||
Display *d;
|
||||
};
|
||||
|
||||
ObtInstance* obt_instance_new(const char *display_name)
|
||||
{
|
||||
gchar *n;
|
||||
Display *d;
|
||||
ObtInstance *inst = NULL;
|
||||
|
||||
n = display_name ? g_strdup(display_name) : NULL;
|
||||
d = XOpenDisplay(n);
|
||||
if (d) {
|
||||
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
|
||||
g_message("Failed to set display as close-on-exec");
|
||||
|
||||
inst = g_new(ObtInstance, 1);
|
||||
inst->ref = 1;
|
||||
inst->d = d;
|
||||
}
|
||||
g_free(n);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
void obt_instance_ref(ObtInstance *inst)
|
||||
{
|
||||
++inst->ref;
|
||||
}
|
||||
|
||||
void obt_instance_unref(ObtInstance *inst)
|
||||
{
|
||||
if (inst && --inst->ref == 0) {
|
||||
XCloseDisplay(inst->d);
|
||||
obt_free0(inst, ObtInstance, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Display* obt_display(const ObtInstance *inst)
|
||||
{
|
||||
return inst->d;
|
||||
}
|
14
obt/obt-4.0.pc
Normal file
14
obt/obt-4.0.pc
Normal file
|
@ -0,0 +1,14 @@
|
|||
prefix=/opt/openbox
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
xcflags=
|
||||
xlibs= -lSM -lICE -lX11
|
||||
|
||||
Name: ObRender
|
||||
Description: Openbox Toolkit Library
|
||||
Version: 3.999.0
|
||||
Requires: glib-2.0
|
||||
Libs: -L${libdir} -lobrender ${xlibs}
|
||||
Cflags: -I${includedir}/openbox/3.4 ${xcflags}
|
14
obt/obt-4.0.pc.in
Normal file
14
obt/obt-4.0.pc.in
Normal file
|
@ -0,0 +1,14 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
xcflags=@X_CFLAGS@
|
||||
xlibs=@X_LIBS@
|
||||
|
||||
Name: ObRender
|
||||
Description: Openbox Toolkit Library
|
||||
Version: @VERSION@
|
||||
Requires: glib-2.0
|
||||
Libs: -L${libdir} -lobrender ${xlibs}
|
||||
Cflags: -I${includedir}/openbox/@OB_VERSION@ ${xcflags}
|
46
obt/obt.h
Normal file
46
obt/obt.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
||||
|
||||
obt.h for the Openbox window manager
|
||||
Copyright (c) 2007 Dana Jansens
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
See the COPYING file for a copy of the GNU General Public License.
|
||||
*/
|
||||
|
||||
#ifndef __obt_h
|
||||
#define __obt_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h> /* for memset() */
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ObtInstance ObtInstance;
|
||||
|
||||
/* Instance funcs */
|
||||
ObtInstance* obt_instance_new (const char *display_name);
|
||||
void obt_instance_ref (ObtInstance *inst);
|
||||
void obt_instance_unref (ObtInstance *inst);
|
||||
|
||||
Display* obt_display (const ObtInstance *inst);
|
||||
|
||||
/* Util funcs */
|
||||
#define obt_free g_free
|
||||
#define obt_free0(p, type, num) memset((p), 0, sizeof(type) * (num)), g_free(p)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*__obt_h*/
|
|
@ -49,6 +49,7 @@
|
|||
#include "parser/parse.h"
|
||||
#include "render/render.h"
|
||||
#include "render/theme.h"
|
||||
#include "obt/obt.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
|
@ -83,18 +84,18 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
|
||||
RrInstance *ob_rr_inst;
|
||||
RrTheme *ob_rr_theme;
|
||||
ObMainLoop *ob_main_loop;
|
||||
Display *ob_display;
|
||||
gint ob_screen;
|
||||
gboolean ob_replace_wm = FALSE;
|
||||
gboolean ob_sm_use = TRUE;
|
||||
gchar *ob_sm_id = NULL;
|
||||
gchar *ob_sm_save_file = NULL;
|
||||
gboolean ob_sm_restore = TRUE;
|
||||
gboolean ob_debug_xinerama = FALSE;
|
||||
ObtInstance *obt_inst;
|
||||
RrInstance *ob_rr_inst;
|
||||
RrTheme *ob_rr_theme;
|
||||
ObMainLoop *ob_main_loop;
|
||||
Display *ob_display;
|
||||
gint ob_screen;
|
||||
gboolean ob_replace_wm = FALSE;
|
||||
gboolean ob_sm_use = TRUE;
|
||||
gchar *ob_sm_id = NULL;
|
||||
gchar *ob_sm_save_file = NULL;
|
||||
gboolean ob_sm_restore = TRUE;
|
||||
gboolean ob_debug_xinerama = FALSE;
|
||||
|
||||
static ObState state;
|
||||
static gboolean xsync = FALSE;
|
||||
|
@ -144,12 +145,10 @@ gint main(gint argc, gchar **argv)
|
|||
session_startup(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
ob_display = XOpenDisplay(NULL);
|
||||
if (ob_display == NULL)
|
||||
obt_inst = obt_instance_new(NULL);
|
||||
if (obt_inst == NULL)
|
||||
ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable."));
|
||||
if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
|
||||
ob_exit_with_error("Failed to set display as close-on-exec");
|
||||
ob_display = obt_display(obt_inst);
|
||||
|
||||
if (remote_control) {
|
||||
prop_startup();
|
||||
|
@ -159,7 +158,7 @@ gint main(gint argc, gchar **argv)
|
|||
* remote_control = 2 -> restart */
|
||||
PROP_MSG(RootWindow(ob_display, ob_screen),
|
||||
ob_control, remote_control, 0, 0, 0);
|
||||
XCloseDisplay(ob_display);
|
||||
obt_instance_unref(obt_inst);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -386,7 +385,7 @@ gint main(gint argc, gchar **argv)
|
|||
|
||||
session_shutdown(being_replaced);
|
||||
|
||||
XCloseDisplay(ob_display);
|
||||
obt_instance_unref(obt_inst);
|
||||
|
||||
parse_paths_shutdown();
|
||||
|
||||
|
|
Loading…
Reference in a new issue