Newer
Older
Olivier Fourdan
committed
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, or (at your option)
any later version.
Olivier Fourdan
committed
Olivier Fourdan
committed
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.
Olivier Fourdan
committed
Olivier Fourdan
committed
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., 675 Mass Ave, Cambridge, MA 02139, USA.
Olivier Fourdan
committed
Olivier Fourdan
committed
oroborus - (c) 2001 Ken Lynch
xfwm4 - (c) 2002-2004 Olivier Fourdan
#include <config.h>
#endif
#include <glib.h>
#include <pango/pango.h>
Olivier Fourdan
committed
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/libxfcegui4.h>
Olivier Fourdan
committed
#include <libxfce4mcs/mcs-client.h>
#include "screen.h"
#include "focus.h"
#define TOINT(x) (x ? atoi(x) : 0)
Olivier Fourdan
committed
#define DEFAULT_KEYTHEME "Default"
#define KEYTHEMERC "keythemerc"
#define THEMERC "themerc"
static void check_for_grabs (ScreenInfo *);
static void set_settings_margin (ScreenInfo *,
int ,
int);
static void notify_cb (const char *,
const char *,
McsAction,
McsSetting *,
void *);
static GdkFilterReturn client_event_filter (GdkXEvent *,
GdkEvent *,
gpointer);
static void watch_cb (Window,
Bool,
long,
void *);
static void loadRcData (ScreenInfo *,
static gboolean loadKeyBindings (ScreenInfo *,
static void unloadTheme (ScreenInfo *);
static void unloadSettings (ScreenInfo *);
static gboolean reloadScreenSettings (ScreenInfo *,
int);
static void
check_for_grabs (ScreenInfo *screen_info)
{
if ((screen_info->params->raise_on_click) || (screen_info->params->click_to_focus))
{
clientGrabMouseButtonForAll (screen_info);
}
else if (!(screen_info->params->raise_on_click) && !(screen_info->params->click_to_focus))
{
clientUngrabMouseButtonForAll (screen_info);
}
}
Olivier Fourdan
committed
set_settings_margin (ScreenInfo *screen_info, int idx, int value)
Olivier Fourdan
committed
{
Olivier Fourdan
committed
case LEFT:
case RIGHT:
if (value < 0)
{
val = 0;
}
else if (value > gdk_screen_get_width (screen_info->gscr) / 4)
Olivier Fourdan
committed
{
val = gdk_screen_get_width (screen_info->gscr) / 4;
Olivier Fourdan
committed
}
else
{
val = value;
}
screen_info->params->xfwm_margins[idx] = val;
Olivier Fourdan
committed
break;
case TOP:
case BOTTOM:
if (value < 0)
{
val = 0;
}
else if (value > gdk_screen_get_height (screen_info->gscr) / 4)
Olivier Fourdan
committed
{
val = gdk_screen_get_height (screen_info->gscr) / 4;
Olivier Fourdan
committed
}
else
{
val = value;
}
screen_info->params->xfwm_margins[idx] = val;
Olivier Fourdan
committed
break;
default:
break;
Olivier Fourdan
committed
notify_cb (const char *name, const char *channel_name, McsAction action, McsSetting * setting, void *data)
ScreenInfo *screen_info = (ScreenInfo *) data;
g_return_if_fail (screen_info != NULL);
if (!g_ascii_strcasecmp (CHANNEL1, channel_name))
Olivier Fourdan
committed
switch (action)
{
case MCS_ACTION_NEW:
/* The following is to reduce initial startup time and reload */
Olivier Fourdan
committed
{
return;
}
case MCS_ACTION_CHANGED:
if (setting->type == MCS_TYPE_INT)
{
if (!strcmp (name, "Xfwm/ClickToFocus"))
{
screen_info->params->click_to_focus = setting->data.v_int;
check_for_grabs (screen_info);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/FocusNewWindow"))
{
screen_info->params->focus_new = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/FocusRaise"))
{
screen_info->params->raise_on_focus = setting->data.v_int;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/MoveOpacity"))
{
screen_info->params->move_opacity = setting->data.v_int;
}
else if (!strcmp (name, "Xfwm/ResizeOpacity"))
{
screen_info->params->resize_opacity = setting->data.v_int;
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/PlacementRatio"))
{
screen_info->params->placement_ratio = setting->data.v_int;
}
else if (!strcmp (name, "Xfwm/ShowFrameShadow"))
Olivier Fourdan
committed
{
screen_info->params->show_frame_shadow = setting->data.v_int;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/PreventFocusStealing"))
{
screen_info->params->prevent_focus_stealing = setting->data.v_int;
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/RaiseDelay"))
{
screen_info->params->raise_delay = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/RaiseOnClick"))
{
screen_info->params->raise_on_click = setting->data.v_int;
check_for_grabs (screen_info);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/RaiseWithAnyButton"))
{
screen_info->params->raise_with_any_button = setting->data.v_int;
check_for_grabs (screen_info);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/SnapToBorder"))
{
screen_info->params->snap_to_border = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/SnapToWindows"))
{
screen_info->params->snap_to_windows = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/SnapWidth"))
{
screen_info->params->snap_width = setting->data.v_int;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/ToggleWorkspaces"))
{
screen_info->params->toggle_workspaces = setting->data.v_int;
}
Olivier Fourdan
committed
else if (!strcmp (name, "Xfwm/WrapWorkspaces"))
{
screen_info->params->wrap_workspaces = setting->data.v_int;
placeSidewalks (screen_info, screen_info->params->wrap_workspaces);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/WrapWindows"))
{
screen_info->params->wrap_windows = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/WrapResistance"))
{
screen_info->params->wrap_resistance = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/BoxMove"))
{
screen_info->params->box_move = setting->data.v_int;
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/BoxResize"))
{
screen_info->params->box_resize = setting->data.v_int;
Olivier Fourdan
committed
}
}
else if (setting->type == MCS_TYPE_STRING)
{
if (!strcmp (name, "Xfwm/DblClickAction"))
{
reloadScreenSettings (screen_info, NO_UPDATE_FLAG);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/ThemeName"))
{
reloadScreenSettings (screen_info, UPDATE_GRAVITY | UPDATE_CACHE);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/ButtonLayout"))
{
reloadScreenSettings (screen_info, UPDATE_FRAME | UPDATE_CACHE);
Olivier Fourdan
committed
}
if (!strcmp (name, "Xfwm/TitleAlign"))
{
reloadScreenSettings (screen_info, UPDATE_FRAME | UPDATE_CACHE);
Olivier Fourdan
committed
}
if (!strcmp (name, "Xfwm/TitleFont"))
{
reloadScreenSettings (screen_info, UPDATE_FRAME | UPDATE_CACHE);
Olivier Fourdan
committed
}
}
break;
case MCS_ACTION_DELETED:
default:
break;
}
else if (!g_ascii_strcasecmp (CHANNEL2, channel_name))
Olivier Fourdan
committed
switch (action)
{
case MCS_ACTION_NEW:
/* The following is to reduce initial startup time and reloads */
Olivier Fourdan
committed
{
return;
}
case MCS_ACTION_CHANGED:
if (setting->type == MCS_TYPE_INT)
{
if (!strcmp (name, "Xfwm/LeftMargin"))
{
set_settings_margin (screen_info, LEFT, setting->data.v_int);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/RightMargin"))
{
set_settings_margin (screen_info, RIGHT, setting->data.v_int);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/BottomMargin"))
{
set_settings_margin (screen_info, BOTTOM, setting->data.v_int);
Olivier Fourdan
committed
}
else if (!strcmp (name, "Xfwm/TopMargin"))
{
set_settings_margin (screen_info, TOP, setting->data.v_int);
Olivier Fourdan
committed
}
}
break;
case MCS_ACTION_DELETED:
default:
break;
}
Olivier Fourdan
committed
}
Olivier Fourdan
committed
switch (action)
{
case MCS_ACTION_NEW:
/* The following is to reduce initial startup time and reloads */
Olivier Fourdan
committed
{
return;
}
case MCS_ACTION_CHANGED:
if (setting->type == MCS_TYPE_INT)
{
if (!strcmp (name, "Xfwm/WorkspaceCount"))
{
workspaceSetCount(screen_info, setting->data.v_int);
Olivier Fourdan
committed
}
}
break;
case MCS_ACTION_DELETED:
default:
break;
}
else if (!g_ascii_strcasecmp (CHANNEL4, channel_name))
{
switch (action)
{
case MCS_ACTION_NEW:
/* The following is to reduce initial startup time and reloads */
if (!screen_info->mcs_initted)
{
return;
}
case MCS_ACTION_CHANGED:
if (setting->type == MCS_TYPE_STRING)
{
if (!strcmp (name, "Xfwm/KeyThemeName"))
{
reloadScreenSettings (screen_info, UPDATE_KEYGRABS);
}
}
break;
case MCS_ACTION_DELETED:
default:
break;
}
}
Olivier Fourdan
committed
}
static GdkFilterReturn
client_event_filter (GdkXEvent * xevent, GdkEvent * event, gpointer data)
Olivier Fourdan
committed
{
ScreenInfo *screen_info = (ScreenInfo *) data;
if (mcs_client_process_event (screen_info->mcs_client, (XEvent *) xevent))
{
Olivier Fourdan
committed
return GDK_FILTER_REMOVE;
}
Olivier Fourdan
committed
else
{
Olivier Fourdan
committed
return GDK_FILTER_CONTINUE;
}
Olivier Fourdan
committed
}
static void
watch_cb (Window window, Bool is_start, long mask, void *cb_data)
Olivier Fourdan
committed
{
GdkWindow *gdkwin;
gdkwin = gdk_window_lookup (window);
Olivier Fourdan
committed
Olivier Fourdan
committed
{
Olivier Fourdan
committed
if (!gdkwin)
{
gdkwin = gdk_window_foreign_new (window);
}
else
{
g_object_ref (gdkwin);
}
gdk_window_add_filter (gdkwin, client_event_filter, cb_data);
Olivier Fourdan
committed
}
else
{
Olivier Fourdan
committed
g_assert (gdkwin);
gdk_window_remove_filter (gdkwin, client_event_filter, cb_data);
g_object_unref (gdkwin);
Olivier Fourdan
committed
}
}
Olivier Fourdan
committed
{
Olivier Fourdan
committed
gchar *keytheme;
gchar *system_keytheme;
Olivier Fourdan
committed
if (!parseRc ("defaults", PACKAGE_DATADIR, rc))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
exit (1);
Olivier Fourdan
committed
}
keythemevalue = getValue ("keytheme", rc);
if (keythemevalue)
{
Olivier Fourdan
committed
system_keytheme = getSystemThemeDir ();
parseRc (KEYTHEMERC, system_keytheme, rc);
Olivier Fourdan
committed
keytheme = getThemeDir (keythemevalue, KEYTHEMERC);
Olivier Fourdan
committed
{
/* If there is a custom key theme, merge it with system defaults */
parseRc (KEYTHEMERC, keytheme, rc);
Olivier Fourdan
committed
}
g_free (system_keytheme);
homedir = xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
"xfce4" G_DIR_SEPARATOR_S "xfwm4",
FALSE);
parseRc ("xfwm4rc", homedir, rc);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
McsSetting *setting;
Olivier Fourdan
committed
{
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ClickToFocus", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("click_to_focus", setting->data.v_int, rc);
check_for_grabs (screen_info);
Olivier Fourdan
committed
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/FocusNewWindow", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("focus_new", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/FocusRaise", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("raise_on_focus", setting->data.v_int, rc);
mcs_setting_free (setting);
}
Olivier Fourdan
committed
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/MoveOpacity", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("move_opacity", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ResizeOpacity", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("resize_opacity", setting->data.v_int, rc);
mcs_setting_free (setting);
}
Olivier Fourdan
committed
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/PlacementRatio", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("placement_ratio", setting->data.v_int, rc);
mcs_setting_free (setting);
}
Olivier Fourdan
committed
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/PreventFocusStealing", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("prevent_focus_stealing", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/RaiseDelay", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("raise_delay", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/RaiseOnClick", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("raise_on_click", setting->data.v_int, rc);
check_for_grabs (screen_info);
Olivier Fourdan
committed
mcs_setting_free (setting);
}
Olivier Fourdan
committed
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/RaiseWithAnyButton", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("raise_with_any_button", setting->data.v_int, rc);
check_for_grabs (screen_info);
Olivier Fourdan
committed
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ShowFrameShadow", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("show_frame_shadow", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/SnapToBorder", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("snap_to_border", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/SnapToWindows", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("snap_to_windows", setting->data.v_int,
rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/SnapWidth", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("snap_width", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/WrapWorkspaces", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("wrap_workspaces", setting->data.v_int, rc);
mcs_setting_free (setting);
}
Olivier Fourdan
committed
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ToggleWorkspaces", CHANNEL1,
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("toggle_workspaces", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/WrapWindows", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("wrap_windows", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/WrapResistance", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("wrap_resistance", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/BoxMove", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("box_move", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/BoxResize", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setBooleanValueFromInt ("box_resize", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/DblClickAction", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setValue ("double_click_action", setting->data.v_string, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ThemeName", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setValue ("theme", setting->data.v_string, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/ButtonLayout", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setValue ("button_layout", setting->data.v_string, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/TitleAlign", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setValue ("title_alignment", setting->data.v_string, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/TitleFont", CHANNEL1,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setValue ("title_font", setting->data.v_string, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/LeftMargin", CHANNEL2,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("margin_left", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/RightMargin", CHANNEL2,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("margin_right", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/BottomMargin", CHANNEL2,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("margin_bottom", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/TopMargin", CHANNEL2,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("margin_top", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/WorkspaceCount", CHANNEL3,
Olivier Fourdan
committed
&setting) == MCS_SUCCESS)
{
setIntValueFromInt ("workspace_count", setting->data.v_int, rc);
mcs_setting_free (setting);
}
if (mcs_client_get_setting (screen_info->mcs_client, "Xfwm/KeyThemeName", CHANNEL4,
&setting) == MCS_SUCCESS)
{
setValue ("keytheme", setting->data.v_string, rc);
mcs_setting_free (setting);
}
Olivier Fourdan
committed
}
}
GtkWidget *widget = NULL;
DisplayInfo *display_info = NULL;
Olivier Fourdan
committed
gchar *theme;
Olivier Fourdan
committed
XpmColorSymbol colsym[20];
Olivier Fourdan
committed
guint i;
Olivier Fourdan
committed
widget = myScreenGetGtkWidget (screen_info);
display_info = screen_info->display_info;
Olivier Fourdan
committed
rc[0].value = get_style (widget, "fg", "selected");
rc[1].value = get_style (widget, "fg", "insensitive");
Olivier Fourdan
committed
rc[2].value = get_style (widget, "fg", "normal");
rc[3].value = get_style (widget, "fg", "normal");
Olivier Fourdan
committed
rc[4].value = get_style (widget, "bg", "selected");
rc[5].value = get_style (widget, "light", "selected");
rc[6].value = get_style (widget, "dark", "selected");
rc[7].value = get_style (widget, "mid", "selected");
rc[8].value = get_style (widget, "bg", "normal");
rc[9].value = get_style (widget, "light", "normal");
rc[10].value = get_style (widget, "dark", "normal");
rc[11].value = get_style (widget, "mid", "normal");
rc[12].value = get_style (widget, "bg", "insensitive");
rc[13].value = get_style (widget, "light", "insensitive");
rc[14].value = get_style (widget, "dark", "insensitive");
rc[15].value = get_style (widget, "mid", "insensitive");
rc[16].value = get_style (widget, "bg", "normal");
rc[17].value = get_style (widget, "light", "normal");
Olivier Fourdan
committed
rc[18].value = get_style (widget, "dark", "normal");
rc[19].value = get_style (widget, "mid", "normal");
Olivier Fourdan
committed
theme = getThemeDir (getValue ("theme", rc), THEMERC);
parseRc (THEMERC, theme, rc);
Olivier Fourdan
committed
screen_info->params->shadow_delta_x =
abs (TOINT (getValue ("shadow_delta_x", rc)));
screen_info->params->shadow_delta_y =
abs (TOINT (getValue ("shadow_delta_y", rc)));
screen_info->params->shadow_delta_width =
abs (TOINT (getValue ("shadow_delta_width", rc)));
screen_info->params->shadow_delta_height =
abs (TOINT (getValue ("shadow_delta_height", rc)));
for (i = 0; i < 20; i++)
Olivier Fourdan
committed
{
Olivier Fourdan
committed
colsym[i].name = rc[i].option;
colsym[i].value = rc[i].value;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
display_info->dbl_click_time = abs (TOINT (getValue ("dbl_click_time", rc)));
Olivier Fourdan
committed
g_value_init (&tmp_val, G_TYPE_INT);
if (gdk_setting_get ("gtk-double-click-time", &tmp_val))
display_info->dbl_click_time = abs (g_value_get_int (&tmp_val));
font = getValue ("title_font", rc);
if (font && strlen (font))
desc = pango_font_description_from_string (font);
if (desc)
Olivier Fourdan
committed
{
pango_font_description_free (desc);
}
}
if (screen_info->title_colors[ACTIVE].allocated)
{
gdk_colormap_free_colors (gdk_screen_get_rgb_colormap (screen_info->gscr),
&screen_info->title_colors[ACTIVE].col, 1);
screen_info->title_colors[ACTIVE].allocated = FALSE;
}
if (gdk_color_parse (rc[0].value, &screen_info->title_colors[ACTIVE].col))
{
if (gdk_colormap_alloc_color (gdk_screen_get_rgb_colormap (screen_info->gscr),
&screen_info->title_colors[ACTIVE].col, FALSE, FALSE))
{
screen_info->title_colors[ACTIVE].allocated = TRUE;
if (screen_info->title_colors[ACTIVE].gc)
Olivier Fourdan
committed
{
g_object_unref (G_OBJECT (screen_info->title_colors[ACTIVE].gc));
Olivier Fourdan
committed
}
screen_info->title_colors[ACTIVE].gc =
gdk_gc_new (myScreenGetGdkWindow (screen_info));
gdk_gc_copy (screen_info->title_colors[ACTIVE].gc, get_style_gc (widget,
Olivier Fourdan
committed
"text", "selected"));
gdk_gc_set_foreground (screen_info->title_colors[ACTIVE].gc,
&screen_info->title_colors[ACTIVE].col);
Olivier Fourdan
committed
}
else
{
gdk_beep ();
g_message (_("%s: Cannot allocate active color %s\n"), g_get_prgname (), rc[0].value);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
gdk_beep ();
g_message (_("%s: Cannot parse active color %s\n"), g_get_prgname (), rc[0].value);
Olivier Fourdan
committed
{
g_object_unref (G_OBJECT (screen_info->black_gc));
Olivier Fourdan
committed
}
screen_info->black_gc = widget->style->black_gc;
g_object_ref (G_OBJECT (widget->style->black_gc));
Olivier Fourdan
committed
Olivier Fourdan
committed
{
g_object_unref (G_OBJECT (screen_info->white_gc));
Olivier Fourdan
committed
}
screen_info->white_gc = widget->style->white_gc;
g_object_ref (G_OBJECT (widget->style->white_gc));
Olivier Fourdan
committed
if (screen_info->title_colors[INACTIVE].allocated)
gdk_colormap_free_colors (gdk_screen_get_rgb_colormap (screen_info->gscr),
&screen_info->title_colors[INACTIVE].col, 1);
screen_info->title_colors[INACTIVE].allocated = FALSE;
if (gdk_color_parse (rc[1].value, &screen_info->title_colors[INACTIVE].col))
if (gdk_colormap_alloc_color (gdk_screen_get_rgb_colormap (screen_info->gscr),
&screen_info->title_colors[INACTIVE].col, FALSE, FALSE))
Olivier Fourdan
committed
{
screen_info->title_colors[INACTIVE].allocated = TRUE;
if (screen_info->title_colors[INACTIVE].gc)
Olivier Fourdan
committed
{
g_object_unref (G_OBJECT (screen_info->title_colors[INACTIVE].gc));
Olivier Fourdan
committed
}
screen_info->title_colors[INACTIVE].gc =
gdk_gc_new (myScreenGetGdkWindow (screen_info));
gdk_gc_copy (screen_info->title_colors[INACTIVE].gc,
Olivier Fourdan
committed
get_style_gc (widget, "text", "normal"));
gdk_gc_set_foreground (screen_info->title_colors[INACTIVE].gc,
&screen_info->title_colors[INACTIVE].col);
Olivier Fourdan
committed
}
else
{
gdk_beep ();
g_message (_("%s: Cannot allocate inactive color %s\n"), g_get_prgname (), rc[1].value);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
gdk_beep ();
g_message (_("%s: Cannot parse inactive color %s\n"), g_get_prgname (), rc[1].value);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_LEFT][ACTIVE], theme,
Olivier Fourdan
committed
"left-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_LEFT][INACTIVE], theme,
Olivier Fourdan
committed
"left-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_RIGHT][ACTIVE], theme,
Olivier Fourdan
committed
"right-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_RIGHT][INACTIVE], theme,
Olivier Fourdan
committed
"right-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_BOTTOM][ACTIVE], theme,
Olivier Fourdan
committed
"bottom-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->sides[SIDE_BOTTOM][INACTIVE], theme,
Olivier Fourdan
committed
"bottom-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_TOP_LEFT][ACTIVE], theme,
Olivier Fourdan
committed
"top-left-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_TOP_LEFT][INACTIVE], theme,
Olivier Fourdan
committed
"top-left-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_TOP_RIGHT][ACTIVE], theme,
Olivier Fourdan
committed
"top-right-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_TOP_RIGHT][INACTIVE], theme,
Olivier Fourdan
committed
"top-right-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_BOTTOM_LEFT][ACTIVE], theme,
Olivier Fourdan
committed
"bottom-left-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_BOTTOM_LEFT][INACTIVE], theme,
Olivier Fourdan
committed
"bottom-left-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_BOTTOM_RIGHT][ACTIVE], theme,
Olivier Fourdan
committed
"bottom-right-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->corners[CORNER_BOTTOM_RIGHT][INACTIVE], theme,
Olivier Fourdan
committed
"bottom-right-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[HIDE_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"hide-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[HIDE_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"hide-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[HIDE_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"hide-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[CLOSE_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"close-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[CLOSE_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"close-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[CLOSE_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"close-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"maximize-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"maximize-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"maximize-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"shade-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"shade-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"shade-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"stick-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"stick-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"stick-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MENU_BUTTON][ACTIVE], theme,
Olivier Fourdan
committed
"menu-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MENU_BUTTON][INACTIVE], theme,
Olivier Fourdan
committed
"menu-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MENU_BUTTON][PRESSED], theme,
Olivier Fourdan
committed
"menu-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][T_ACTIVE], theme,
Olivier Fourdan
committed
"shade-toggled-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][T_INACTIVE], theme,
Olivier Fourdan
committed
"shade-toggled-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[SHADE_BUTTON][T_PRESSED], theme,
Olivier Fourdan
committed
"shade-toggled-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][T_ACTIVE], theme,
Olivier Fourdan
committed
"stick-toggled-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][T_INACTIVE], theme,
Olivier Fourdan
committed
"stick-toggled-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[STICK_BUTTON][T_PRESSED], theme,
Olivier Fourdan
committed
"stick-toggled-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][T_ACTIVE], theme,
Olivier Fourdan
committed
"maximize-toggled-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][T_INACTIVE], theme,
Olivier Fourdan
committed
"maximize-toggled-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->buttons[MAXIMIZE_BUTTON][T_PRESSED], theme,
Olivier Fourdan
committed
"maximize-toggled-pressed", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_1][ACTIVE], theme,
Olivier Fourdan
committed
"title-1-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_1][INACTIVE], theme,
Olivier Fourdan
committed
"title-1-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_2][ACTIVE], theme,
Olivier Fourdan
committed
"title-2-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_2][INACTIVE], theme,
Olivier Fourdan
committed
"title-2-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_3][ACTIVE], theme,
Olivier Fourdan
committed
"title-3-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_3][INACTIVE], theme,
Olivier Fourdan
committed
"title-3-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_4][ACTIVE], theme,
Olivier Fourdan
committed
"title-4-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_4][INACTIVE], theme,
Olivier Fourdan
committed
"title-4-inactive", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_5][ACTIVE], theme,
Olivier Fourdan
committed
"title-5-active", colsym, 20);
xfwmPixmapLoad (screen_info, &screen_info->title[TITLE_5][INACTIVE], theme,
Olivier Fourdan
committed
"title-5-inactive", colsym, 20);
screen_info->box_gc = createGC (screen_info, "#FFFFFF", GXxor, NULL, 2, TRUE);
if (!g_ascii_strcasecmp ("left", getValue ("title_alignment", rc)))
screen_info->params->title_alignment = ALIGN_LEFT;
else if (!g_ascii_strcasecmp ("right", getValue ("title_alignment", rc)))
screen_info->params->title_alignment = ALIGN_RIGHT;
screen_info->params->title_alignment = ALIGN_CENTER;
Olivier Fourdan
committed
Olivier Fourdan
committed
!g_ascii_strcasecmp ("true", getValue ("full_width_title", rc));
Olivier Fourdan
committed
!g_ascii_strcasecmp ("true", getValue ("title_shadow_active", rc));
screen_info->params->title_shadow[INACTIVE] =
Olivier Fourdan
committed
!g_ascii_strcasecmp ("true", getValue ("title_shadow_inactive", rc));
strncpy (screen_info->params->button_layout, getValue ("button_layout", rc), 7);
screen_info->params->button_spacing = TOINT (getValue ("button_spacing", rc));
screen_info->params->button_offset = TOINT (getValue ("button_offset", rc));
screen_info->params->title_vertical_offset_active =
Olivier Fourdan
committed
TOINT (getValue ("title_vertical_offset_active", rc));
screen_info->params->title_vertical_offset_inactive =
Olivier Fourdan
committed
TOINT (getValue ("title_vertical_offset_inactive", rc));
screen_info->params->title_horizontal_offset =
Olivier Fourdan
committed
TOINT (getValue ("title_horizontal_offset", rc));
g_free (theme);
Olivier Fourdan
committed
}
for (i = 0; i < NB_KEY_SHORTCUTS; i++)
Olivier Fourdan
committed
gchar *tmp, *shortcut;
tmp = g_strdup_printf ("shortcut_%i_exec", i + 1);
Olivier Fourdan
committed
{
g_free (screen_info->params->shortcut_exec[i]);
screen_info->params->shortcut_exec[i] = NULL;
Olivier Fourdan
committed
}
shortcut = getValue (tmp, rc);
if (shortcut)
{
screen_info->params->shortcut_exec[i] = g_strdup (shortcut);
Olivier Fourdan
committed
}
g_free (tmp);
static gboolean
Olivier Fourdan
committed
{
Olivier Fourdan
committed
gchar *keytheme;
gchar *keythemevalue;
/*
Load defaults keytheme so that even if there are
missing shortcuts in an older user defined key theme
the missing keys will be taken from the default
*/
keytheme = getThemeDir (DEFAULT_KEYTHEME, KEYTHEMERC);
parseRc (KEYTHEMERC, keytheme, rc);
g_free (keytheme);
keythemevalue = getValue ("keytheme", rc);
if (keythemevalue)
Olivier Fourdan
committed
keytheme = getThemeDir (keythemevalue, KEYTHEMERC);
if (!parseRc (KEYTHEMERC, keytheme, rc))
{
g_warning ("Specified key theme \"%s\" missing, using default", keythemevalue);
Olivier Fourdan
committed
}
g_free (keytheme);
if (!checkRc (rc))
{
Olivier Fourdan
committed
return FALSE;
}
Olivier Fourdan
committed
loadShortcutCmd (screen_info, rc);
parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_UP], getValue ("move_window_up_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_DOWN], getValue ("move_window_down_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_LEFT], getValue ("move_window_left_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_RIGHT], getValue ("move_window_right_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_RESIZE_UP], getValue ("resize_window_up_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_RESIZE_DOWN], getValue ("resize_window_down_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_RESIZE_LEFT], getValue ("resize_window_left_key", rc));
parseKeyString (dpy, &screen_info->params->keys[KEY_RESIZE_RIGHT], getValue ("resize_window_right_key", rc));