diff options
author | Viktor Odintsev <zakhams@gmail.com> | 2017-07-02 16:46:26 +0300 |
---|---|---|
committer | Viktor Odintsev <ninetls@xfce.org> | 2017-07-02 16:46:26 +0300 |
commit | 9d5ac6a4f964ce1b4a12b402486f81c77cd3c5e1 (patch) | |
tree | 8ad7c422e90f89c039630ecf1550ee7e54b5a562 /common | |
parent | efff6a64b3650d93501649edf3fbedea0f8f6f2f (diff) | |
download | xfwm4-9d5ac6a4f964ce1b4a12b402486f81c77cd3c5e1.tar.gz |
Introduce xfwm-common static library
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile.am | 20 | ||||
-rw-r--r-- | common/xfwm-common.c | 74 | ||||
-rw-r--r-- | common/xfwm-common.h | 32 |
3 files changed, 126 insertions, 0 deletions
diff --git a/common/Makefile.am b/common/Makefile.am new file mode 100644 index 000000000..5fd949bfe --- /dev/null +++ b/common/Makefile.am @@ -0,0 +1,20 @@ +AM_CPPFLAGS = \ + -I${top_srcdir} + +noinst_LTLIBRARIES = \ + libxfwm-common.la + +libxfwm_common_la_SOURCES = \ + xfwm-common.c \ + xfwm-common.h + +libxfwm_common_la_CFLAGS = \ + $(GTK_CFLAGS) \ + $(PLATFORM_CFLAGS) + +libxfwm_common_la_LIBADD = \ + $(GTK_LIBS) + +libxfwm_common_la_LDFLAGS = \ + -no-undefined \ + $(PLATFORM_LDFLAGS) diff --git a/common/xfwm-common.c b/common/xfwm-common.c new file mode 100644 index 000000000..b6c9ae25f --- /dev/null +++ b/common/xfwm-common.c @@ -0,0 +1,74 @@ +/* vi:set sw=2 sts=2 ts=2 et ai tw=100: */ +/*- + * Copyright (c) 2017 Viktor Odintsev <zakhams@gmail.com> + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include <string.h> +#include <gdk/gdkx.h> + +#include "xfwm-common.h" + + + +void +xfwm_widget_reparent (GtkWidget *widget, + GtkWidget *new_parent) +{ + GtkWidget *old_parent; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_CONTAINER (new_parent)); + + old_parent = gtk_widget_get_parent (widget); + + g_return_if_fail (old_parent != NULL); + + if (old_parent != new_parent) + { + g_object_ref (widget); + gtk_container_remove (GTK_CONTAINER (old_parent), widget); + gtk_container_add (GTK_CONTAINER (new_parent), widget); + g_object_unref (widget); + } +} + + + +void +xfwm_get_screen_dimensions (gint *width, gint *height) +{ +#if GTK_CHECK_VERSION(3, 22, 0) + GdkDisplay *display; + GdkMonitor *monitor; + GdkRectangle geometry; + + display = gdk_display_get_default (); + monitor = gdk_display_get_primary_monitor (display); + gdk_monitor_get_geometry (monitor, &geometry); + + if (width != NULL) + *width = geometry.width; + if (height != NULL) + *height = geometry.height; +#else + if (width != NULL) + *width = gdk_screen_width (); + if (height != NULL) + *height = gdk_screen_height (); +#endif +} diff --git a/common/xfwm-common.h b/common/xfwm-common.h new file mode 100644 index 000000000..eb2ed4182 --- /dev/null +++ b/common/xfwm-common.h @@ -0,0 +1,32 @@ +/* vi:set sw=2 sts=2 ts=2 et ai tw=100: */ +/*- + * Copyright (c) 2017 Viktor Odintsev <zakhams@gmail.com> + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include <gtk/gtk.h> + +void xfwm_widget_reparent (GtkWidget *widget, + GtkWidget *new_parent); + +void xfwm_get_screen_dimensions (gint *width, + gint *height); + +#endif /* !__COMMON_H__ */ |