add most of the root window props get functions
This commit is contained in:
parent
9b63f238ae
commit
7b03041409
4 changed files with 141 additions and 9 deletions
|
@ -2,7 +2,6 @@
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "prop.h"
|
#include "prop.h"
|
||||||
#include "client_props.h"
|
#include "client_props.h"
|
||||||
#include "render/render.h"
|
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __prop_h
|
#ifndef __cwmcc_prop_h
|
||||||
#define __prop_h
|
#define __cwmcc_prop_h
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#include "cwmcc_internal.h"
|
#include "cwmcc_internal.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "prop.h"
|
#include "prop.h"
|
||||||
#include "client_props.h"
|
#include "root_props.h"
|
||||||
#include "render/render.h"
|
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -114,3 +112,88 @@ void cwmcc_root_get_active_window(Window win, Window *window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void cwmcc_root_get_workarea(Window win, Rect a)
|
||||||
|
{
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void cwmcc_root_get_supporting_wm_check(Window win, Window *window)
|
||||||
|
{
|
||||||
|
if (!prop_get32(win, CWMCC_ATOM(root, net_supporting_wm_check),
|
||||||
|
CWMCC_ATOM(type, window), window)) {
|
||||||
|
g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win);
|
||||||
|
*window = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cwmcc_root_get_desktop_layout(Window win,
|
||||||
|
struct Cwmcc_DesktopLayout *layout)
|
||||||
|
{
|
||||||
|
gulong *data = NULL, num;
|
||||||
|
gulong desks;
|
||||||
|
|
||||||
|
/* need the number of desktops */
|
||||||
|
cwmcc_root_get_number_of_desktops(win, &desks);
|
||||||
|
|
||||||
|
layout->orientation = Cwmcc_Orientation_Horz;
|
||||||
|
layout->start_corner = Cwmcc_Corner_TopLeft;
|
||||||
|
layout->rows = 1;
|
||||||
|
layout->columns = desks;
|
||||||
|
|
||||||
|
if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_layout),
|
||||||
|
CWMCC_ATOM(type, cardinal), &data, &num)) {
|
||||||
|
g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win);
|
||||||
|
} else if (num != 4) {
|
||||||
|
g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win);
|
||||||
|
} else {
|
||||||
|
if (data[0] == Cwmcc_Orientation_Horz ||
|
||||||
|
data[0] == Cwmcc_Orientation_Vert)
|
||||||
|
layout->orientation = data[0];
|
||||||
|
if (data[3] == Cwmcc_Corner_TopLeft ||
|
||||||
|
data[3] == Cwmcc_Corner_TopRight ||
|
||||||
|
data[3] == Cwmcc_Corner_BottomLeft ||
|
||||||
|
data[3] == Cwmcc_Corner_BottomRight)
|
||||||
|
layout->start_corner = data[3];
|
||||||
|
layout->rows = data[2];
|
||||||
|
layout->columns = data[1];
|
||||||
|
|
||||||
|
/* bounds checking */
|
||||||
|
if (layout->orientation == Cwmcc_Orientation_Horz) {
|
||||||
|
if (layout->rows > desks)
|
||||||
|
layout->rows = desks;
|
||||||
|
if (layout->columns > ((desks + desks % layout->rows) /
|
||||||
|
layout->rows))
|
||||||
|
layout->columns = ((desks + desks % layout->rows) /
|
||||||
|
layout->rows);
|
||||||
|
} else {
|
||||||
|
if (layout->columns > desks)
|
||||||
|
layout->columns = desks;
|
||||||
|
if (layout->rows > ((desks + desks % layout->columns) /
|
||||||
|
layout->columns))
|
||||||
|
layout->rows = ((desks + desks % layout->columns) /
|
||||||
|
layout->columns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cwmcc_root_get_showing_desktop(Window win, gboolean *showing)
|
||||||
|
{
|
||||||
|
gulong a;
|
||||||
|
|
||||||
|
if (!prop_get32(win, CWMCC_ATOM(root, net_showing_desktop),
|
||||||
|
CWMCC_ATOM(type, cardinal), &a)) {
|
||||||
|
g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win);
|
||||||
|
a = FALSE;
|
||||||
|
}
|
||||||
|
*showing = !!a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cwmcc_root_get_openbox_pid(Window win, gulong *pid)
|
||||||
|
{
|
||||||
|
if (!prop_get32(win, CWMCC_ATOM(root, openbox_pid),
|
||||||
|
CWMCC_ATOM(type, cardinal), pid)) {
|
||||||
|
g_warning("Failed to read OPENBOX_PID from 0x%lx", win);
|
||||||
|
*pid = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,56 @@
|
||||||
#ifndef __cwmcc_root_props_h
|
/*#ifndef __cwmcc_root_props_h
|
||||||
#define __cwmcc_root_props_h
|
#define __cwmcc_root_props_h*/
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
void cwmcc_root_get_supported(Window win, Atom **atoms);
|
void cwmcc_root_get_supported(Window win, Atom **atoms);
|
||||||
|
|
||||||
#endif
|
void cwmcc_root_get_client_list(Window win, Window **windows);
|
||||||
|
|
||||||
|
void cwmcc_root_get_client_list_stacking(Window win, Window **windows);
|
||||||
|
|
||||||
|
void cwmcc_root_get_number_of_desktops(Window win, gulong *desktops);
|
||||||
|
|
||||||
|
void cwmcc_root_get_desktop_geometry(Window win, gulong *w, gulong *h);
|
||||||
|
|
||||||
|
void cwmcc_root_get_desktop_viewport(Window win, gulong *x, gulong *y);
|
||||||
|
|
||||||
|
void cwmcc_root_get_current_desktop(Window win, gulong *desktop);
|
||||||
|
|
||||||
|
void cwmcc_root_get_desktop_names(Window win, char ***names);
|
||||||
|
|
||||||
|
void cwmcc_root_get_active_window(Window win, Window *window);
|
||||||
|
|
||||||
|
/*void cwmcc_root_get_workarea(Window win, Rect a)*/
|
||||||
|
|
||||||
|
void cwmcc_root_get_supporting_wm_check(Window win, Window *window);
|
||||||
|
|
||||||
|
/*! Orientation of the desktops */
|
||||||
|
enum Cwmcc_Orientation {
|
||||||
|
Cwmcc_Orientation_Horz = 0,
|
||||||
|
Cwmcc_Orientation_Vert = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Cwmcc_Corner {
|
||||||
|
Cwmcc_Corner_TopLeft = 0,
|
||||||
|
Cwmcc_Corner_TopRight = 1,
|
||||||
|
Cwmcc_Corner_BottomRight = 2,
|
||||||
|
Cwmcc_Corner_BottomLeft = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Cwmcc_DesktopLayout {
|
||||||
|
enum Cwmcc_Orientation orientation;
|
||||||
|
enum Cwmcc_Corner start_corner;
|
||||||
|
guint rows;
|
||||||
|
guint columns;
|
||||||
|
};
|
||||||
|
|
||||||
|
void cwmcc_root_get_desktop_layout(Window win,
|
||||||
|
struct Cwmcc_DesktopLayout *layout);
|
||||||
|
|
||||||
|
void cwmcc_root_get_showing_desktop(Window win, gboolean *showing);
|
||||||
|
|
||||||
|
void cwmcc_root_get_openbox_pid(Window win, gulong *pid);
|
||||||
|
|
||||||
|
/*#endif*/
|
||||||
|
|
Loading…
Reference in a new issue