]> Dogcows Code - chaz/openbox/commitdiff
cvs add is good
authorMikael Magnusson <mikachu@comhem.se>
Thu, 8 Jun 2006 10:24:47 +0000 (10:24 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Thu, 8 Jun 2006 10:24:47 +0000 (10:24 +0000)
openbox/per_app_settings.c [new file with mode: 0644]
openbox/per_app_settings.h [new file with mode: 0644]

diff --git a/openbox/per_app_settings.c b/openbox/per_app_settings.c
new file mode 100644 (file)
index 0000000..47b2fc0
--- /dev/null
@@ -0,0 +1,73 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   client.h for the Openbox window manager
+   Copyright (c) 2006        Mikael Magnusson
+
+   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.
+*/
+
+#include "per_app_settings.h"
+#include "screen.h"
+
+GSList *per_app_settings;
+
+ObAppSetting *get_client_settings(ObClient *client)
+{
+    GSList *a = per_app_settings;
+
+    while (a) {
+        ObAppSetting *app = (ObAppSetting *) a->data;
+        
+        if (!strcmp(app->name, client->name)) {
+            ob_debug("Window matching: %s\n", app->name);
+
+            return (ObAppSetting *) a->data;
+        }
+
+        a = a->next;
+    }
+    return NULL;
+}
+
+void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y)
+{
+    gint px, py, i;
+    Rect *screen;
+
+    /* Find which head the pointer is on, partly taken from place.c */
+    if (setting->head == -1) {
+        screen_pointer_pos(&px, &py);
+
+        for (i = 0; i < screen_num_monitors; i++) {
+            screen = screen_area_monitor(client->desktop, i);
+            if (RECT_CONTAINS(*screen, px, py))
+                break;
+        }
+
+        if (i == screen_num_monitors)
+            screen = screen_area_monitor(client->desktop, 0);
+    }
+    else
+        screen = screen_area_monitor(client->desktop, setting->head);
+
+    if (setting->position.x == -1 && setting->center_x)
+        *x = screen->x + screen->width / 2 - client->area.width / 2;
+    else if (setting->position.x != -1)
+        *x = screen->x + setting->position.x;
+
+    if (setting->position.y == -1 && setting->center_y)
+        *y = screen->y + screen->height / 2 - client->area.height / 2;
+    else if (setting->position.y != -1)
+        *y = screen->y + setting->position.y;
+
+}
diff --git a/openbox/per_app_settings.h b/openbox/per_app_settings.h
new file mode 100644 (file)
index 0000000..b6b7d51
--- /dev/null
@@ -0,0 +1,48 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   client.h for the Openbox window manager
+   Copyright (c) 2006        Mikael Magnusson
+
+   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 __per_app_settings_h
+#define __per_app_settings_h
+
+#include "client.h"
+
+typedef struct _ObAppSetting ObAppSetting;
+
+struct _ObAppSetting
+{
+    gchar *name;
+    gboolean decor;
+    gboolean shade;
+    gboolean focus;
+
+    Point position;
+    gboolean center_x;
+    gboolean center_y;
+
+    guint desktop;
+    guint head;
+
+    guint layer;
+};
+
+extern GSList *per_app_settings;
+
+ObAppSetting *get_client_settings(ObClient *client);
+void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y);
+
+#endif
This page took 0.035639 seconds and 4 git commands to generate.