From: Mikael Magnusson Date: Thu, 8 Jun 2006 10:24:47 +0000 (+0000) Subject: cvs add is good X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=3c3415d87b3ab0f5b141fa4b122d80ed23616dfd;p=chaz%2Fopenbox cvs add is good --- diff --git a/openbox/per_app_settings.c b/openbox/per_app_settings.c new file mode 100644 index 00000000..47b2fc0e --- /dev/null +++ b/openbox/per_app_settings.c @@ -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 index 00000000..b6b7d514 --- /dev/null +++ b/openbox/per_app_settings.h @@ -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