From: Dana Jansens Date: Sat, 12 Apr 2003 02:03:28 +0000 (+0000) Subject: add most of the root window props get functions X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=7b03041409912d38cb9f98988449fb9be641f572;p=chaz%2Fopenbox add most of the root window props get functions --- diff --git a/cwmcc/client_props.c b/cwmcc/client_props.c index 34ae4ecd..30644dd8 100644 --- a/cwmcc/client_props.c +++ b/cwmcc/client_props.c @@ -2,7 +2,6 @@ #include "atom.h" #include "prop.h" #include "client_props.h" -#include "render/render.h" #include #ifdef HAVE_STRING_H diff --git a/cwmcc/prop.h b/cwmcc/prop.h index c046f5b8..c9cb0751 100644 --- a/cwmcc/prop.h +++ b/cwmcc/prop.h @@ -1,5 +1,5 @@ -#ifndef __prop_h -#define __prop_h +#ifndef __cwmcc_prop_h +#define __cwmcc_prop_h #include #include diff --git a/cwmcc/root_props.c b/cwmcc/root_props.c index 7339cbba..ef03e445 100644 --- a/cwmcc/root_props.c +++ b/cwmcc/root_props.c @@ -1,10 +1,8 @@ #include "cwmcc_internal.h" #include "atom.h" #include "prop.h" -#include "client_props.h" -#include "render/render.h" +#include "root_props.h" -#include #ifdef HAVE_STRING_H # include #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; + } +} + diff --git a/cwmcc/root_props.h b/cwmcc/root_props.h index 0bc5fef7..ca43f136 100644 --- a/cwmcc/root_props.h +++ b/cwmcc/root_props.h @@ -1,6 +1,56 @@ -#ifndef __cwmcc_root_props_h -#define __cwmcc_root_props_h +/*#ifndef __cwmcc_root_props_h + #define __cwmcc_root_props_h*/ + +#include +#include 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*/