9 Commits

Author SHA1 Message Date
879a766a94 Fix typo in BUILD deps for //wmaker:keybind. 2025-02-09 23:26:57 -05:00
ff1c9fd9f9 Factor keybind into its own BUILD target (//wmaker:keybind). 2025-02-09 23:26:17 -05:00
bd8f3c2fd1 Factor notification macros and appearance enum out of WindowMaker.h.
Create //wmaker:notifications and //wmaker:appearance_settings.
2025-02-09 23:17:05 -05:00
16343ec2e0 Factor resources.{h,c} out into //wmaker:resources. 2025-02-09 22:25:19 -05:00
fc5b1e4d8e Move global variables from WindowMaker.h into //wmaker:globals. 2025-02-09 22:16:14 -05:00
e08e3058fd Rename global_display to globals. 2025-02-09 22:14:54 -05:00
3f9b61fa9d Factor //wmaker/pixmap into a distinct lib.
Start factoring out //wmaker/screen. with interface decls needed by
//wmaker/pixmap.
2025-02-09 17:38:33 -05:00
7b67e06b35 Move the global dpy behind a distinct BUILD rule. 2025-02-09 16:49:23 -05:00
949ac920ce Factor //wmaker:{cursor,geometry,preferences} into distinct libs. 2025-02-09 10:28:29 -05:00
246 changed files with 9293 additions and 16716 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@
#define WMGNUSTEP_H_
#include <X11/Xproto.h>
#include <X11/X.h>
#define GNUSTEP_WM_MINIATURIZE_WINDOW "_GNUSTEP_WM_MINIATURIZE_WINDOW"
@@ -109,3 +109,4 @@ typedef struct {
#define WMFHideApplication 12
#endif

View File

@@ -1,136 +0,0 @@
#include "wmaker/WindowMaker.h"
/* notifications */
const char WMNManaged[] = "WMNManaged";
const char WMNUnmanaged[] = "WMNUnmanaged";
const char WMNChangedWorkspace[] = "WMNChangedWorkspace";
const char WMNChangedState[] = "WMNChangedState";
const char WMNChangedFocus[] = "WMNChangedFocus";
const char WMNChangedStacking[] = "WMNChangedStacking";
const char WMNChangedName[] = "WMNChangedName";
const char WMNWorkspaceCreated[] = "WMNWorkspaceCreated";
const char WMNWorkspaceDestroyed[] = "WMNWorkspaceDestroyed";
const char WMNWorkspaceChanged[] = "WMNWorkspaceChanged";
const char WMNWorkspaceNameChanged[] = "WMNWorkspaceNameChanged";
const char WMNResetStacking[] = "WMNResetStacking";
/* window attributes */
const struct window_attribute_t wm_global_window_attribute[] = {
{ "NoTitlebar", { .no_titlebar = 1 }, N_("Disable titlebar"),
N_("Remove the titlebar of this window.\n"
"To access the window commands menu of a window\n"
"without its titlebar, press Control+Esc (or the\n"
"equivalent shortcut, if you changed the default\n"
"settings).") },
{ "NoResizebar", { .no_resizebar = 1 }, N_("Disable resizebar"),
N_("Remove the resizebar of this window.") },
{ "NoCloseButton", { .no_close_button = 1 }, N_("Disable close button"),
N_("Remove the `close window' button of this window.") },
{ "NoMiniaturizeButton", { .no_miniaturize_button = 1 }, N_("Disable miniaturize button"),
N_("Remove the `miniaturize window' button of the window.") },
{ "NoBorder", { .no_border = 1 }, N_("Disable border"),
N_("Remove the 1 pixel black border around the window.") },
{ "KeepOnTop", { .floating = 1 }, N_("Keep on top (floating)"),
N_("Keep the window over other windows, not allowing\n"
"them to cover it.") },
{ "KeepOnBottom", { .sunken = 1 }, N_("Keep at bottom (sunken)"),
N_("Keep the window under all other windows.") },
{ "Omnipresent", { .omnipresent = 1 }, N_("Omnipresent"),
N_("Make window present in all workspaces.") },
{ "StartMiniaturized", { .start_miniaturized = 1 }, N_("Start miniaturized"),
N_("Make the window be automatically miniaturized when it's\n"
"first shown.") },
{ "StartMaximized", { .start_maximized = 1 }, N_("Start maximized"),
N_("Make the window be automatically maximized when it's\n"
"first shown.") },
{ "FullMaximize", { .full_maximize = 1 }, N_("Full screen maximization"),
N_("Make the window use the whole screen space when it's\n"
"maximized. The titlebar and resizebar will be moved\n"
"to outside the screen.") }
};
const struct window_attribute_t wm_global_advanced_option[] = {
{ "NoKeyBindings", { .no_bind_keys = 1 }, N_("Do not bind keyboard shortcuts"),
N_("Do not bind keyboard shortcuts from Window Maker\n"
"when this window is focused. This will allow the\n"
"window to receive all key combinations regardless\n"
"of your shortcut configuration.") },
{ "NoMouseBindings", { .no_bind_mouse = 1 }, N_("Do not bind mouse clicks"),
N_("Do not bind mouse actions, such as `Alt'+drag\n"
"in the window (when Alt is the modifier you have\n"
"configured).") },
{ "SkipWindowList", { .skip_window_list = 1 }, N_("Do not show in the window list"),
N_("Do not list the window in the window list menu.") },
{ "SkipSwitchPanel", { .skip_switchpanel = 1 }, N_("Do not show in the switch panel"),
N_("Do not include in switch panel while cycling windows.") },
{ "Unfocusable", { .no_focusable = 1 }, N_("Do not let it take focus"),
N_("Do not let the window take keyboard focus when you\n"
"click on it.") },
{ "KeepInsideScreen", { .dont_move_off = 1 }, N_("Keep inside screen"),
N_("Do not allow the window to move itself completely\n"
"outside the screen. For bug compatibility.\n") },
{ "NoHideOthers", { .no_hide_others = 1 }, N_("Ignore 'Hide Others'"),
N_("Do not hide the window when issuing the\n"
"`HideOthers' command.") },
{ "DontSaveSession", { .dont_save_session = 1 }, N_("Ignore 'Save Session'"),
N_("Do not save the associated application in the\n"
"session's state, so that it won't be restarted\n"
"together with other applications when Window Maker\n"
"starts.") },
{ "EmulateAppIcon", { .emulate_appicon = 1 }, N_("Emulate application icon"),
N_("Make this window act as an application that provides\n"
"enough information to Window Maker for a dockable\n"
"application icon to be created.") },
{ "FocusAcrossWorkspace", { .focus_across_wksp = 1 }, N_("Focus across workspaces"),
N_("Allow Window Maker to switch workspace to satisfy\n"
"a focus request (annoying).") },
{ "NoMiniaturizable", { .no_miniaturizable = 1 }, N_("Do not let it be minimized"),
N_("Do not let the window of this application be\n"
"minimized.\n") },
{ "IgnoreDecorationChanges", { .ignore_decoration_changes = 1 }, N_("Ignore decoration changes"),
N_("Ignore any request from the application to change\n"
"window decorations (like hiding the titlebar).\n") }
#ifdef XKB_BUTTON_HINT
,{ "NoLanguageButton", { .no_language_button = 1 }, N_("Disable language button"),
N_("Remove the `toggle language' button of the window.") }
#endif
};
const struct window_attribute_t wm_global_application_attr[] = {
{ "StartHidden", { .start_hidden = 1 }, N_("Start hidden"),
N_("Automatically hide application when it's started.") },
{ "NoAppIcon", { .no_appicon = 1 }, N_("No application icon"),
N_("Disable the application icon for the application.\n"
"Note that you won't be able to dock it anymore,\n"
"and any icons that are already docked will stop\n"
"working correctly.") },
{ "SharedAppIcon", { .shared_appicon = 1 }, N_("Shared application icon"),
N_("Use a single shared application icon for all of\n"
"the instances of this application.\n") }
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +0,0 @@
#ifndef WACTION_CONSTANTS_H_
#define WACTION_CONSTANTS_H_
#ifdef USE_ANIMATIONS
struct {
int steps;
int delay;
} shadePars[5] = {
{ SHADE_STEPS_UF, SHADE_DELAY_UF },
{ SHADE_STEPS_F, SHADE_DELAY_F },
{ SHADE_STEPS_M, SHADE_DELAY_M },
{ SHADE_STEPS_S, SHADE_DELAY_S },
{ SHADE_STEPS_US, SHADE_DELAY_US }
};
#define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
#define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
#endif // USE_ANIMATIONS
#define UNSHADE 0
#define SHADE 1
#endif // WACTION_CONSTANTS_H_

File diff suppressed because it is too large Load Diff

View File

@@ -1,371 +0,0 @@
#include "wmaker/animation.h"
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include <math.h>
#include <stdlib.h>
#include <time.h>
/*
* Do the animation while shading (called with what = SHADE)
* or unshading (what = UNSHADE).
*/
#ifdef USE_ANIMATIONS
static struct {
int steps;
int delay;
} shadePars[5] = {
{ SHADE_STEPS_UF, SHADE_DELAY_UF },
{ SHADE_STEPS_F, SHADE_DELAY_F },
{ SHADE_STEPS_M, SHADE_DELAY_M },
{ SHADE_STEPS_S, SHADE_DELAY_S },
{ SHADE_STEPS_US, SHADE_DELAY_US }
};
#define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
#define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
void shade_animate(WWindow *wwin, Bool what)
{
int y, s, w, h;
time_t time0 = time(NULL);
if (wwin->flags.skip_next_animation || wPreferences.no_animations)
return;
switch (what) {
case SHADE:
if (!wwin->screen_ptr->flags.startup) {
/* do the shading animation */
h = wwin->frame->core->height;
s = h / SHADE_STEPS;
if (s < 1)
s = 1;
w = wwin->frame->core->width;
y = wwin->frame->top_width;
while (h > wwin->frame->top_width + 1) {
XMoveWindow(dpy, wwin->client_win, 0, y);
XResizeWindow(dpy, wwin->frame->core->window, w, h);
XFlush(dpy);
if (time(NULL) - time0 > MAX_ANIMATION_TIME)
break;
if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 1000L);
else
wusleep(10);
h -= s;
y -= s;
}
XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
}
break;
case UNSHADE:
h = wwin->frame->top_width + wwin->frame->bottom_width;
y = wwin->frame->top_width - wwin->client.height;
s = abs(y) / SHADE_STEPS;
if (s < 1)
s = 1;
w = wwin->frame->core->width;
XMoveWindow(dpy, wwin->client_win, 0, y);
if (s > 0) {
while (h < wwin->client.height + wwin->frame->top_width + wwin->frame->bottom_width) {
XResizeWindow(dpy, wwin->frame->core->window, w, h);
XMoveWindow(dpy, wwin->client_win, 0, y);
XFlush(dpy);
if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 2000L / 3);
else
wusleep(10);
h += s;
y += s;
if (time(NULL) - time0 > MAX_ANIMATION_TIME)
break;
}
}
XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
break;
}
}
#else
inline void shade_animate(WWindow *wwin, Bool what)
{
/*
* This function is empty on purpose, so tell the compiler
* to not warn about parameters being not used
*/
(void) wwin;
(void) what;
}
#endif // USE_ANIMATIONS
#ifdef USE_ANIMATIONS
static void animateResizeFlip(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
{
#define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
float cx, cy, cw, ch;
float xstep, ystep, wstep, hstep;
XPoint points[5];
float dx, dch, midy;
float angle, final_angle, delta;
xstep = (float)(fx - x) / steps;
ystep = (float)(fy - y) / steps;
wstep = (float)(fw - w) / steps;
hstep = (float)(fh - h) / steps;
cx = (float)x;
cy = (float)y;
cw = (float)w;
ch = (float)h;
final_angle = 2 * WM_PI * MINIATURIZE_ANIMATION_TWIST_F;
delta = (float)(final_angle / FRAMES);
for (angle = 0;; angle += delta) {
if (angle > final_angle)
angle = final_angle;
dx = (cw / 10) - ((cw / 5) * sinf(angle));
dch = (ch / 2) * cosf(angle);
midy = cy + (ch / 2);
points[0].x = cx + dx;
points[0].y = midy - dch;
points[1].x = cx + cw - dx;
points[1].y = points[0].y;
points[2].x = cx + cw + dx;
points[2].y = midy + dch;
points[3].x = cx - dx;
points[3].y = points[2].y;
points[4].x = points[0].x;
points[4].y = points[0].y;
XGrabServer(dpy);
XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_F);
XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
XUngrabServer(dpy);
cx += xstep;
cy += ystep;
cw += wstep;
ch += hstep;
if (angle >= final_angle)
break;
}
XFlush(dpy);
}
#undef FRAMES
static void
animateResizeTwist(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
{
#define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
float cx, cy, cw, ch;
float xstep, ystep, wstep, hstep;
XPoint points[5];
float angle, final_angle, a, d, delta;
x += w / 2;
y += h / 2;
fx += fw / 2;
fy += fh / 2;
xstep = (float)(fx - x) / steps;
ystep = (float)(fy - y) / steps;
wstep = (float)(fw - w) / steps;
hstep = (float)(fh - h) / steps;
cx = (float)x;
cy = (float)y;
cw = (float)w;
ch = (float)h;
final_angle = 2 * WM_PI * MINIATURIZE_ANIMATION_TWIST_T;
delta = (float)(final_angle / FRAMES);
for (angle = 0;; angle += delta) {
if (angle > final_angle)
angle = final_angle;
a = atan2f(ch, cw);
d = sqrtf((cw / 2) * (cw / 2) + (ch / 2) * (ch / 2));
points[0].x = cx + cosf(angle - a) * d;
points[0].y = cy + sinf(angle - a) * d;
points[1].x = cx + cosf(angle + a) * d;
points[1].y = cy + sinf(angle + a) * d;
points[2].x = cx + cosf(angle - a + (float)WM_PI) * d;
points[2].y = cy + sinf(angle - a + (float)WM_PI) * d;
points[3].x = cx + cosf(angle + a + (float)WM_PI) * d;
points[3].y = cy + sinf(angle + a + (float)WM_PI) * d;
points[4].x = cx + cosf(angle - a) * d;
points[4].y = cy + sinf(angle - a) * d;
XGrabServer(dpy);
XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_T);
XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
XUngrabServer(dpy);
cx += xstep;
cy += ystep;
cw += wstep;
ch += hstep;
if (angle >= final_angle)
break;
}
XFlush(dpy);
}
#undef FRAMES
static void animateResizeZoom(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
{
#define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
float cx[FRAMES], cy[FRAMES], cw[FRAMES], ch[FRAMES];
float xstep, ystep, wstep, hstep;
int i, j;
xstep = (float)(fx - x) / steps;
ystep = (float)(fy - y) / steps;
wstep = (float)(fw - w) / steps;
hstep = (float)(fh - h) / steps;
for (j = 0; j < FRAMES; j++) {
cx[j] = (float)x;
cy[j] = (float)y;
cw[j] = (float)w;
ch[j] = (float)h;
}
XGrabServer(dpy);
for (i = 0; i < steps; i++) {
for (j = 0; j < FRAMES; j++) {
XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
(int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
}
XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
for (j = 0; j < FRAMES; j++) {
XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
(int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
if (j < FRAMES - 1) {
cx[j] = cx[j + 1];
cy[j] = cy[j + 1];
cw[j] = cw[j + 1];
ch[j] = ch[j + 1];
} else {
cx[j] += xstep;
cy[j] += ystep;
cw[j] += wstep;
ch[j] += hstep;
}
}
}
for (j = 0; j < FRAMES; j++)
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
for (j = 0; j < FRAMES; j++)
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
XUngrabServer(dpy);
}
#undef FRAMES
void animateResize(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh)
{
int style = wPreferences.iconification_style; /* Catch the value */
int steps;
if (style == WIS_NONE)
return;
if (style == WIS_RANDOM)
style = rand() % 3;
switch (style) {
case WIS_TWIST:
steps = MINIATURIZE_ANIMATION_STEPS_T;
if (steps > 0)
animateResizeTwist(scr, x, y, w, h, fx, fy, fw, fh, steps);
break;
case WIS_FLIP:
steps = MINIATURIZE_ANIMATION_STEPS_F;
if (steps > 0)
animateResizeFlip(scr, x, y, w, h, fx, fy, fw, fh, steps);
break;
case WIS_ZOOM:
default:
steps = MINIATURIZE_ANIMATION_STEPS_Z;
if (steps > 0)
animateResizeZoom(scr, x, y, w, h, fx, fy, fw, fh, steps);
break;
}
}
#else
inline void animateResize(WScreen* scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh)
{
(void)scr;
(void)x;
(void)y;
(void)w;
(void)h;
(void)fx;
(void)fy;
(void)fw;
(void)fh;
}
#endif /* USE_ANIMATIONS */
#ifdef USE_ANIMATIONS
int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih)
{
if (wwin->screen_ptr->flags.startup || wPreferences.no_animations
|| wwin->flags.skip_next_animation || wwin->icon == NULL)
return 0;
if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
*ix = wwin->icon_x;
*iy = wwin->icon_y;
*iw = wwin->icon->core->width;
*ih = wwin->icon->core->height;
} else {
if (wwin->flags.net_handle_icon) {
*ix = wwin->icon_x;
*iy = wwin->icon_y;
*iw = wwin->icon_w;
*ih = wwin->icon_h;
} else {
*ix = 0;
*iy = 0;
*iw = wwin->screen_ptr->scr_width;
*ih = wwin->screen_ptr->scr_height;
}
}
return 1;
}
#else
inline int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih)
{
(void)wwin;
(void)ix;
(void)iy;
(void)iw;
(void)ih;
return 1;
}
#endif /* USE_ANIMATIONS */

View File

@@ -1,13 +0,0 @@
#ifndef WMANIMATION_H_
#define WMANIMATION_H_
#include "wmaker/WindowMaker.h"
#define UNSHADE 0
#define SHADE 1
void shade_animate(WWindow *wwin, Bool what);
void animateResize(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh);
int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih);
#endif // WMANIMATION_H_

View File

@@ -1,64 +0,0 @@
#include "wmaker/app_icon_paint.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/application_tracking.h"
#include "wmaker/icon_paint.h"
#include <X11/Xlib.h>
static void drawCorner(WIcon * icon)
{
WScreen *scr = icon->core->screen_ptr;
XPoint points[3];
points[0].x = 1;
points[0].y = 1;
points[1].x = 12;
points[1].y = 1;
points[2].x = 1;
points[2].y = 12;
XFillPolygon(dpy, icon->core->window, scr->icon_title_texture->normal_gc,
points, 3, Convex, CoordModeOrigin);
XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 0, 12);
XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 12, 0);
}
void wAppIconPaint(WAppIcon *aicon)
{
WApplication *wapp;
WScreen *scr = aicon->icon->core->screen_ptr;
if (aicon->icon->owner)
wapp = wApplicationOf(aicon->icon->owner->main_window);
else
wapp = NULL;
wIconPaint(aicon->icon);
# ifdef WS_INDICATOR
if (aicon->docked && scr->dock && scr->dock == aicon->dock && aicon->yindex == 0)
updateDockNumbers(scr);
# endif
if (aicon->docked && !aicon->running && aicon->command != NULL) {
XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window,
scr->copy_gc, 0, 0, scr->dock_dots->width, scr->dock_dots->height, 0, 0);
}
#ifdef HIDDENDOT
if (wapp && wapp->flags.hidden) {
XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
XCopyArea(dpy, scr->dock_dots->image,
aicon->icon->core->window, scr->copy_gc, 0, 0, 7, scr->dock_dots->height, 0, 0);
}
#endif /* HIDDENDOT */
if (aicon->omnipresent)
drawCorner(aicon->icon);
XSetClipMask(dpy, scr->copy_gc, None);
if (aicon->launching)
XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
0, 0, wPreferences.icon_size, wPreferences.icon_size);
}

View File

@@ -1,8 +0,0 @@
#ifndef WAPP_ICON_PAINT_H_
#define WAPP_ICON_PAINT_H_
#include "wmaker/WindowMaker.h"
void wAppIconPaint(WAppIcon *aicon);
#endif // WAPP_ICON_PAINT_H_

View File

@@ -1,62 +0,0 @@
#include "wmaker/app_menu_map.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/menu/move.h"
#include "wmaker/menu/realize.h"
#include "wmaker/stacking.h"
#include <X11/Xlib.h>
static void wMenuMap(WMenu * menu)
{
if (!menu->flags.realized) {
menu->flags.realized = 1;
wMenuRealize(menu);
}
if (menu->flags.app_menu && menu->parent == NULL) {
menu->frame_x = menu->frame->screen_ptr->app_menu_x;
menu->frame_y = menu->frame->screen_ptr->app_menu_y;
XMoveWindow(dpy, menu->frame->core->window, menu->frame_x, menu->frame_y);
}
XMapWindow(dpy, menu->frame->core->window);
wRaiseFrame(menu->frame->core);
menu->flags.mapped = 1;
}
static void mapmenus(WMenu * menu)
{
int i;
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
}
void wAppMenuMap(WMenu * menu, WWindow * wwin)
{
if (!menu)
return;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if (wwin && (wPreferences.focus_mode != WKF_CLICK)) {
int x, min;
min = 20; /* Keep at least 20 pixels visible */
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
} else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
}
mapmenus(menu);
}

View File

@@ -1,8 +0,0 @@
#ifndef WAPP_MENU_MAP_H_
#define WAPP_MENU_MAP_H_
#include "wmaker/WindowMaker.h"
void wAppMenuMap(WMenu *menu, WWindow *wwin);
#endif // WAPP_MENU_MAP_H_

View File

@@ -0,0 +1,11 @@
#ifndef WAPPEARANCE_SETTINGS_H_
#define WAPPEARANCE_SETTINGS_H_
/* appearance settings clientdata flags */
enum {
WFontSettings = 1 << 0,
WTextureSettings = 1 << 1,
WColorSettings = 1 << 2
};
#endif // WAPPEARANCE_SETTINGS_H_

View File

@@ -20,23 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/icon/appicon.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/dnd/xdnd_init.h"
#include "wmaker/icon/icon.h"
#include "wmaker/arrange_icons.h"
#include "wmaker/stacking.h"
/* #include "wmaker/application.h" */
/* #include "wmaker/dialog_interface.h" */
/* #include "wmaker/icon_base.h" */
/* #include "wmaker/stacking.h" */
/* #include "wmaker/window_icon.h" */
/* #ifdef USE_DOCK_XDND */
/* #include "wmaker/xdnd.h" */
/* #endif // USE_DOCK_XDND */
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -47,27 +31,29 @@
#include <sys/stat.h>
#include <errno.h>
/* #include "WindowMaker.h" */
/* #include "window.h" */
/* #include "icon.h" */
/* #include "actions.h" */
/* #include "stacking.h" */
/* #include "dock.h" */
/* #include "main.h" */
/* #include "defaults.h" */
/* #include "workspace.h" */
/* #include "superfluous.h" */
/* #include "menu.h" */
/* #include "framewin.h" */
/* #include "dialog.h" */
/* #include "xinerama.h" */
/* #include "client.h" */
/* #include "placement.h" */
/* #include "misc.h" */
/* #include "event.h" */
/* #ifdef USE_DOCK_XDND */
/* #include "xdnd.h" */
/* #endif */
#include "WindowMaker.h"
#include "window.h"
#include "icon.h"
#include "application.h"
#include "appicon.h"
#include "actions.h"
#include "stacking.h"
#include "dock.h"
#include "main.h"
#include "defaults.h"
#include "workspace.h"
#include "superfluous.h"
#include "menu.h"
#include "framewin.h"
#include "dialog.h"
#include "xinerama.h"
#include "client.h"
#include "placement.h"
#include "misc.h"
#include "event.h"
#ifdef USE_DOCK_XDND
#include "xdnd.h"
#endif
/*
* icon_file for the dock is got from the preferences file by
@@ -85,7 +71,42 @@ static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon);
static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon);
static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window);
WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile, struct WIconEventHandler *event_handler)
/* This function is used if the application is a .app. It checks if it has an icon in it
* like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
*/
void wApplicationExtractDirPackIcon(const char *path, const char *wm_instance, const char *wm_class)
{
char *iconPath = NULL;
char *tmp = NULL;
if (strstr(path, ".app")) {
tmp = wmalloc(strlen(path) + 16);
if (wPreferences.supports_tiff) {
strcpy(tmp, path);
strcat(tmp, ".tiff");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!iconPath) {
strcpy(tmp, path);
strcat(tmp, ".xpm");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!iconPath)
wfree(tmp);
if (iconPath) {
wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class);
wfree(iconPath);
}
}
}
WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile)
{
WAppIcon *aicon;
@@ -107,7 +128,7 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *w
if (wPreferences.flags.clip_merged_in_dock && wm_class != NULL && strcmp(wm_class, "WMDock") == 0)
tile = TILE_CLIP;
aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile, event_handler);
aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile);
#ifdef USE_DOCK_XDND
wXDNDMakeAwareness(aicon->icon->core->window);
@@ -331,6 +352,30 @@ void wAppIconDestroy(WAppIcon * aicon)
wrelease(aicon);
}
static void drawCorner(WIcon * icon)
{
WScreen *scr = icon->core->screen_ptr;
XPoint points[3];
points[0].x = 1;
points[0].y = 1;
points[1].x = 12;
points[1].y = 1;
points[2].x = 1;
points[2].y = 12;
XFillPolygon(dpy, icon->core->window, scr->icon_title_texture->normal_gc,
points, 3, Convex, CoordModeOrigin);
XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 0, 12);
XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 12, 0);
}
void wAppIconMove(WAppIcon * aicon, int x, int y)
{
XMoveWindow(dpy, aicon->icon->core->window, x, y);
aicon->x_pos = x;
aicon->y_pos = y;
}
#ifdef WS_INDICATOR
static void updateDockNumbers(WScreen *scr)
{
@@ -351,6 +396,46 @@ static void updateDockNumbers(WScreen *scr)
}
#endif /* WS_INDICATOR */
void wAppIconPaint(WAppIcon *aicon)
{
WApplication *wapp;
WScreen *scr = aicon->icon->core->screen_ptr;
if (aicon->icon->owner)
wapp = wApplicationOf(aicon->icon->owner->main_window);
else
wapp = NULL;
wIconPaint(aicon->icon);
# ifdef WS_INDICATOR
if (aicon->docked && scr->dock && scr->dock == aicon->dock && aicon->yindex == 0)
updateDockNumbers(scr);
# endif
if (aicon->docked && !aicon->running && aicon->command != NULL) {
XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window,
scr->copy_gc, 0, 0, scr->dock_dots->width, scr->dock_dots->height, 0, 0);
}
#ifdef HIDDENDOT
if (wapp && wapp->flags.hidden) {
XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
XCopyArea(dpy, scr->dock_dots->image,
aicon->icon->core->window, scr->copy_gc, 0, 0, 7, scr->dock_dots->height, 0, 0);
}
#endif /* HIDDENDOT */
if (aicon->omnipresent)
drawCorner(aicon->icon);
XSetClipMask(dpy, scr->copy_gc, None);
if (aicon->launching)
XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
0, 0, wPreferences.icon_size, wPreferences.icon_size);
}
/* Save the application icon, if it's a dockapp then use it with dock = True */
void save_appicon(WAppIcon *aicon)
{
@@ -430,7 +515,7 @@ static void unhideHereCallback(WMenu * menu, WMenuEntry * entry)
wUnhideApplication(wapp, False, True);
}
static void setIconCallback(WMenu *menu, WMenuEntry *entry, WDialogGenerator *dialog)
static void setIconCallback(WMenu *menu, WMenuEntry *entry)
{
WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon;
char *file = NULL;
@@ -455,9 +540,9 @@ static void setIconCallback(WMenu *menu, WMenuEntry *entry, WDialogGenerator *di
if (result) {
if (!icon->destroyed) {
if (!wIconChangeImageFile(icon->icon, file)) {
(dialog->message)(scr, _("Error"),
_("Could not open specified icon file"),
_("OK"), NULL, NULL);
wMessageDialog(scr, _("Error"),
_("Could not open specified icon file"),
_("OK"), NULL, NULL);
} else {
wDefaultChangeIcon(icon->wm_instance, icon->wm_class, file);
wAppIconPaint(icon);
@@ -494,7 +579,7 @@ static void killCallback(WMenu * menu, WMenuEntry * entry)
wretain(wapp->main_window_desc);
if (wPreferences.dont_confirm_kill
|| (dialog->message)(menu->frame->screen_ptr, _("Kill Application"),
|| wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
buffer, _("Yes"), _("No"), NULL) == WAPRDefault) {
if (fPtr != NULL) {
WWindow *wwin, *twin;
@@ -1007,6 +1092,46 @@ Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event)
}
}
/* This function save the application icon and store the path in the Dictionary */
static void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_instance, const char *wm_class)
{
WMPropList *dict = w_global.domain.window_attr->dictionary;
WMPropList *adict, *key, *iconk;
WMPropList *val;
char *tmp;
tmp = get_name_for_instance_class(wm_instance, wm_class);
key = WMCreatePLString(tmp);
wfree(tmp);
adict = WMGetFromPLDictionary(dict, key);
iconk = WMCreatePLString("Icon");
if (adict) {
val = WMGetFromPLDictionary(adict, iconk);
} else {
/* no dictionary for app, so create one */
adict = WMCreatePLDictionary(NULL, NULL);
WMPutInPLDictionary(dict, key, adict);
WMReleasePropList(adict);
val = NULL;
}
if (!val) {
val = WMCreatePLString(iconPath);
WMPutInPLDictionary(adict, iconk, val);
WMReleasePropList(val);
} else {
val = NULL;
}
WMReleasePropList(key);
WMReleasePropList(iconk);
if (val && !wPreferences.flags.noupdates)
UpdateDomainFile(w_global.domain.window_attr);
}
static WAppIcon *findDockIconFor(WDock *dock, Window main_window)
{
WAppIcon *aicon = NULL;

90
bazel/wmaker/appicon.h Normal file
View File

@@ -0,0 +1,90 @@
/* appicon.h- application icon
*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef WMAPPICON_H_
#define WMAPPICON_H_
#include "wrlib/wraster.h"
#include "window.h"
#include "icon.h"
#include "application.h"
typedef struct WAppIcon {
short xindex;
short yindex;
struct WAppIcon *next;
struct WAppIcon *prev;
WIcon *icon;
int x_pos, y_pos; /* absolute screen coordinate */
char *command; /* command used to launch app */
#ifdef USE_DOCK_XDND
char *dnd_command; /* command to use when something is */
/* dropped on us */
#endif
char *paste_command; /* command to run when
* something is pasted */
char *wm_class;
char *wm_instance;
pid_t pid; /* for apps launched from the dock */
Window main_window;
struct WDock *dock; /* In which dock is docked. */
struct _AppSettingsPanel *panel; /* Settings Panel */
unsigned int docked:1;
unsigned int omnipresent:1; /* If omnipresent when
* docked in clip */
unsigned int attracted:1; /* If it was attracted by the clip */
unsigned int launching:1;
unsigned int running:1; /* application is already running */
unsigned int relaunching:1; /* launching 2nd instance */
unsigned int forced_dock:1;
unsigned int auto_launch:1; /* launch app on startup */
unsigned int remote_start:1;
unsigned int updated:1;
unsigned int editing:1; /* editing docked icon */
unsigned int drop_launch:1; /* launching from drop action */
unsigned int paste_launch:1; /* launching from paste action */
unsigned int destroyed:1; /* appicon was destroyed */
unsigned int buggy_app:1; /* do not make dock rely on hints
* set by app */
unsigned int lock:1; /* do not allow to be destroyed */
} WAppIcon;
WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *wm_instance,
const char *wm_class, int tile);
Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event);
void wAppIconDestroy(WAppIcon *aicon);
void wAppIconPaint(WAppIcon *aicon);
void wAppIconMove(WAppIcon *aicon, int x, int y);
void create_appicon_for_application(WApplication *wapp, WWindow *wwin);
void removeAppIconFor(WApplication * wapp);
void save_appicon(WAppIcon *aicon);
void paint_app_icon(WApplication *wapp);
void unpaint_app_icon(WApplication *wapp);
void wApplicationExtractDirPackIcon(const char *path, const char *wm_instance,
const char *wm_class);
WAppIcon *wAppIconFor(Window window);
void appIconMouseDown(WObjDescriptor * desc, XEvent * event);
#endif

View File

@@ -1,109 +0,0 @@
#include "wmaker/appicon_files.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/update_domain_file.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "WINGs/WUtil.h"
char *get_name_for_instance_class(const char *wm_instance, const char *wm_class)
{
char *suffix;
int len;
if (wm_class && wm_instance) {
len = strlen(wm_class) + strlen(wm_instance) + 2;
suffix = wmalloc(len);
snprintf(suffix, len, "%s.%s", wm_instance, wm_class);
} else if (wm_class) {
len = strlen(wm_class) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wm_class);
} else if (wm_instance) {
len = strlen(wm_instance) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wm_instance);
} else {
return NULL;
}
return suffix;
}
/* This function saves the application icon and store the path in the Dictionary */
void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_instance, const char *wm_class)
{
WMPropList *dict = w_global.domain.window_attr->dictionary;
WMPropList *adict, *key, *iconk;
WMPropList *val;
char *tmp;
tmp = get_name_for_instance_class(wm_instance, wm_class);
key = WMCreatePLString(tmp);
wfree(tmp);
adict = WMGetFromPLDictionary(dict, key);
iconk = WMCreatePLString("Icon");
if (adict) {
val = WMGetFromPLDictionary(adict, iconk);
} else {
/* no dictionary for app, so create one */
adict = WMCreatePLDictionary(NULL, NULL);
WMPutInPLDictionary(dict, key, adict);
WMReleasePropList(adict);
val = NULL;
}
if (!val) {
val = WMCreatePLString(iconPath);
WMPutInPLDictionary(adict, iconk, val);
WMReleasePropList(val);
} else {
val = NULL;
}
WMReleasePropList(key);
WMReleasePropList(iconk);
if (val && !wPreferences.flags.noupdates)
UpdateDomainFile(w_global.domain.window_attr);
}
/* This function is used if the application is a .app. It checks if it has an icon in it
* like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
*/
void wApplicationExtractDirPackIcon(const char *path, const char *wm_instance, const char *wm_class)
{
char *iconPath = NULL;
char *tmp = NULL;
if (strstr(path, ".app")) {
tmp = wmalloc(strlen(path) + 16);
if (wPreferences.supports_tiff) {
strcpy(tmp, path);
strcat(tmp, ".tiff");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!iconPath) {
strcpy(tmp, path);
strcat(tmp, ".xpm");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!iconPath)
wfree(tmp);
if (iconPath) {
wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class);
wfree(iconPath);
}
}
}

View File

@@ -1,10 +0,0 @@
#ifndef WMEXTRACT_DIR_PACK_ICON_H_
#define WMEXTRACT_DIR_PACK_ICON_H_
char *get_name_for_instance_class(const char *wm_instance, const char *wm_class);
void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_instance, const char *wm_class);
void wApplicationExtractDirPackIcon(const char *path, const char *wm_instance, const char *wm_class);
#endif // WMEXTRACT_DIR_PACK_ICON_H_

View File

@@ -18,33 +18,24 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/appicon.h"
#include "wmaker/application_tracking.h"
#include "wmaker/appmenu.h"
#include "wmaker/defaults.h"
#include "wmaker/dock.h"
#include "wmaker/find_image.h"
#include "wmaker/properties.h"
#include "wmaker/window.h"
#include "wmaker/window_tracking.h"
#include "wconfig.h"
#include <X11/Xlib.h>
#include <string.h>
/* #include "menu.h" */
/* #include "window.h" */
/* #ifdef USER_MENU */
/* #include "usermenu.h" */
/* #endif /\* USER_MENU *\/ */
/* #include "appicon.h" */
/* #include "application.h" */
/* #include "appmenu.h" */
/* #include "properties.h" */
/* #include "workspace.h" */
/* #include "dock.h" */
/* #include "defaults.h" */
#include "WindowMaker.h"
#include "menu.h"
#include "window.h"
#ifdef USER_MENU
#include "usermenu.h"
#endif /* USER_MENU */
#include "appicon.h"
#include "application.h"
#include "appmenu.h"
#include "properties.h"
#include "workspace.h"
#include "dock.h"
#include "defaults.h"
/******** Local variables ********/
@@ -72,6 +63,17 @@ static WWindow *makeMainWindow(WScreen * scr, Window window)
return wwin;
}
WApplication *wApplicationOf(Window window)
{
WApplication *wapp;
if (window == None)
return NULL;
if (XFindContext(dpy, window, w_global.context.app_win, (XPointer *) & wapp) != XCSUCCESS)
return NULL;
return wapp;
}
WApplication *wApplicationCreate(WWindow * wwin)
{
WScreen *scr = wwin->screen_ptr;
@@ -195,3 +197,19 @@ void wApplicationDestroy(WApplication *wapp)
}
wfree(wapp);
}
void wApplicationActivate(WApplication *wapp)
{
if (wapp->app_icon) {
wIconSetHighlited(wapp->app_icon->icon, True);
wAppIconPaint(wapp->app_icon);
}
}
void wApplicationDeactivate(WApplication *wapp)
{
if (wapp->app_icon) {
wIconSetHighlited(wapp->app_icon->icon, False);
wAppIconPaint(wapp->app_icon);
}
}

View File

@@ -22,14 +22,35 @@
#ifndef WMAPPLICATION_H_
#define WMAPPLICATION_H_
#include "wmaker/WindowMaker.h"
/* for tracking single application instances */
typedef struct WApplication {
struct WApplication *next;
struct WApplication *prev;
Window main_window; /* ID of the group leader */
struct WWindow *main_window_desc; /* main (leader) window descriptor */
WMenu *menu; /* application menu */
struct WAppIcon *app_icon;
int refcount;
struct WWindow *last_focused; /* focused window before hide */
int last_workspace; /* last workspace used to work on the
* app */
WMHandlerID *urgent_bounce_timer;
struct {
unsigned int skip_next_animation:1;
unsigned int hidden:1;
unsigned int emulated:1;
unsigned int bouncing:1;
} flags;
} WApplication;
// The type definition for WApplication is in WindowMaker.h.
WApplication *wApplicationCreate(struct WWindow *wwin);
WApplication *wApplicationOf(Window window);
void wApplicationDestroy(WApplication *wapp);
void wAppBounce(WApplication *);
void wAppBounceWhileUrgent(WApplication *);
void wApplicationActivate(WApplication *);
void wApplicationDeactivate(WApplication *);
#endif

View File

@@ -1,16 +0,0 @@
#include "wmaker/application_tracking.h"
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
WApplication *wApplicationOf(Window window)
{
WApplication *wapp;
if (window == None)
return NULL;
if (XFindContext(dpy, window, w_global.context.app_win, (XPointer *) & wapp) != XCSUCCESS)
return NULL;
return wapp;
}

View File

@@ -1,9 +0,0 @@
#ifndef WMAPPLICATION_TRACKING_H_
#define WMAPPLICATION_TRACKING_H_
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
WApplication *wApplicationOf(Window window);
#endif // WMAPPLICATION_TRACKING_H_

View File

@@ -236,3 +236,61 @@ void wAppMenuDestroy(WMenu * menu)
if (menu)
wMenuDestroy(menu, True);
}
static void mapmenus(WMenu * menu)
{
int i;
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
}
void wAppMenuMap(WMenu * menu, WWindow * wwin)
{
if (!menu)
return;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if (wwin && (wPreferences.focus_mode != WKF_CLICK)) {
int x, min;
min = 20; /* Keep at least 20 pixels visible */
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
} else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
}
mapmenus(menu);
}
static void unmapmenus(WMenu * menu)
{
int i;
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
}
void wAppMenuUnmap(WMenu * menu)
{
if (menu)
unmapmenus(menu);
}

View File

@@ -25,5 +25,8 @@
WMenu *wAppMenuGet(WScreen *scr, Window window);
void wAppMenuDestroy(WMenu *menu);
void wAppMenuMap(WMenu *menu, WWindow *wwin);
void wAppMenuUnmap(WMenu *menu);
#endif

View File

@@ -1,162 +0,0 @@
#include "wmaker/arrange_icons.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/placement.h"
#include "wmaker/xinerama.h"
#include <X11/Xlib.h>
void wAppIconMove(WAppIcon * aicon, int x, int y)
{
XMoveWindow(dpy, aicon->icon->core->window, x, y);
aicon->x_pos = x;
aicon->y_pos = y;
}
void wArrangeIcons(WScreen *scr, Bool arrangeAll)
{
WWindow *wwin;
WAppIcon *aicon;
int head;
const int heads = wXineramaHeads(scr);
struct HeadVars {
int pf; /* primary axis */
int sf; /* secondary axis */
int fullW;
int fullH;
int pi, si;
int sx1, sx2, sy1, sy2; /* screen boundary */
int sw, sh;
int xo, yo;
int xs, ys;
} *vars;
int isize = wPreferences.icon_size;
vars = (struct HeadVars *)wmalloc(sizeof(struct HeadVars) * heads);
for (head = 0; head < heads; ++head) {
WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
WMRect rect;
if (scr->dock) {
int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE;
if (scr->dock->on_right_side)
area.x2 -= offset;
else
area.x1 += offset;
}
rect = wmkrect(area.x1, area.y1, area.x2 - area.x1, area.y2 - area.y1);
vars[head].pi = vars[head].si = 0;
vars[head].sx1 = rect.pos.x;
vars[head].sy1 = rect.pos.y;
vars[head].sw = rect.size.width;
vars[head].sh = rect.size.height;
vars[head].sx2 = vars[head].sx1 + vars[head].sw;
vars[head].sy2 = vars[head].sy1 + vars[head].sh;
vars[head].sw = isize * (vars[head].sw / isize);
vars[head].sh = isize * (vars[head].sh / isize);
vars[head].fullW = (vars[head].sx2 - vars[head].sx1) / isize;
vars[head].fullH = (vars[head].sy2 - vars[head].sy1) / isize;
/* icon yard boundaries */
if (wPreferences.icon_yard & IY_VERT) {
vars[head].pf = vars[head].fullH;
vars[head].sf = vars[head].fullW;
} else {
vars[head].pf = vars[head].fullW;
vars[head].sf = vars[head].fullH;
}
if (wPreferences.icon_yard & IY_RIGHT) {
vars[head].xo = vars[head].sx2 - isize;
vars[head].xs = -1;
} else {
vars[head].xo = vars[head].sx1;
vars[head].xs = 1;
}
if (wPreferences.icon_yard & IY_TOP) {
vars[head].yo = vars[head].sy1;
vars[head].ys = 1;
} else {
vars[head].yo = vars[head].sy2 - isize;
vars[head].ys = -1;
}
}
#define X ((wPreferences.icon_yard & IY_VERT) \
? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
: vars[head].xo + vars[head].xs*(vars[head].pi*isize))
#define Y ((wPreferences.icon_yard & IY_VERT) \
? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
: vars[head].yo + vars[head].ys*(vars[head].si*isize))
/* arrange application icons */
aicon = scr->app_icon_list;
/* reverse them to avoid unnecessarily sliding of icons */
while (aicon && aicon->next)
aicon = aicon->next;
while (aicon) {
if (!aicon->docked) {
/* CHECK: can icon be NULL here ? */
/* The intention here is to place the AppIcon on the head that
* contains most of the applications _main_ window. */
head = wGetHeadForWindow(aicon->icon->owner);
if (aicon->x_pos != X || aicon->y_pos != Y) {
#ifdef USE_ANIMATIONS
if (!wPreferences.no_animations)
slide_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y);
#endif /* USE_ANIMATIONS */
}
wAppIconMove(aicon, X, Y);
vars[head].pi++;
if (vars[head].pi >= vars[head].pf) {
vars[head].pi = 0;
vars[head].si++;
}
}
aicon = aicon->prev;
}
/* arrange miniwindows */
wwin = scr->focused_window;
/* reverse them to avoid unnecessarily shuffling */
while (wwin && wwin->prev)
wwin = wwin->prev;
while (wwin) {
if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden &&
(wwin->frame->workspace == scr->current_workspace ||
IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) {
head = wGetHeadForWindow(wwin);
if (arrangeAll || !wwin->flags.icon_moved) {
if (wwin->icon_x != X || wwin->icon_y != Y)
move_window(wwin->icon->core->window, wwin->icon_x, wwin->icon_y, X, Y);
wwin->icon_x = X;
wwin->icon_y = Y;
vars[head].pi++;
if (vars[head].pi >= vars[head].pf) {
vars[head].pi = 0;
vars[head].si++;
}
}
}
if (arrangeAll)
wwin->flags.icon_moved = 0;
/* we reversed the order, so we use next */
wwin = wwin->next;
}
wfree(vars);
}

View File

@@ -1,9 +0,0 @@
#ifndef WARRANGE_ICONS_H_
#define WARRANGE_ICONS_H_
#include "wmaker/WindowMaker.h"
void wAppIconMove(WAppIcon *aicon, int x, int y);
void wArrangeIcons(WScreen *scr, Bool arrangeAll);
#endif // WARRANGE_ICONS_H_

View File

@@ -1,212 +0,0 @@
#include "wmaker/atoms.h"
#include "wmaker/properties.h"
#include <X11/X.h>
#include <X11/Xlib.h>
/* Root Window Properties */
static Atom net_supported;
static Atom net_client_list;
static Atom net_client_list_stacking;
static Atom net_number_of_desktops;
static Atom net_desktop_geometry;
static Atom net_desktop_viewport;
static Atom net_current_desktop;
static Atom net_desktop_names;
static Atom net_active_window;
static Atom net_workarea;
static Atom net_supporting_wm_check;
static Atom net_virtual_roots; /* N/A */
static Atom net_desktop_layout; /* XXX */
static Atom net_showing_desktop;
/* Other Root Window Messages */
static Atom net_close_window;
static Atom net_moveresize_window; /* TODO */
static Atom net_wm_moveresize; /* TODO */
/* Application Window Properties */
static Atom net_wm_name;
static Atom net_wm_visible_name; /* TODO (unnecessary?) */
static Atom net_wm_icon_name;
static Atom net_wm_visible_icon_name; /* TODO (unnecessary?) */
static Atom net_wm_desktop;
#ifdef USE_XINERAMA
static Atom net_wm_fullscreen_monitors;
#endif
static Atom net_wm_window_type;
static Atom net_wm_window_type_desktop;
static Atom net_wm_window_type_dock;
static Atom net_wm_window_type_toolbar;
static Atom net_wm_window_type_menu;
static Atom net_wm_window_type_utility;
static Atom net_wm_window_type_splash;
static Atom net_wm_window_type_dialog;
static Atom net_wm_window_type_dropdown_menu;
static Atom net_wm_window_type_popup_menu;
static Atom net_wm_window_type_tooltip;
static Atom net_wm_window_type_notification;
static Atom net_wm_window_type_combo;
static Atom net_wm_window_type_dnd;
static Atom net_wm_window_type_normal;
static Atom net_wm_state;
static Atom net_wm_state_modal; /* XXX: what is this?!? */
static Atom net_wm_state_sticky;
static Atom net_wm_state_maximized_vert;
static Atom net_wm_state_maximized_horz;
static Atom net_wm_state_shaded;
static Atom net_wm_state_skip_taskbar;
static Atom net_wm_state_skip_pager;
static Atom net_wm_state_hidden;
static Atom net_wm_state_fullscreen;
static Atom net_wm_state_above;
static Atom net_wm_state_below;
static Atom net_wm_state_focused;
static Atom net_wm_allowed_actions;
static Atom net_wm_action_move;
static Atom net_wm_action_resize;
static Atom net_wm_action_minimize;
static Atom net_wm_action_shade;
static Atom net_wm_action_stick;
static Atom net_wm_action_maximize_horz;
static Atom net_wm_action_maximize_vert;
static Atom net_wm_action_fullscreen;
static Atom net_wm_action_change_desktop;
static Atom net_wm_action_close;
static Atom net_wm_strut;
static Atom net_wm_strut_partial; /* TODO: doesn't really fit into the current strut scheme */
static Atom net_wm_icon_geometry; /* FIXME: should work together with net_wm_handled_icons, gnome-panel-2.2.0.1 doesn't use _NET_WM_HANDLED_ICONS, thus present situation. */
Atom wm_global_net_wm_icon;
static Atom net_wm_pid; /* TODO */
static Atom net_wm_handled_icons; /* FIXME: see net_wm_icon_geometry */
static Atom net_wm_window_opacity;
static Atom net_frame_extents;
/* Window Manager Protocols */
static Atom net_wm_ping; /* TODO */
static Atom utf8_string;
atomitem_t atomNames[] = {
{"_NET_SUPPORTED", &net_supported},
{"_NET_CLIENT_LIST", &net_client_list},
{"_NET_CLIENT_LIST_STACKING", &net_client_list_stacking},
{"_NET_NUMBER_OF_DESKTOPS", &net_number_of_desktops},
{"_NET_DESKTOP_GEOMETRY", &net_desktop_geometry},
{"_NET_DESKTOP_VIEWPORT", &net_desktop_viewport},
{"_NET_CURRENT_DESKTOP", &net_current_desktop},
{"_NET_DESKTOP_NAMES", &net_desktop_names},
{"_NET_ACTIVE_WINDOW", &net_active_window},
{"_NET_WORKAREA", &net_workarea},
{"_NET_SUPPORTING_WM_CHECK", &net_supporting_wm_check},
{"_NET_VIRTUAL_ROOTS", &net_virtual_roots},
{"_NET_DESKTOP_LAYOUT", &net_desktop_layout},
{"_NET_SHOWING_DESKTOP", &net_showing_desktop},
{"_NET_CLOSE_WINDOW", &net_close_window},
{"_NET_MOVERESIZE_WINDOW", &net_moveresize_window},
{"_NET_WM_MOVERESIZE", &net_wm_moveresize},
{"_NET_WM_NAME", &net_wm_name},
{"_NET_WM_VISIBLE_NAME", &net_wm_visible_name},
{"_NET_WM_ICON_NAME", &net_wm_icon_name},
{"_NET_WM_VISIBLE_ICON_NAME", &net_wm_visible_icon_name},
{"_NET_WM_DESKTOP", &net_wm_desktop},
#ifdef USE_XINERAMA
{"_NET_WM_FULLSCREEN_MONITORS", &net_wm_fullscreen_monitors},
#endif
{"_NET_WM_WINDOW_TYPE", &net_wm_window_type},
{"_NET_WM_WINDOW_TYPE_DESKTOP", &net_wm_window_type_desktop},
{"_NET_WM_WINDOW_TYPE_DOCK", &net_wm_window_type_dock},
{"_NET_WM_WINDOW_TYPE_TOOLBAR", &net_wm_window_type_toolbar},
{"_NET_WM_WINDOW_TYPE_MENU", &net_wm_window_type_menu},
{"_NET_WM_WINDOW_TYPE_UTILITY", &net_wm_window_type_utility},
{"_NET_WM_WINDOW_TYPE_SPLASH", &net_wm_window_type_splash},
{"_NET_WM_WINDOW_TYPE_DIALOG", &net_wm_window_type_dialog},
{"_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", &net_wm_window_type_dropdown_menu},
{"_NET_WM_WINDOW_TYPE_POPUP_MENU", &net_wm_window_type_popup_menu},
{"_NET_WM_WINDOW_TYPE_TOOLTIP", &net_wm_window_type_tooltip},
{"_NET_WM_WINDOW_TYPE_NOTIFICATION", &net_wm_window_type_notification},
{"_NET_WM_WINDOW_TYPE_COMBO", &net_wm_window_type_combo},
{"_NET_WM_WINDOW_TYPE_DND", &net_wm_window_type_dnd},
{"_NET_WM_WINDOW_TYPE_NORMAL", &net_wm_window_type_normal},
{"_NET_WM_STATE", &net_wm_state},
{"_NET_WM_STATE_MODAL", &net_wm_state_modal},
{"_NET_WM_STATE_STICKY", &net_wm_state_sticky},
{"_NET_WM_STATE_MAXIMIZED_VERT", &net_wm_state_maximized_vert},
{"_NET_WM_STATE_MAXIMIZED_HORZ", &net_wm_state_maximized_horz},
{"_NET_WM_STATE_SHADED", &net_wm_state_shaded},
{"_NET_WM_STATE_SKIP_TASKBAR", &net_wm_state_skip_taskbar},
{"_NET_WM_STATE_SKIP_PAGER", &net_wm_state_skip_pager},
{"_NET_WM_STATE_HIDDEN", &net_wm_state_hidden},
{"_NET_WM_STATE_FULLSCREEN", &net_wm_state_fullscreen},
{"_NET_WM_STATE_ABOVE", &net_wm_state_above},
{"_NET_WM_STATE_BELOW", &net_wm_state_below},
{"_NET_WM_STATE_FOCUSED", &net_wm_state_focused},
{"_NET_WM_ALLOWED_ACTIONS", &net_wm_allowed_actions},
{"_NET_WM_ACTION_MOVE", &net_wm_action_move},
{"_NET_WM_ACTION_RESIZE", &net_wm_action_resize},
{"_NET_WM_ACTION_MINIMIZE", &net_wm_action_minimize},
{"_NET_WM_ACTION_SHADE", &net_wm_action_shade},
{"_NET_WM_ACTION_STICK", &net_wm_action_stick},
{"_NET_WM_ACTION_MAXIMIZE_HORZ", &net_wm_action_maximize_horz},
{"_NET_WM_ACTION_MAXIMIZE_VERT", &net_wm_action_maximize_vert},
{"_NET_WM_ACTION_FULLSCREEN", &net_wm_action_fullscreen},
{"_NET_WM_ACTION_CHANGE_DESKTOP", &net_wm_action_change_desktop},
{"_NET_WM_ACTION_CLOSE", &net_wm_action_close},
{"_NET_WM_STRUT", &net_wm_strut},
{"_NET_WM_STRUT_PARTIAL", &net_wm_strut_partial},
{"_NET_WM_ICON_GEOMETRY", &net_wm_icon_geometry},
{"_NET_WM_ICON", &wm_global_net_wm_icon},
{"_NET_WM_PID", &net_wm_pid},
{"_NET_WM_HANDLED_ICONS", &net_wm_handled_icons},
{"_NET_WM_WINDOW_OPACITY", &net_wm_window_opacity},
{"_NET_FRAME_EXTENTS", &net_frame_extents},
{"_NET_WM_PING", &net_wm_ping},
{"UTF8_STRING", &utf8_string},
};
char *wNETWMGetWindowName(Window window)
{
char *name;
char *ret;
int size;
name = (char *)PropGetCheckProperty(window, net_wm_name, utf8_string, 0, 0, &size);
if (name) {
ret = wstrndup(name, size);
XFree(name);
} else {
ret = NULL;
}
return ret;
}
char *wNETWMGetIconName(Window window)
{
char *name;
char *ret;
int size;
name = (char *)PropGetCheckProperty(window, net_wm_icon_name, utf8_string, 0, 0, &size);
if (name) {
ret = wstrndup(name, size);
XFree(name);
} else {
ret = NULL;
}
return ret;
}
void wNETCleanupFrameExtents(WWindow *wwin)
{
XDeleteProperty(dpy, wwin->client_win, net_frame_extents);
}

View File

@@ -1,25 +0,0 @@
#ifndef WATOMS_H_
#define WATOMS_H_
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
typedef struct {
char *name;
Atom *atom;
} atomitem_t;
extern Atom wm_global_net_wm_icon;
#ifdef USE_XINERAMA
extern atomitem_t wm_global_atomNames[72];
#else
extern atomitem_t wm_global_atomNames[71];
#endif // USE_XINERAMA
char *wNETWMGetIconName(Window window);
char *wNETWMGetWindowName(Window window);
void wNETCleanupFrameExtents(WWindow *wwin);
#endif // WATOMS_H_

View File

@@ -19,10 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/application_tracking.h"
#include "wmaker/icon_base.h"
#include "wmaker/shrink_string.h"
#include "wconfig.h"
#ifdef BALLOON_TEXT

View File

@@ -1,83 +0,0 @@
#include "wmaker/child_process.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/dialog_interface.h"
#include "wmaker/runtime.h"
#include "wmaker/setup_environment.h"
#include <unistd.h>
#include "WINGs/WUtil.h"
typedef struct {
WScreen *scr;
char *command;
WMessageDialog_fn_t *message_fn;
} _tuple;
static void shellCommandHandler(pid_t pid, unsigned int status, void *client_data)
{
_tuple *data = (_tuple *) client_data;
/* Parameter not used, but tell the compiler that it is ok */
(void) pid;
if (status == 127) {
char *buffer;
buffer = wstrconcat(_("Could not execute command: "), data->command);
if (data->message_fn != NULL)
(data->message_fn)(data->scr, _("Error"), buffer, _("OK"), NULL, NULL);
wfree(buffer);
} else if (status != 127) {
/*
printf("%s: %i\n", data->command, status);
*/
}
wfree(data->command);
wfree(data);
}
void ExecuteShellCommand(WScreen *scr, const char *command, WMessageDialog_fn_t *message_fn)
{
static char *shell = NULL;
pid_t pid;
/*
* This have a problem: if the shell is tcsh (not sure about others)
* and ~/.tcshrc have /bin/stty erase ^H somewhere on it, the shell
* will block and the command will not be executed.
if (!shell) {
shell = getenv("SHELL");
if (!shell)
shell = "/bin/sh";
}
*/
shell = "/bin/sh";
pid = fork();
if (pid == 0) {
SetupEnvironment(scr);
#ifdef HAVE_SETSID
setsid();
#endif
execl(shell, shell, "-c", command, NULL);
werror("could not execute %s -c %s", shell, command);
Exit(-1);
} else if (pid < 0) {
werror("cannot fork a new process");
} else {
_tuple *data = wmalloc(sizeof(_tuple));
data->scr = scr;
data->command = wstrdup(command);
data->message_fn = message_fn;
wAddDeathHandler(pid, shellCommandHandler, data);
}
}

View File

@@ -1,16 +0,0 @@
#ifndef WMCHILD_PROCESS_H_
#define WMCHILD_PROCESS_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/dialog_interface.h"
typedef void (WDeathHandler)(pid_t pid, unsigned int status, void *cdata);
void ExecuteShellCommand(WScreen *scr, const char *command, WMessageDialog_fn_t *message_fn);
WMagicNumber wAddDeathHandler(pid_t pid, WDeathHandler *callback, void *cdata);
/* called from the signal handler */
void NotifyDeadProcess(pid_t pid, unsigned char status);
#endif // Wmchild_Process_H_

View File

@@ -17,23 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/actions.h"
#include "wmaker/app_icon_paint.h"
#include "wmaker/application.h"
#include "wmaker/application_tracking.h"
#include "wmaker/appmenu.h"
#include "wmaker/client.h"
#include "wmaker/colormap.h"
#include "wmaker/destroy.h"
#include "wmaker/misc.h"
#include "wmaker/properties.h"
#include "wmaker/framewin.h"
#include "wmaker/icon.h"
#include "wmaker/stacking.h"
#include "wmaker/window_tracking.h"
#include "wmaker/wmspec.h"
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -46,17 +30,75 @@
#include <stdio.h>
#include <string.h>
/* #include "window.h" */
/* #include "properties.h" */
/* #include "actions.h" */
/* #include "icon.h" */
/* #include "client.h" */
/* #include "colormap.h" */
/* #include "stacking.h" */
/* #include "appicon.h" */
/* #include "appmenu.h" */
/* #include "wmspec.h" */
/* #include "misc.h" */
#include "WindowMaker.h"
#include "framewin.h"
#include "window.h"
#include "properties.h"
#include "actions.h"
#include "icon.h"
#include "client.h"
#include "colormap.h"
#include "stacking.h"
#include "appicon.h"
#include "appmenu.h"
#include "wmspec.h"
#include "misc.h"
/*
*--------------------------------------------------------------------
* wClientRestore--
* Reparent the window back to the root window.
*
*--------------------------------------------------------------------
*/
void wClientRestore(WWindow * wwin)
{
#if 0
int gx, gy;
wClientGetGravityOffsets(wwin, &gx, &gy);
/* set the position of the frame on screen */
wwin->frame_x -= gx * wwin->screen_ptr->frame_border_width;
wwin->frame_y -= gy * wwin->screen_ptr->frame_border_width;
/* if gravity is to the south, account for the border sizes */
if (gy > 0)
wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width);
#endif
XSetWindowBorderWidth(dpy, wwin->client_win, wwin->old_border_width);
XReparentWindow(dpy, wwin->client_win, wwin->screen_ptr->root_win, wwin->frame_x, wwin->frame_y);
/* don't let the window get iconified after restart */
/*
if (wwin->flags.shaded)
wClientSetState(wwin, NormalState, None);
*/
}
/*
*----------------------------------------------------------------------
* wClientSetState--
* Set the state of the client window to one of the window
* states defined in ICCCM (Iconic, Withdrawn, Normal)
*
* Side effects:
* The WM_STATE property of the window is updated as well as the
* WWindow.state variable.
*----------------------------------------------------------------------
*/
void wClientSetState(WWindow * wwin, int state, Window icon_win)
{
long data[2];
wwin->state = state;
data[0] = (unsigned long)state;
data[1] = (unsigned long)icon_win;
XChangeProperty(dpy, wwin->client_win, w_global.atom.wm.state,
w_global.atom.wm.state, 32, PropModeReplace,
(unsigned char *)data, 2);
}
void wClientGetGravityOffsets(WWindow * wwin, int *ofs_x, int *ofs_y)
{
@@ -211,6 +253,30 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
}
}
void wClientSendProtocol(WWindow * wwin, Atom protocol, Time time)
{
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = w_global.atom.wm.protocols;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = wwin->client_win;
event.xclient.data.l[0] = protocol;
event.xclient.data.l[1] = time;
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, wwin->client_win, False, NoEventMask, &event);
XSync(dpy, False);
}
void wClientKill(WWindow * wwin)
{
XKillClient(dpy, wwin->client_win);
XFlush(dpy);
}
/*
*----------------------------------------------------------------------
* wClientCheckProperty--

View File

@@ -21,8 +21,13 @@
#ifndef WMCLIENT_H_
#define WMCLIENT_H_
void wClientSetState(WWindow *wwin, int state, Window icon_win);
void wClientRestore(WWindow *wwin);
void wClientConfigure(WWindow *wwin, XConfigureRequestEvent *xcre);
void wClientGetGravityOffsets(WWindow *wwin, int *ofs_x, int *ofs_y);
void wClientSendProtocol(WWindow *wwin, Atom protocol, Time time);
void wClientKill(WWindow *wwin);
void wClientCheckProperty(WWindow *wwin, XPropertyEvent *event);

View File

@@ -1,11 +0,0 @@
#include "wmaker/client_kill.h"
#include <X11/Xlib.h>
void wClientKill(WWindow * wwin)
{
XKillClient(dpy, wwin->client_win);
XFlush(dpy);
}

View File

@@ -1,8 +0,0 @@
#ifndef WMCLIENT_KILL_H_
#define WMCLIENT_KILL_H_
#include "wmaker/WindowMaker.h"
void wClientKill(WWindow *wwin);
#endif // WMCLIENT_KILL_H_

View File

@@ -1,22 +0,0 @@
#include "wmaker/client_send_protocol.h"
#include "wmaker/WindowMaker.h"
#include <X11/Xlib.h>
void wClientSendProtocol(WWindow * wwin, Atom protocol, Time time)
{
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = w_global.atom.wm.protocols;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = wwin->client_win;
event.xclient.data.l[0] = protocol;
event.xclient.data.l[1] = time;
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, wwin->client_win, False, NoEventMask, &event);
XSync(dpy, False);
}

View File

@@ -1,10 +0,0 @@
#ifndef WCLIENT_SEND_PROTOCOL_H_
#define WCLIENT_SEND_PROTOCOL_H_
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
void wClientSendProtocol(WWindow *wwin, Atom protocol, Time time);
#endif // WCLIENT_SEND_PROTOCOL_H_

View File

@@ -1,28 +0,0 @@
#include "wmaker/client_set_state.h"
#include <X11/Xlib.h>
/*
*----------------------------------------------------------------------
* wClientSetState--
* Set the state of the client window to one of the window
* states defined in ICCCM (Iconic, Withdrawn, Normal)
*
* Side effects:
* The WM_STATE property of the window is updated as well as the
* WWindow.state variable.
*----------------------------------------------------------------------
*/
void wClientSetState(WWindow * wwin, int state, Window icon_win)
{
long data[2];
wwin->state = state;
data[0] = (unsigned long)state;
data[1] = (unsigned long)icon_win;
XChangeProperty(dpy, wwin->client_win, w_global.atom.wm.state,
w_global.atom.wm.state, 32, PropModeReplace,
(unsigned char *)data, 2);
}

View File

@@ -1,8 +0,0 @@
#ifndef WCLIENT_SET_STATE_H_
#define WCLIENT_SET_STATE_H_
#include "wmaker/WindowMaker.h"
void wClientSetState(WWindow *wwin, int state, Window icon_win);
#endif // WCLIENT_SET_STATE_H_

View File

@@ -1,116 +0,0 @@
#include "wmaker/clip_actions.h"
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
static void clipEnterNotify(WObjDescriptor *desc, XEvent *event);
static void clipLeaveNotify(WObjDescriptor *desc, XEvent *event);
static void clipLeave(WDock *dock);
struct wm_global_clip_actions =
{
.enterNotify = &clipEnterNotify,
.leaveNotify = &clipLeaveNotify,
.leave = &clipLeave,
};
static void clipEnterNotify(WObjDescriptor *desc, XEvent *event)
{
WAppIcon *btn = (WAppIcon *) desc->parent;
WDock *dock, *tmp;
WScreen *scr;
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
assert(event->type == EnterNotify);
if (desc->parent_type != WCLASS_DOCK_ICON)
return;
scr = btn->icon->core->screen_ptr;
dock = btn->dock;
if (dock == NULL)
return;
/* The auto raise/lower code */
tmp = (dock->type == WM_DRAWER ? scr->dock : dock);
if (tmp->auto_lower_magic) {
WMDeleteTimerHandler(tmp->auto_lower_magic);
tmp->auto_lower_magic = NULL;
}
if (tmp->auto_raise_lower && !tmp->auto_raise_magic)
tmp->auto_raise_magic = WMAddTimerHandler(wPreferences.clip_auto_raise_delay, clipAutoRaise, (void *) tmp);
if (dock->type != WM_CLIP && dock->type != WM_DRAWER)
return;
/* The auto expand/collapse code */
if (dock->auto_collapse_magic) {
WMDeleteTimerHandler(dock->auto_collapse_magic);
dock->auto_collapse_magic = NULL;
}
if (dock->auto_collapse && !dock->auto_expand_magic)
dock->auto_expand_magic = WMAddTimerHandler(wPreferences.clip_auto_expand_delay, clipAutoExpand, (void *)dock);
}
static void clipLeave(WDock *dock)
{
XEvent event;
WObjDescriptor *desc = NULL;
WDock *tmp;
if (dock == NULL)
return;
if (XCheckTypedEvent(dpy, EnterNotify, &event) != False) {
if (XFindContext(dpy, event.xcrossing.window, w_global.context.client_win,
(XPointer *) & desc) != XCNOENT
&& desc && desc->parent_type == WCLASS_DOCK_ICON
&& ((WAppIcon *) desc->parent)->dock == dock) {
/* We haven't left the dock/clip/drawer yet */
XPutBackEvent(dpy, &event);
return;
}
XPutBackEvent(dpy, &event);
} else {
/* We entered a withdrawn window, so we're still in Clip */
return;
}
tmp = (dock->type == WM_DRAWER ? dock->screen_ptr->dock : dock);
if (tmp->auto_raise_magic) {
WMDeleteTimerHandler(tmp->auto_raise_magic);
tmp->auto_raise_magic = NULL;
}
if (tmp->auto_raise_lower && !tmp->auto_lower_magic)
tmp->auto_lower_magic = WMAddTimerHandler(wPreferences.clip_auto_lower_delay, clipAutoLower, (void *)tmp);
if (dock->type != WM_CLIP && dock->type != WM_DRAWER)
return;
if (dock->auto_expand_magic) {
WMDeleteTimerHandler(dock->auto_expand_magic);
dock->auto_expand_magic = NULL;
}
if (dock->auto_collapse && !dock->auto_collapse_magic)
dock->auto_collapse_magic = WMAddTimerHandler(wPreferences.clip_auto_collapse_delay, clipAutoCollapse, (void *)dock);
}
static void clipLeaveNotify(WObjDescriptor *desc, XEvent *event)
{
WAppIcon *btn = (WAppIcon *) desc->parent;
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
assert(event->type == LeaveNotify);
if (desc->parent_type != WCLASS_DOCK_ICON)
return;
clipLeave(btn->dock);
}

View File

@@ -1,11 +0,0 @@
#ifndef WMCLIP_ACTIONS_H_
#define WMCLIP_ACTIONS_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/clip_actions_interface.h"
#include <X11/X.h>
extern struct WClipActions wm_global_clip_actions;
#endif // WMCLIP_ACTIONS_H_

View File

@@ -1,18 +0,0 @@
#ifndef WMCLIP_ACTIONS_INTERFACE_
#define WMCLIP_ACTIONS_INTERFACE_
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
typedef void (WClipEnterNotify_fn_t)(WObjDescriptor *desc, XEvent *event);
typedef void (WClipLeaveNotify_fn_t)(WObjDescriptor *desc, XEvent *event);
typedef void (WClipLeave_fn_t)(WDock *dock);
struct WClipActions {
WClipEnterNotify_fn_t *enterNotify;
WClipLeaveNotify_fn_t *leaveNotify;
WClipLeave_fn_t *leave;
};
#endif // WMCLIP_ACTIONS_INTERFACE_

View File

@@ -23,15 +23,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wconfig.h"
#include "WindowMaker.h"
#include <X11/Xatom.h>
/* #include "window.h" */
/* #include "framewin.h" */
/* #include "colormap.h" */
#include "window.h"
#include "framewin.h"
#include "colormap.h"
void wColormapInstallForWindow(WScreen * scr, WWindow * wwin)

View File

@@ -21,8 +21,6 @@
#ifndef WMCOLORMAP_H
#define WMCOLORMAP_H
#include "wmaker/WindowMaker.h"
void wColormapInstallForWindow(WScreen *scr, WWindow *wwin);
void wColormapAllowClientInstallation(WScreen * scr, Bool starting);

View File

@@ -1,13 +0,0 @@
#include "wmaker/compare_times.h"
#include "WINGs/WINGs.h"
int compareTimes(Time t1, Time t2)
{
Time diff;
if (t1 == t2)
return 0;
diff = t1 - t2;
return (diff < 60000) ? 1 : -1;
}

View File

@@ -1,8 +0,0 @@
#ifndef WCOMPARE_TIMES_H_
#define WCOMPARE_TIMES_H_
#include "WINGs/WINGs.h"
int compareTimes(Time t1, Time t2);
#endif // WCOMPARE_TIMES_H_

28
bazel/wmaker/cursor.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef CURSOR_H_
#define CURSOR_H_
/* Mouse cursors */
typedef enum {
WCUR_NORMAL,
WCUR_MOVE,
WCUR_RESIZE,
WCUR_TOPLEFTRESIZE,
WCUR_TOPRIGHTRESIZE,
WCUR_BOTTOMLEFTRESIZE,
WCUR_BOTTOMRIGHTRESIZE,
WCUR_VERTICALRESIZE,
WCUR_HORIZONRESIZE,
WCUR_WAIT,
WCUR_ARROW,
WCUR_QUESTION,
WCUR_TEXT,
WCUR_SELECT,
WCUR_CAPTURE,
WCUR_ROOT,
WCUR_EMPTY,
/* Count of the number of cursors defined */
WCUR_LAST
} w_cursor;
#endif // CURSOR_H_

View File

@@ -19,9 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/set_focus.h"
#include "wmaker/screen_tracking.h"
#include "wconfig.h"
#include <stdlib.h>
#include <X11/Xlib.h>

View File

@@ -22,12 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/defaults.h"
#include "wmaker/keybind.h"
#include "wmaker/screen_tracking.h"
#include "wmaker/screen.h"
#include "wconfig.h"
#include <stdio.h>
#include <stdint.h>
@@ -52,20 +47,23 @@
#include "wrlib/wraster.h"
/* #include "framewin.h" */
/* #include "window.h" */
/* #include "texture.h" */
/* #include "screen.h" */
/* #include "resources.h" */
/* #include "xmodifier.h" */
/* #include "icon.h" */
/* #include "main.h" */
/* #include "actions.h" */
/* #include "dock.h" */
/* #include "workspace.h" */
/* #include "properties.h" */
/* #include "misc.h" */
/* #include "winmenu.h" */
#include "WindowMaker.h"
#include "framewin.h"
#include "window.h"
#include "texture.h"
#include "screen.h"
#include "resources.h"
#include "defaults.h"
#include "keybind.h"
#include "xmodifier.h"
#include "icon.h"
#include "main.h"
#include "actions.h"
#include "dock.h"
#include "workspace.h"
#include "properties.h"
#include "misc.h"
#include "winmenu.h"
#define MAX_SHORTCUT_LENGTH 32

View File

@@ -21,7 +21,12 @@
#ifndef WMDEFAULTS_H_
#define WMDEFAULTS_H_
// Type definition for WDDomain is in WindowMaker.h.
typedef struct WDDomain {
const char *domain_name;
WMPropList *dictionary;
const char *path;
time_t timestamp;
} WDDomain;
WDDomain * wDefaultsInitDomain(const char *domain, Bool requireDictionary);
@@ -36,8 +41,19 @@ void wDefaultFillAttributes(const char *instance, const char *class,
WWindowAttributes *attr, WWindowAttributes *mask,
Bool useGlobalDefault);
char *get_default_image_path(void);
RImage *get_default_image(WScreen *scr);
char *wDefaultGetIconFile(const char *instance, const char *class, Bool default_icon);
RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass, int max_size);
char *get_icon_filename(const char *winstance, const char *wclass, const char *command,
Bool default_icon);
int wDefaultGetStartWorkspace(WScreen *scr, const char *instance, const char *class);
void wDefaultChangeIcon(const char *instance, const char* class, const char *file);
RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size);
void wDefaultPurgeInfo(const char *instance, const char *class);

View File

@@ -1,454 +0,0 @@
#include "wmaker/destroy.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/app_icon_paint.h"
#include "wmaker/application_tracking.h"
#include "wmaker/arrange_icons.h"
#include "wmaker/atoms.h"
#include "wmaker/window/framewin.h"
#include "wmaker/icon/icon.h"
#include "wmaker/pixmap.h"
#include "wmaker/select_window.h"
#include "wmaker/set_focus.h"
#include "wmaker/stacking.h"
#include "wmaker/wcore.h"
#include "wmaker/window/tracking.h"
#include "WINGs/WUtil.h"
void wWindowDestroy(WWindow *wwin)
{
int i;
if (wwin->screen_ptr->cmap_window == wwin)
wwin->screen_ptr->cmap_window = NULL;
WMRemoveNotificationObserver(wwin);
wwin->flags.destroyed = 1;
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (!wwin->screen_ptr->shortcutWindows[i])
continue;
WMRemoveFromArray(wwin->screen_ptr->shortcutWindows[i], wwin);
if (!WMGetArrayItemCount(wwin->screen_ptr->shortcutWindows[i])) {
WMFreeArray(wwin->screen_ptr->shortcutWindows[i]);
wwin->screen_ptr->shortcutWindows[i] = NULL;
}
}
if (wwin->fake_group && wwin->fake_group->retainCount > 0) {
wwin->fake_group->retainCount--;
if (wwin->fake_group->retainCount == 0 && wwin->fake_group->leader != None) {
XDestroyWindow(dpy, wwin->fake_group->leader);
wwin->fake_group->leader = None;
wwin->fake_group->origLeader = None;
XFlush(dpy);
}
}
if (wwin->normal_hints)
XFree(wwin->normal_hints);
if (wwin->wm_hints)
XFree(wwin->wm_hints);
if (wwin->wm_instance)
XFree(wwin->wm_instance);
if (wwin->wm_class)
XFree(wwin->wm_class);
if (wwin->wm_gnustep_attr)
wfree(wwin->wm_gnustep_attr);
if (wwin->cmap_windows)
XFree(wwin->cmap_windows);
XDeleteContext(dpy, wwin->client_win, w_global.context.client_win);
if (wwin->frame)
wFrameWindowDestroy(wwin->frame);
if (wwin->icon) {
RemoveFromStackList(wwin->icon->core);
wIconDestroy(wwin->icon);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(wwin->screen_ptr, True);
}
if (wwin->net_icon_image)
RReleaseImage(wwin->net_icon_image);
wrelease(wwin);
}
void wFrameWindowDestroy(WFrameWindow * fwin)
{
int i;
if (fwin->left_button)
wCoreDestroy(fwin->left_button);
#ifdef XKB_BUTTON_HINT
if (fwin->language_button)
wCoreDestroy(fwin->language_button);
#endif
if (fwin->right_button)
wCoreDestroy(fwin->right_button);
if (fwin->resizebar)
wCoreDestroy(fwin->resizebar);
if (fwin->titlebar)
wCoreDestroy(fwin->titlebar);
RemoveFromStackList(fwin->core);
wCoreDestroy(fwin->core);
if (fwin->title)
wfree(fwin->title);
for (i = 0; i < (fwin->flags.single_texture ? 1 : 3); i++) {
FREE_PIXMAP(fwin->title_back[i]);
if (wPreferences.new_style == TS_NEW) {
FREE_PIXMAP(fwin->lbutton_back[i]);
#ifdef XKB_BUTTON_HINT
FREE_PIXMAP(fwin->languagebutton_back[i]);
#endif
FREE_PIXMAP(fwin->rbutton_back[i]);
}
}
wfree(fwin);
}
void wIconDestroy(WIcon *icon)
{
WCoreWindow *core = icon->core;
WScreen *scr = core->screen_ptr;
WMRemoveNotificationObserver(icon);
if (icon->handlerID)
WMDeleteTimerHandler(icon->handlerID);
if (icon->icon_win) {
int x = 0, y = 0;
if (icon->owner) {
x = icon->owner->icon_x;
y = icon->owner->icon_y;
}
XUnmapWindow(dpy, icon->icon_win);
XReparentWindow(dpy, icon->icon_win, scr->root_win, x, y);
}
if (icon->icon_name)
XFree(icon->icon_name);
if (icon->pixmap)
XFreePixmap(dpy, icon->pixmap);
if (icon->mini_preview)
XFreePixmap(dpy, icon->mini_preview);
unset_icon_image(icon);
wCoreDestroy(icon->core);
wfree(icon);
}
void wMenuUnmap(WMenu * menu)
{
int i;
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->flags.titled && menu->flags.buttoned) {
wFrameWindowHideButton(menu->frame, WFF_RIGHT_BUTTON);
}
menu->flags.buttoned = 0;
menu->flags.mapped = 0;
menu->flags.open_to_left = 0;
if (menu->flags.shaded) {
wFrameWindowResize(menu->frame, menu->frame->core->width, menu->frame->top_width +
menu->entry_height*menu->entry_no + menu->frame->bottom_width - 1);
menu->flags.shaded = 0;
}
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i] != NULL
&& menu->cascades[i]->flags.mapped && !menu->cascades[i]->flags.buttoned) {
wMenuUnmap(menu->cascades[i]);
}
}
menu->selected_entry = -1;
}
void CloseWindowMenu(WScreen * scr)
{
if (scr->window_menu) {
if (scr->window_menu->flags.mapped)
wMenuUnmap(scr->window_menu);
if (scr->window_menu->entries[0]->clientdata) {
WWindow *wwin = (WWindow *) scr->window_menu->entries[0]->clientdata;
wwin->flags.menu_open_for_me = 0;
}
scr->window_menu->entries[0]->clientdata = NULL;
}
}
/*
*--------------------------------------------------------------------
* wClientRestore--
* Reparent the window back to the root window.
*
*--------------------------------------------------------------------
*/
static void wClientRestore(WWindow * wwin)
{
#if 0
int gx, gy;
wClientGetGravityOffsets(wwin, &gx, &gy);
/* set the position of the frame on screen */
wwin->frame_x -= gx * wwin->screen_ptr->frame_border_width;
wwin->frame_y -= gy * wwin->screen_ptr->frame_border_width;
/* if gravity is to the south, account for the border sizes */
if (gy > 0)
wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width);
#endif
XSetWindowBorderWidth(dpy, wwin->client_win, wwin->old_border_width);
XReparentWindow(dpy, wwin->client_win, wwin->screen_ptr->root_win, wwin->frame_x, wwin->frame_y);
/* don't let the window get iconified after restart */
/*
if (wwin->flags.shaded)
wClientSetState(wwin, NormalState, None);
*/
}
/*
*----------------------------------------------------------------------
* wUnmanageWindow--
* Removes the frame window from a window and destroys all data
* related to it. The window will be reparented back to the root window
* if restore is True.
*
* Side effects:
* Everything related to the window is destroyed and the window
* is removed from the window lists. Focus is set to the previous on the
* window list.
*----------------------------------------------------------------------
*/
void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed)
{
WCoreWindow *frame = wwin->frame->core;
WWindow *owner = NULL;
WWindow *newFocusedWindow = NULL;
int wasFocused;
WScreen *scr = wwin->screen_ptr;
/* First close attribute editor window if open */
if (wwin->flags.inspector_open)
wCloseInspectorForWindow(wwin);
/* Close window menu if it's open for this window */
if (wwin->flags.menu_open_for_me)
CloseWindowMenu(scr);
/* Don't restore focus to this window after a window exits
* fullscreen mode */
if (scr->bfs_focused_window == wwin)
scr->bfs_focused_window = NULL;
if (!destroyed) {
if (!wwin->flags.internal_window)
XRemoveFromSaveSet(dpy, wwin->client_win);
/* If this is a leader window, we still need to listen for
* DestroyNotify and PropertyNotify. */
if (wApplicationOf(wwin->client_win))
XSelectInput(dpy, wwin->client_win, StructureNotifyMask | PropertyChangeMask);
else
XSelectInput(dpy, wwin->client_win, NoEventMask);
XUngrabButton(dpy, AnyButton, AnyModifier, wwin->client_win);
XUngrabKey(dpy, AnyKey, AnyModifier, wwin->client_win);
}
XUnmapWindow(dpy, frame->window);
XUnmapWindow(dpy, wwin->client_win);
/* deselect window */
wSelectWindow(wwin, False);
/* remove all pending events on window */
/* I think this only matters for autoraise */
if (wPreferences.raise_delay)
WMDeleteTimerWithClientData(wwin->frame->core);
XFlush(dpy);
/* reparent the window back to the root */
if (restore)
wClientRestore(wwin);
if (wwin->transient_for != scr->root_win) {
owner = wWindowFor(wwin->transient_for);
if (owner) {
if (!owner->flags.semi_focused)
owner = NULL;
else
owner->flags.semi_focused = 0;
}
}
wasFocused = wwin->flags.focused;
/* remove from window focus list */
if (!wwin->prev && !wwin->next) {
/* was the only window */
scr->focused_window = NULL;
newFocusedWindow = NULL;
} else {
WWindow *tmp;
if (wwin->prev)
wwin->prev->next = wwin->next;
if (wwin->next)
wwin->next->prev = wwin->prev;
else {
scr->focused_window = wwin->prev;
scr->focused_window->next = NULL;
}
if (wPreferences.focus_mode == WKF_CLICK) {
/* if in click to focus mode and the window
* was a transient, focus the owner window
*/
tmp = NULL;
if (wPreferences.focus_mode == WKF_CLICK) {
tmp = wWindowFor(wwin->transient_for);
if (tmp && (!tmp->flags.mapped || WFLAGP(tmp, no_focusable))) {
tmp = NULL;
}
}
/* otherwise, focus the next one in the focus list */
if (!tmp) {
tmp = scr->focused_window;
while (tmp) { /* look for one in the window list first */
if (!WFLAGP(tmp, no_focusable) && !WFLAGP(tmp, skip_window_list)
&& (tmp->flags.mapped || tmp->flags.shaded))
break;
tmp = tmp->prev;
}
if (!tmp) { /* if unsuccessful, choose any focusable window */
tmp = scr->focused_window;
while (tmp) {
if (!WFLAGP(tmp, no_focusable)
&& (tmp->flags.mapped || tmp->flags.shaded))
break;
tmp = tmp->prev;
}
}
}
newFocusedWindow = tmp;
} else if (wPreferences.focus_mode == WKF_SLOPPY) {
unsigned int mask;
int foo;
Window bar, win;
/* This is to let the root window get the keyboard input
* if Sloppy focus mode and no other window get focus.
* This way keybindings will not freeze.
*/
tmp = NULL;
if (XQueryPointer(dpy, scr->root_win, &bar, &win, &foo, &foo, &foo, &foo, &mask))
tmp = wWindowFor(win);
if (tmp == wwin)
tmp = NULL;
newFocusedWindow = tmp;
} else {
newFocusedWindow = NULL;
}
}
if (!wwin->flags.internal_window)
WMPostNotificationName(WMNUnmanaged, wwin, NULL);
if (wasFocused) {
if (newFocusedWindow != owner && owner) {
if (wwin->flags.is_gnustep == 0)
wFrameWindowChangeState(owner->frame, WS_UNFOCUSED);
}
wSetFocusTo(scr, newFocusedWindow);
}
/* Close menu and unhighlight */
WApplication *oapp = wApplicationOf(wwin->main_window);
WApplication *napp = scr->focused_window ? wApplicationOf(scr->focused_window->main_window) : NULL;
if (oapp && oapp != napp) {
wAppMenuUnmap(oapp->menu);
if (wPreferences.highlight_active_app)
wApplicationDeactivate(oapp);
}
wNETCleanupFrameExtents(wwin);
wWindowDestroy(wwin);
XFlush(dpy);
}
void wCloseInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame; /* the inspector window */
(*pwin->frame->on_click_right) (NULL, pwin, NULL);
}
void wNETWMCleanup(WScreen *scr)
{
int i;
for (i = 0; i < wlengthof(wm_global_atomNames); i++)
XDeleteProperty(dpy, scr->root_win, *wm_global_atomNames[i].atom);
}
static void unmapmenus(WMenu * menu)
{
int i;
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
}
void wAppMenuUnmap(WMenu * menu)
{
if (menu)
unmapmenus(menu);
}
void wApplicationDeactivate(WApplication *wapp)
{
if (wapp->app_icon) {
wIconSetHighlited(wapp->app_icon->icon, False);
wAppIconPaint(wapp->app_icon);
}
}

View File

@@ -1,26 +0,0 @@
#ifndef WMDESTROY_H_
#define WMDESTROY_H_
#include "wmaker/WindowMaker.h"
void wIconDestroy(WIcon *icon);
void wWindowDestroy(WWindow *wwin);
void wFrameWindowDestroy(WFrameWindow *fwin);
void wMenuUnmap(WMenu *menu);
void CloseWindowMenu(WScreen *scr);
void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
void wCloseInspectorForWindow(WWindow *wwin);
void wNETWMCleanup(WScreen *scr);
void wAppMenuUnmap(WMenu *menu);
void wApplicationDeactivate(WApplication *);
#endif // WMDESTROY_H_

View File

@@ -21,20 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
/* #include "wmaker/defaults.h" */
#include "wmaker/WindowMaker.h"
#include "wmaker/GNUstep.h"
#include "wmaker/destroy.h"
#include "wmaker/dialog.h"
#include "wmaker/find_image.h"
#include "wmaker/framewin.h"
#include "wmaker/icon_base.h"
#include "wmaker/set_focus.h"
#include "wmaker/stacking.h"
#include "wmaker/window_base.h"
#include "wmaker/window_map.h"
#include "wmaker/xinerama.h"
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -65,42 +52,25 @@
#define PATH_MAX DEFAULT_PATH_MAX
#endif
/* #include "screen.h" */
/* #include "window.h" */
/* #include "dialog.h" */
/* #include "misc.h" */
/* #include "stacking.h" */
/* #include "framewin.h" */
/* #include "window.h" */
/* #include "actions.h" */
/* #include "xinerama.h" */
#include "WindowMaker.h"
#include "GNUstep.h"
#include "screen.h"
#include "window.h"
#include "dialog.h"
#include "misc.h"
#include "stacking.h"
#include "framewin.h"
#include "window.h"
#include "actions.h"
#include "xinerama.h"
static int wMessageDialog(WScreen *scr, const char *title, const char *message,
const char *defBtn, const char *altBtn, const char *othBtn);
static int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message,
const char *name, char **text);
static int wInputDialog(WScreen *scr, const char *title, const char *message, char **text);
static int wExitDialog(WScreen *scr, const char *title, const char *message, const char *defBtn,
const char *altBtn, const char *othBtn);
static Bool wIconChooserDialog(WScreen *scr, char **file, const char *instance, const char *class);
struct WDialogGenerator wm_global_dialog =
{
.message = &wMessageDialog,
.advancedInput = &wAdvancedInputDialog,
.input = &wInputDialog,
.exit = &wExitDialog,
.iconChooser = &wIconChooserDialog,
};
static WMPoint getCenter(WScreen * scr, int width, int height)
{
return wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr), width, height);
}
static int wMessageDialog(WScreen *scr, const char *title, const char *message, const char *defBtn, const char *altBtn, const char *othBtn)
int wMessageDialog(WScreen *scr, const char *title, const char *message, const char *defBtn, const char *altBtn, const char *othBtn)
{
WMAlertPanel *panel;
Window parent;
@@ -148,7 +118,7 @@ static void toggleSaveSession(WMWidget *w, void *data)
wPreferences.save_session_on_exit = WMGetButtonSelected((WMButton *) w);
}
static int wExitDialog(WScreen *scr, const char *title, const char *message, const char *defBtn, const char *altBtn, const char *othBtn)
int wExitDialog(WScreen *scr, const char *title, const char *message, const char *defBtn, const char *altBtn, const char *othBtn)
{
WMAlertPanel *panel;
WMButton *saveSessionBtn;
@@ -456,7 +426,7 @@ static void handleHistoryKeyPress(XEvent * event, void *clientData)
}
}
static int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, const char *name, char **text)
int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, const char *name, char **text)
{
WWindow *wwin;
Window parent;
@@ -523,7 +493,7 @@ static int wAdvancedInputDialog(WScreen *scr, const char *title, const char *mes
}
}
static int wInputDialog(WScreen *scr, const char *title, const char *message, char **text)
int wInputDialog(WScreen *scr, const char *title, const char *message, char **text)
{
WWindow *wwin;
Window parent;
@@ -952,7 +922,7 @@ static void keyPressHandler(XEvent * event, void *data)
}
}
static Bool wIconChooserDialog(WScreen *scr, char **file, const char *instance, const char *class)
Bool wIconChooserDialog(WScreen *scr, char **file, const char *instance, const char *class)
{
WWindow *wwin;
Window parent;
@@ -1205,7 +1175,7 @@ static void destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
infoPanel = NULL;
}
static char *getPrettyOSName(void)
char *getPrettyOSName(void)
{
char line[200];
char *token;

View File

@@ -22,8 +22,7 @@
#ifndef WMDIALOG_H_
#define WMDIALOG_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/dialog_interface.h"
#include "screen.h"
enum {
WMAbort=0,
@@ -31,10 +30,20 @@ enum {
WMStartAlternate
};
extern struct WDialogGenerator wm_global_dialog;
int wMessageDialog(WScreen *scr, const char *title, const char *message,
const char *defBtn, const char *altBtn, const char *othBtn);
int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, const char *name, char **text);
int wInputDialog(WScreen *scr, const char *title, const char *message, char **text);
int wExitDialog(WScreen *scr, const char *title, const char *message, const char *defBtn,
const char *altBtn, const char *othBtn);
Bool wIconChooserDialog(WScreen *scr, char **file, const char *instance, const char *class);
void wShowInfoPanel(WScreen *scr);
void wShowLegalPanel(WScreen *scr);
int wShowCrashingDialogPanel(int whatSig);
#endif

View File

@@ -1,25 +0,0 @@
#ifndef WMDIALOG_INTERFACE_H_
#define WMDIALOG_INTERFACE_H_
#include "wmaker/WindowMaker.h"
typedef int (WMessageDialog_fn_t)(WScreen *scr, const char *title, const char *message,
const char *defBtn, const char *altBtn, const char *othBtn);
typedef int (WAdvancedInputDialog_fn_t)(WScreen *scr, const char *title, const char *message,
const char *name, char **text);
typedef int (WInputDialog_fn_t)(WScreen *scr, const char *title, const char *message, char **text);
typedef int (WExitDialog_fn_t)(WScreen *scr, const char *title, const char *message, const char *defBtn,
const char *altBtn, const char *othBtn);
typedef Bool (WIconChooserDialog_fn_t)(WScreen *scr, char **file, const char *instance, const char *class);
struct WDialogGenerator {
WMessageDialog_fn_t *message;
WAdvancedInputDialog_fn_t *advancedInput;
WInputDialog_fn_t *input;
WExitDialog_fn_t *exit;
WIconChooserDialog_fn_t *iconChooser;
};
#endif // WMDIALOG_INTERFACE_H_

View File

@@ -1,22 +0,0 @@
package(default_visibility = ["//visibility:public"])
cc_library(
name = "xdnd_init",
hdrs = ["xdnd_init.h"],
srcs = ["xdnd_init.c"],
deps = [
"//wmaker:base",
"//wmaker:wconfig",
"@x11//:lib",
],
)
cc_library(
name = "xdnd",
hdrs = ["xdnd.h"],
srcs = ["xdnd.c"],
deps = [
":xdnd_init",
"//wmaker:base",
],
)

View File

@@ -1,6 +0,0 @@
#ifndef WMXDND_ATOMS_H_
#define WMXDND_ATOMS_H_
#endif // WMXDND_ATOMS_H_

View File

@@ -1,44 +0,0 @@
#include "wmaker/dnd/xdnd_init.h"
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
static Atom _XA_XdndAware;
static Atom _XA_XdndEnter;
static Atom _XA_XdndLeave;
static Atom _XA_XdndDrop;
static Atom _XA_XdndPosition;
static Atom _XA_XdndStatus;
static Atom _XA_XdndActionCopy;
static Atom _XA_XdndSelection;
static Atom _XA_XdndFinished;
static Atom _XA_XdndTypeList;
static Atom _XA_WINDOWMAKER_XDNDEXCHANGE;
static Atom supported_typelist;
void wXDNDInitializeAtoms(void)
{
_XA_XdndAware = XInternAtom(dpy, "XdndAware", False);
_XA_XdndEnter = XInternAtom(dpy, "XdndEnter", False);
_XA_XdndLeave = XInternAtom(dpy, "XdndLeave", False);
_XA_XdndDrop = XInternAtom(dpy, "XdndDrop", False);
_XA_XdndPosition = XInternAtom(dpy, "XdndPosition", False);
_XA_XdndStatus = XInternAtom(dpy, "XdndStatus", False);
_XA_XdndActionCopy = XInternAtom(dpy, "XdndActionCopy", False);
_XA_XdndSelection = XInternAtom(dpy, "XdndSelection", False);
_XA_XdndFinished = XInternAtom(dpy, "XdndFinished", False);
_XA_XdndTypeList = XInternAtom(dpy, "XdndTypeList", False);
_XA_WINDOWMAKER_XDNDEXCHANGE = XInternAtom(dpy, "_WINDOWMAKER_XDNDEXCHANGE", False);
supported_typelist = XInternAtom(dpy, "text/uri-list", False);
}
void wXDNDMakeAwareness(Window window)
{
long int xdnd_version = XDND_VERSION;
XChangeProperty(dpy, window, _XA_XdndAware, XA_ATOM, 32,
PropModeAppend, (unsigned char *)&xdnd_version, 1);
}

View File

@@ -1,11 +0,0 @@
#ifndef WMXDND_INIT_H_
#define WMXDND_INIT_H_
#include <X11/X.h>
#define XDND_VERSION 3L
void wXDNDInitializeAtoms(void);
void wXDNDMakeAwareness(Window window);
#endif // WMXDND_INIT_H_

File diff suppressed because it is too large Load Diff

View File

@@ -23,22 +23,64 @@
#ifndef WMDOCK_H_
#define WMDOCK_H_
#include "wmaker/WindowMaker.h"
#include "appicon.h"
// The type definition for WDock is in WindowMaker.h.
typedef struct WDock {
WScreen *screen_ptr;
int x_pos, y_pos; /* position of the first icon */
WAppIcon **icon_array; /* array of docked icons */
int max_icons;
int icon_count;
#define WM_DOCK 0
#define WM_CLIP 1
#define WM_DRAWER 2
int type;
WMagicNumber auto_expand_magic;
WMagicNumber auto_collapse_magic;
WMagicNumber auto_raise_magic;
WMagicNumber auto_lower_magic;
unsigned int auto_collapse:1; /* if clip auto-collapse itself */
unsigned int auto_raise_lower:1; /* if clip should raise/lower when
* entered/leaved */
unsigned int on_right_side:1;
unsigned int collapsed:1;
unsigned int mapped:1;
unsigned int lowered:1;
unsigned int attract_icons:1; /* If clip should attract app-icons */
unsigned int lclip_button_pushed:1;
unsigned int rclip_button_pushed:1;
struct WMenu *menu;
struct WDDomain *defaults;
} WDock;
WDock *wDockCreate(WScreen *scr, int type, const char *name);
WDock *wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type);
void wDockDestroy(WDock *dock);
void wDockHideIcons(WDock *dock);
void wDockShowIcons(WDock *dock);
void wDockLower(WDock *dock);
void wDockRaise(WDock *dock);
void wDockRaiseLower(WDock *dock);
void wDockSaveState(WScreen *scr, WMPropList *old_state);
Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon);
Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y,
int *ret_x, int *ret_y, int redocking);
Bool wDockFindFreeSlot(WDock *dock, int *req_x, int *req_y);
void wDockDetach(WDock *dock, WAppIcon *icon);
Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y);
void wDockReattachIcon(WDock *dock, WAppIcon *icon, int x, int y);
void wSlideAppicons(WAppIcon **appicons, int n, int to_the_left);
@@ -55,13 +97,32 @@ void wDockSwap(WDock *dock);
int wDockReceiveDNDDrop(WScreen *scr, XEvent *event);
#endif
void wClipIconPaint(WAppIcon *aicon);
void wClipSaveState(WScreen *scr);
WMPropList *wClipSaveWorkspaceState(WScreen *scr, int workspace);
WAppIcon *wClipRestoreState(WScreen *scr, WMPropList *clip_state);
void wDrawerIconPaint(WAppIcon *dicon);
void wDrawersSaveState(WScreen *scr);
void wDrawersRestoreState(WScreen *scr);
int wIsADrawer(WAppIcon *aicon);
void wClipUpdateForWorkspaceChange(WScreen *scr, int workspace);
RImage *wClipMakeTile(RImage *normalTile);
RImage* wDrawerMakeTile(WScreen *scr, RImage *normalTile);
#define WO_FAILED 0
#define WO_NOT_APPLICABLE 1
#define WO_SUCCESS 2
typedef enum
{
P_NORMAL = 0,
P_AUTO_RAISE_LOWER,
P_KEEP_ON_TOP,
} dockPosition;
int wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent);
#endif

View File

@@ -1,486 +0,0 @@
#include "wmaker/dock_base.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/app_icon_paint.h"
#include "wmaker/dialog_interface.h"
#include "wmaker/get_command_for_window.h"
#include "wmaker/icon/icon.h"
#include "wmaker/stacking.h"
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
void wClipUpdateForWorkspaceChange(struct WDialogGenerator *dialog, struct WClipActions *clip_actions, WScreen *scr, int workspace)
{
if (!wPreferences.flags.noclip) {
scr->clip_icon->dock = scr->workspaces[workspace]->clip;
if (scr->current_workspace != workspace) {
WDock *old_clip = scr->workspaces[scr->current_workspace]->clip;
WAppIconChain *chain = scr->global_icons;
while (chain) {
wDockMoveIconBetweenDocks(dialog, clip_actions,
chain->aicon->dock,
scr->workspaces[workspace]->clip,
chain->aicon,
chain->aicon->xindex,
chain->aicon->yindex);
if (scr->workspaces[workspace]->clip->collapsed)
XUnmapWindow(dpy, chain->aicon->icon->core->window);
chain = chain->next;
}
wDockHideIcons(old_clip);
if (old_clip->auto_raise_lower) {
if (old_clip->auto_raise_magic) {
WMDeleteTimerHandler(old_clip->auto_raise_magic);
old_clip->auto_raise_magic = NULL;
}
wDockLower(old_clip);
}
if (old_clip->auto_collapse) {
if (old_clip->auto_expand_magic) {
WMDeleteTimerHandler(old_clip->auto_expand_magic);
old_clip->auto_expand_magic = NULL;
}
old_clip->collapsed = 1;
}
wDockShowIcons(scr->workspaces[workspace]->clip);
}
}
}
Bool wDockMoveIconBetweenDocks(struct WDialogGenerator *dialog, struct WClipActions *clip_actions, WDock *src, WDock *dest, WAppIcon *icon, int x, int y)
{
WWindow *wwin;
char *command = NULL;
int index;
Bool update_icon = False;
if (src == dest)
return True; /* No move needed, we're already there */
if (dest == NULL)
return False;
/*
* For the moment we can't do this if we move icons in Clip from one
* workspace to other, because if we move two or more icons without
* command, the dialog box will not be able to tell us to which of the
* moved icons it applies. -Dan
*/
if ((dest->type == WM_DOCK /*|| dest->keep_attracted */ ) && icon->command == NULL) {
/* If icon->owner exists, it means the application is running */
if (icon->icon->owner) {
wwin = icon->icon->owner;
command = GetCommandForWindow(wwin->client_win);
}
if (command) {
icon->command = command;
} else {
icon->editing = 1;
/* icon->forced_dock = 1; */
if ((dialog->input)(src->screen_ptr, _("Dock Icon"),
_("Type the command used to launch the application"), &command)) {
if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) {
wfree(command);
command = NULL;
}
icon->command = command;
} else {
icon->editing = 0;
if (command)
wfree(command);
return False;
}
icon->editing = 0;
}
}
if (dest->type == WM_DOCK || dest->type == WM_DRAWER)
wClipMakeIconOmnipresent(icon, False);
for (index = 1; index < src->max_icons; index++) {
if (src->icon_array[index] == icon)
break;
}
assert(index < src->max_icons);
src->icon_array[index] = NULL;
src->icon_count--;
for (index = 1; index < dest->max_icons; index++) {
if (dest->icon_array[index] == NULL)
break;
}
assert(index < dest->max_icons);
dest->icon_array[index] = icon;
icon->dock = dest;
/* deselect the icon */
if (icon->icon->selected)
wIconSelect(icon->icon);
icon->icon->core->descriptor.handle_enternotify = clip_actions->enterNotify;
icon->icon->core->descriptor.handle_leavenotify = clip_actions->leaveNotify;
/* set it to be kept when moving to dock.
* Unless the icon does not have a command set
*/
if (icon->command && (dest->type == WM_DOCK || dest->type == WM_DRAWER)) {
icon->attracted = 0;
if (icon->icon->shadowed) {
icon->icon->shadowed = 0;
update_icon = True;
}
}
if (src->auto_collapse || src->auto_raise_lower)
(clip_actions->leave)(src);
icon->yindex = y;
icon->xindex = x;
icon->x_pos = dest->x_pos + x * wPreferences.icon_size;
icon->y_pos = dest->y_pos + y * wPreferences.icon_size;
dest->icon_count++;
MoveInStackListUnder(dest->icon_array[index - 1]->icon->core, icon->icon->core);
/*
* Update icon pixmap, RImage doesn't change,
* so call wIconUpdate is not needed
*/
if (update_icon)
update_icon_pixmap(icon->icon);
/* Paint it */
wAppIconPaint(icon);
return True;
}
void wDockShowIcons(WDock *dock)
{
int i;
WAppIcon *btn;
if (dock == NULL)
return;
btn = dock->icon_array[0];
wDockMove(dock, btn->x_pos, btn->y_pos);
/* Deleting any change in stacking level, this function is now only about
mapping icons */
if (!dock->collapsed) {
for (i = 1; i < dock->max_icons; i++) {
if (dock->icon_array[i])
XMapWindow(dpy, dock->icon_array[i]->icon->core->window);
}
}
dock->mapped = 1;
wDockIconPaint(btn);
}
void wDockHideIcons(WDock *dock)
{
int i;
if (dock == NULL)
return;
for (i = 1; i < dock->max_icons; i++) {
if (dock->icon_array[i])
XUnmapWindow(dpy, dock->icon_array[i]->icon->core->window);
}
dock->mapped = 0;
wDockIconPaint(dock->icon_array[0]);
}
void wDockLower(WDock *dock)
{
int i;
WDrawerChain *dc;
if (dock->type == WM_DOCK) {
for (dc = dock->screen_ptr->drawers; dc != NULL; dc = dc->next)
wDockLower(dc->adrawer);
}
for (i = 0; i < dock->max_icons; i++) {
if (dock->icon_array[i])
wLowerFrame(dock->icon_array[i]->icon->core);
}
}
void wDockMove(WDock *dock, int new_x, int new_y)
{
WAppIcon *btn;
WDrawerChain *dc;
int i;
if (dock->type == WM_DOCK) {
for (dc = dock->screen_ptr->drawers; dc != NULL; dc = dc->next)
wDockMove(dc->adrawer, new_x, dc->adrawer->y_pos - dock->y_pos + new_y);
}
dock->x_pos = new_x;
dock->y_pos = new_y;
for (i = 0; i < dock->max_icons; i++) {
btn = dock->icon_array[i];
if (btn) {
btn->x_pos = new_x + btn->xindex * wPreferences.icon_size;
btn->y_pos = new_y + btn->yindex * wPreferences.icon_size;
XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos);
}
}
}
void wDockIconPaint(WAppIcon *btn)
{
if (btn == btn->icon->core->screen_ptr->clip_icon) {
wClipIconPaint(btn);
} else if (wIsADrawer(btn)) {
wDrawerIconPaint(btn);
} else {
wAppIconPaint(btn);
save_appicon(btn);
}
}
void wDrawerIconPaint(WAppIcon *dicon)
{
Window win = dicon->icon->core->window;
WScreen *scr = dicon->icon->core->screen_ptr;
XPoint p[4];
GC gc = scr->draw_gc;
WMColor *color;
wIconPaint(dicon->icon);
if (!dicon->dock->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
XSetForeground(dpy, gc, WMColorPixel(color));
if (dicon->dock->on_right_side) {
p[0].x = p[3].x = 10;
p[0].y = p[3].y = wPreferences.icon_size / 2 - 5;
p[1].x = 10;
p[1].y = wPreferences.icon_size / 2 + 5;
p[2].x = 5;
p[2].y = wPreferences.icon_size / 2;
}
else {
p[0].x = p[3].x = wPreferences.icon_size-1 - 10;
p[0].y = p[3].y = wPreferences.icon_size / 2 - 5;
p[1].x = wPreferences.icon_size-1 - 10;
p[1].y = wPreferences.icon_size / 2 + 5;
p[2].x = wPreferences.icon_size-1 - 5;
p[2].y = wPreferences.icon_size / 2;
}
XFillPolygon(dpy, win, gc, p,3,Convex,CoordModeOrigin);
XDrawLines(dpy, win, gc, p,4,CoordModeOrigin);
}
int wIsADrawer(WAppIcon *aicon)
{
return aicon && aicon->dock &&
aicon->dock->type == WM_DRAWER && aicon->dock->icon_array[0] == aicon;
}
static void paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed)
{
Window win = clipIcon->icon->core->window;
WScreen *scr = clipIcon->icon->core->screen_ptr;
XPoint p[4];
int pt = CLIP_BUTTON_SIZE * wPreferences.icon_size / 64;
int tp = wPreferences.icon_size - pt;
int as = pt - 15; /* 15 = 5+5+5 */
GC gc = scr->draw_gc; /* maybe use WMColorGC() instead here? */
WMColor *color;
color = scr->clip_title_color[CLIP_NORMAL];
XSetForeground(dpy, gc, WMColorPixel(color));
if (rpushed) {
p[0].x = tp + 1;
p[0].y = 1;
p[1].x = wPreferences.icon_size - 2;
p[1].y = 1;
p[2].x = wPreferences.icon_size - 2;
p[2].y = pt - 1;
} else if (lpushed) {
p[0].x = 1;
p[0].y = tp;
p[1].x = pt;
p[1].y = wPreferences.icon_size - 2;
p[2].x = 1;
p[2].y = wPreferences.icon_size - 2;
}
if (lpushed || rpushed) {
XSetForeground(dpy, scr->draw_gc, scr->white_pixel);
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
}
/* top right arrow */
p[0].x = p[3].x = wPreferences.icon_size - 5 - as;
p[0].y = p[3].y = 5;
p[1].x = wPreferences.icon_size - 6;
p[1].y = 5;
p[2].x = wPreferences.icon_size - 6;
p[2].y = 4 + as;
if (rpushed) {
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin);
} else {
XFillPolygon(dpy, win, gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, gc, p, 4, CoordModeOrigin);
}
/* bottom left arrow */
p[0].x = p[3].x = 5;
p[0].y = p[3].y = wPreferences.icon_size - 5 - as;
p[1].x = 5;
p[1].y = wPreferences.icon_size - 6;
p[2].x = 4 + as;
p[2].y = wPreferences.icon_size - 6;
if (lpushed) {
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin);
} else {
XFillPolygon(dpy, win, gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, gc, p, 4, CoordModeOrigin);
}
}
void wClipIconPaint(WAppIcon *aicon)
{
WScreen *scr = aicon->icon->core->screen_ptr;
WWorkspace *workspace = scr->workspaces[scr->current_workspace];
WMColor *color;
Window win = aicon->icon->core->window;
int length, nlength;
char *ws_name, ws_number[sizeof scr->current_workspace * CHAR_BIT / 3 + 1];
int ty, tx;
wIconPaint(aicon->icon);
length = strlen(workspace->name);
ws_name = wmalloc(length + 1);
snprintf(ws_name, length + 1, "%s", workspace->name);
snprintf(ws_number, sizeof ws_number, "%u", scr->current_workspace + 1);
nlength = strlen(ws_number);
if (wPreferences.flags.noclip || !workspace->clip->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
ty = wPreferences.icon_size - WMFontHeight(scr->clip_title_font) - 3;
tx = CLIP_BUTTON_SIZE * wPreferences.icon_size / 64;
if(wPreferences.show_clip_title)
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, ty, ws_name, length);
tx = (wPreferences.icon_size / 2 - WMWidthOfString(scr->clip_title_font, ws_number, nlength)) / 2;
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, 2, ws_number, nlength);
wfree(ws_name);
if (aicon->launching)
XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
0, 0, wPreferences.icon_size, wPreferences.icon_size);
paintClipButtons(aicon, aicon->dock->lclip_button_pushed, aicon->dock->rclip_button_pushed);
}
static Bool iconCanBeOmnipresent(WAppIcon *aicon)
{
WScreen *scr = aicon->icon->core->screen_ptr;
WDock *clip;
WAppIcon *btn;
int i, j;
for (i = 0; i < scr->workspace_count; i++) {
clip = scr->workspaces[i]->clip;
if (clip == aicon->dock)
continue;
if (clip->icon_count + scr->global_icon_count >= clip->max_icons)
return False; /* Clip is full in some workspace */
for (j = 0; j < clip->max_icons; j++) {
btn = clip->icon_array[j];
if (btn && btn->xindex == aicon->xindex && btn->yindex == aicon->yindex)
return False;
}
}
return True;
}
int wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent)
{
WScreen *scr = aicon->icon->core->screen_ptr;
WAppIconChain *new_entry, *tmp, *tmp1;
int status = WO_SUCCESS;
if ((scr->dock && aicon->dock == scr->dock) || aicon == scr->clip_icon)
return WO_NOT_APPLICABLE;
if (aicon->omnipresent == omnipresent)
return WO_SUCCESS;
if (omnipresent) {
if (iconCanBeOmnipresent(aicon)) {
aicon->omnipresent = 1;
new_entry = wmalloc(sizeof(WAppIconChain));
new_entry->aicon = aicon;
new_entry->next = scr->global_icons;
scr->global_icons = new_entry;
scr->global_icon_count++;
} else {
aicon->omnipresent = 0;
status = WO_FAILED;
}
} else {
aicon->omnipresent = 0;
if (aicon == scr->global_icons->aicon) {
tmp = scr->global_icons->next;
wfree(scr->global_icons);
scr->global_icons = tmp;
scr->global_icon_count--;
} else {
tmp = scr->global_icons;
while (tmp->next) {
if (tmp->next->aicon == aicon) {
tmp1 = tmp->next->next;
wfree(tmp->next);
tmp->next = tmp1;
scr->global_icon_count--;
break;
}
tmp = tmp->next;
}
}
}
wAppIconPaint(aicon);
return status;
}

View File

@@ -1,33 +0,0 @@
#ifndef WMDOCK_BASE_H_
#define WMDOCK_BASE_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/clip_actions_interface.h"
#include "wmaker/dialog_interface.h"
#define WO_FAILED 0
#define WO_NOT_APPLICABLE 1
#define WO_SUCCESS 2
typedef enum
{
P_NORMAL = 0,
P_AUTO_RAISE_LOWER,
P_KEEP_ON_TOP,
} dockPosition;
WDock *wDockCreate(WScreen *scr, int type, const char *name);
void wClipUpdateForWorkspaceChange(struct WDialogGenerator *dialog, struct WClipActions *clip_actions, WScreen *scr, int workspace);
Bool wDockMoveIconBetweenDocks(struct WDialogGenerator *dialog, struct WClipActions *clip_actions, WDock *src, WDock *dest, WAppIcon *icon, int x, int y);
void wDockShowIcons(WDock *dock);
void wDockHideIcons(WDock *dock);
void wDockLower(WDock *dock);
void wDockMove(WDock *dock, int new_x, int new_y);
void wDockIconPaint(WAppIcon *btn);
int wIsADrawer(WAppIcon *aicon);
void wClipIconPaint(WAppIcon *aicon);
void wDrawerIconPaint(WAppIcon *dicon);
int wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent);
#endif // WMDOCK_BASE_H_

View File

@@ -1,50 +0,0 @@
#include "wmaker/dock_state.h"
#include "wmaker/wconfig.h"
#include "WINGs/WUtil.h"
static struct dock_plist_t dock_keys =
{
.command = NULL,
.pasteCommand = NULL,
#ifdef USE_DOCK_XDND
.dropCommand = NULL,
#endif // USE_DOCK_XDND
.drawers = NULL,
};
struct dock_plist_t * global_dock_keys()
{
if (dock_keys.command != NULL)
return &dock_keys;
dock_keys.command = WMRetainPropList(WMCreatePLString("Command"));
dock_keys.pasteCommand = WMRetainPropList(WMCreatePLString("PasteCommand"));
#ifdef USE_DOCK_XDND
dock_keys.dropCommand = WMRetainPropList(WMCreatePLString("DropCommand"));
#endif // USE_DOCK_XDND
dock_keys.lock = WMRetainPropList(WMCreatePLString("Lock"));
dock_keys.autoLaunch = WMRetainPropList(WMCreatePLString("AutoLaunch"));
dock_keys.name = WMRetainPropList(WMCreatePLString("Name"));
dock_keys.forced = WMRetainPropList(WMCreatePLString("Forced"));
dock_keys.buggyApplication = WMRetainPropList(WMCreatePLString("BuggyApplication"));
dock_keys.yes = WMRetainPropList(WMCreatePLString("Yes"));
dock_keys.no = WMRetainPropList(WMCreatePLString("No"));
dock_keys.host = WMRetainPropList(WMCreatePLString("Host"));
dock_keys.position = WMCreatePLString("Position");
dock_keys.applications = WMCreatePLString("Applications");
dock_keys.lowered = WMCreatePLString("Lowered");
dock_keys.collapsed = WMCreatePLString("Collapsed");
dock_keys.autoCollapse = WMCreatePLString("AutoCollapse");
dock_keys.autoRaiseLower = WMCreatePLString("AutoRaiseLower");
dock_keys.autoAttractIcons = WMCreatePLString("AutoAttractIcons");
dock_keys.omnipresent = WMCreatePLString("Omnipresent");
dock_keys.dock = WMCreatePLString("Dock");
dock_keys.clip = WMCreatePLString("Clip");
dock_keys.drawers = WMCreatePLString("Drawers");
return &dock_keys;
}

View File

@@ -1,27 +0,0 @@
#ifndef WMDOCK_STATE_H_
#define WMDOCK_STATE_H_
#include "wmaker/wconfig.h"
#include "WINGs/WUtil.h"
struct dock_plist_t {
WMPropList *command;
WMPropList *pasteCommand;
#ifdef USE_DOCK_XDND
WMPropList *dropCommand;
#endif // USE_DOCK_XDND
WMPropList *autoLaunch, *lock;
WMPropList *name, *forced, *buggyApplication, *yes, *no;
WMPropList *host, *dock, *clip;
WMPropList *autoAttractIcons;
WMPropList *position, *applications, *lowered, *collapsed;
WMPropList *autoCollapse, *autoRaiseLower, *omnipresent;
WMPropList *drawers;
};
struct dock_plist_t * global_dock_keys();
#endif // WMDOCK_STATE_H_

View File

@@ -19,19 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/app_icon_paint.h"
#include "wmaker/defaults.h"
#include "wmaker/destroy.h"
#include "wmaker/dialog.h"
#include "wmaker/dock.h"
#include "wmaker/dockedapp.h"
#include "wmaker/find_image.h"
#include "wmaker/icon_base.h"
#include "wmaker/window_map.h"
#include "wmaker/window.h"
#include "wmaker/xinerama.h"
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -39,16 +27,17 @@
#include <string.h>
#include <stdio.h>
/* #include "window.h" */
/* #include "icon.h" */
/* #include "appicon.h" */
/* #include "dock.h" */
/* #include "dockedapp.h" */
/* #include "dialog.h" */
/* #include "misc.h" */
/* #include "defaults.h" */
/* #include "framewin.h" */
/* #include "xinerama.h" */
#include "WindowMaker.h"
#include "window.h"
#include "icon.h"
#include "appicon.h"
#include "dock.h"
#include "dockedapp.h"
#include "dialog.h"
#include "misc.h"
#include "defaults.h"
#include "framewin.h"
#include "xinerama.h"
static void updateCommand(WAppIcon * icon, char *command)
@@ -181,8 +170,8 @@ static void panelBtnCallback(WMWidget * self, void *data)
buf = wmalloc(len);
snprintf(buf, len, _("Could not open specified icon file: %s"), text);
if ((dialog->message)(panel->wwin->screen_ptr, _("Error"), buf,
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
wfree(text);
wfree(buf);
return;

View File

@@ -1,61 +0,0 @@
#include "wmaker/escape_wm_class.h"
#include <stdio.h>
#include <string.h>
#include "WINGs/WUtil.h"
char *EscapeWM_CLASS(const char *name, const char *class)
{
char *ret;
char *ename = NULL, *eclass = NULL;
int i, j, l;
if (!name && !class)
return NULL;
if (name) {
l = strlen(name);
ename = wmalloc(l * 2 + 1);
j = 0;
for (i = 0; i < l; i++) {
if (name[i] == '\\') {
ename[j++] = '\\';
} else if (name[i] == '.') {
ename[j++] = '\\';
}
ename[j++] = name[i];
}
ename[j] = 0;
}
if (class) {
l = strlen(class);
eclass = wmalloc(l * 2 + 1);
j = 0;
for (i = 0; i < l; i++) {
if (class[i] == '\\') {
eclass[j++] = '\\';
} else if (class[i] == '.') {
eclass[j++] = '\\';
}
eclass[j++] = class[i];
}
eclass[j] = 0;
}
if (ename && eclass) {
int len = strlen(ename) + strlen(eclass) + 4;
ret = wmalloc(len);
snprintf(ret, len, "%s.%s", ename, eclass);
wfree(ename);
wfree(eclass);
} else if (ename) {
ret = wstrdup(ename);
wfree(ename);
} else {
ret = wstrdup(eclass);
wfree(eclass);
}
return ret;
}

View File

@@ -1,6 +0,0 @@
#ifndef WMESCAPE_WM_CLASS_
#define WMESCAPE_WM_CLASS_
char *EscapeWM_CLASS(const char *name, const char *class);
#endif // WMESCAPE_WM_CLASS_

View File

@@ -20,8 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include "wconfig.h"
#ifdef HAVE_INOTIFY
#include <sys/select.h>
@@ -54,31 +53,32 @@
#include <X11/XKBlib.h>
#endif /* KEEP_XKB_LOCK_STATUS */
/* #include "window.h" */
/* #include "actions.h" */
/* #include "client.h" */
/* #include "main.h" */
/* #include "cycling.h" */
/* #include "keybind.h" */
/* #include "application.h" */
/* #include "stacking.h" */
/* #include "defaults.h" */
/* #include "workspace.h" */
/* #include "dock.h" */
/* #include "framewin.h" */
/* #include "properties.h" */
/* #include "balloon.h" */
/* #include "xinerama.h" */
/* #include "wmspec.h" */
/* #include "rootmenu.h" */
/* #include "colormap.h" */
/* #include "screen.h" */
/* #include "shutdown.h" */
/* #include "misc.h" */
/* #include "event.h" */
/* #include "winmenu.h" */
/* #include "switchmenu.h" */
/* #include "wsmap.h" */
#include "WindowMaker.h"
#include "window.h"
#include "actions.h"
#include "client.h"
#include "main.h"
#include "cycling.h"
#include "keybind.h"
#include "application.h"
#include "stacking.h"
#include "defaults.h"
#include "workspace.h"
#include "dock.h"
#include "framewin.h"
#include "properties.h"
#include "balloon.h"
#include "xinerama.h"
#include "wmspec.h"
#include "rootmenu.h"
#include "colormap.h"
#include "screen.h"
#include "shutdown.h"
#include "misc.h"
#include "event.h"
#include "winmenu.h"
#include "switchmenu.h"
#include "wsmap.h"
#define MOD_MASK wPreferences.modifier_mask
@@ -423,6 +423,54 @@ noreturn void EventLoop(void)
}
}
/*
*----------------------------------------------------------------------
* ProcessPendingEvents --
* Processes the events that are currently pending (at the time
* this function is called) in the display's queue.
*
* Returns:
* After the pending events that were present at the function call
* are processed.
*
* Side effects:
* Many -- whatever handling events may involve.
*
*----------------------------------------------------------------------
*/
void ProcessPendingEvents(void)
{
XEvent event;
int count;
XSync(dpy, False);
/* Take a snapshot of the event count in the queue */
count = XPending(dpy);
while (count > 0 && XPending(dpy)) {
WMNextEvent(dpy, &event);
WMHandleEvent(&event);
count--;
}
}
Bool IsDoubleClick(WScreen * scr, XEvent * event)
{
if ((scr->last_click_time > 0) &&
(event->xbutton.time - scr->last_click_time <= wPreferences.dblclick_time)
&& (event->xbutton.button == scr->last_click_button)
&& (event->xbutton.window == scr->last_click_window)) {
scr->flags.next_click_is_not_double = 1;
scr->last_click_time = 0;
scr->last_click_window = event->xbutton.window;
return True;
}
return False;
}
void NotifyDeadProcess(pid_t pid, unsigned char status)
{
if (deadProcessPtr >= MAX_DEAD_PROCESSES - 1) {

View File

@@ -28,8 +28,15 @@
#include <stdnoreturn.h>
#endif
typedef void (WDeathHandler)(pid_t pid, unsigned int status, void *cdata);
noreturn void EventLoop(void);
void DispatchEvent(XEvent *event);
void ProcessPendingEvents(void);
WMagicNumber wAddDeathHandler(pid_t pid, WDeathHandler *callback, void *cdata);
Bool IsDoubleClick(WScreen *scr, XEvent *event);
/* called from the signal handler */
void NotifyDeadProcess(pid_t pid, unsigned char status);
#endif /* WMEVENT_H */

View File

@@ -1,22 +0,0 @@
#include "wmaker/find_image.h"
#include <stdlib.h>
#include <string.h>
#include "WINGs/WUtil.h"
char *FindImage(const char *paths, const char *file)
{
char *tmp, *path = NULL;
tmp = strrchr(file, ':');
if (tmp) {
*tmp = 0;
path = wfindfile(paths, file);
*tmp = ':';
}
if (!tmp || !path)
path = wfindfile(paths, file);
return path;
}

View File

@@ -1,6 +0,0 @@
#ifndef WMFIND_IMAGE_H_
#define WMFIND_IMAGE_H_
char *FindImage(const char *paths, const char *file);
#endif // WMFIND_IMAGE_H_

View File

@@ -1,12 +0,0 @@
#include "wmaker/flush_expose.h"
#include "wmaker/WindowMaker.h"
void wmFlushExpose(void)
{
XEvent tmpev;
while (XCheckTypedEvent(dpy, Expose, &tmpev))
WMHandleEvent(&tmpev);
XSync(dpy, 0);
}

View File

@@ -1,10 +0,0 @@
#ifndef WMFLUSH_EXPOSE_
#define WMFLUSH_EXPOSE_
#include <X11/X.h>
#include "WINGs/WINGs.h"
void wmFlushExpose(void);
#endif // WMFLUSH_EXPOSE_

View File

@@ -18,15 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/wconfig.h"
#include "wmaker/GNUstep.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/window/framewin.h"
#include "wmaker/is_double_click.h"
#include "wmaker/resources.h"
#include "wmaker/shrink_string.h"
#include "wmaker/stacking.h"
#include "wmaker/texture.h"
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -39,14 +31,17 @@
#include "wrlib/wraster.h"
/* #include "texture.h" */
/* #include "screen.h" */
/* #include "wcore.h" */
/* #include "window.h" */
/* #include "framewin.h" */
/* #include "stacking.h" */
/* #include "misc.h" */
/* #include "event.h" */
#include "WindowMaker.h"
#include "GNUstep.h"
#include "texture.h"
#include "resources.h"
#include "screen.h"
#include "wcore.h"
#include "window.h"
#include "framewin.h"
#include "stacking.h"
#include "misc.h"
#include "event.h"
static void handleExpose(WObjDescriptor * desc, XEvent * event);
@@ -436,6 +431,48 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
}
}
void wFrameWindowDestroy(WFrameWindow * fwin)
{
int i;
if (fwin->left_button)
wCoreDestroy(fwin->left_button);
#ifdef XKB_BUTTON_HINT
if (fwin->language_button)
wCoreDestroy(fwin->language_button);
#endif
if (fwin->right_button)
wCoreDestroy(fwin->right_button);
if (fwin->resizebar)
wCoreDestroy(fwin->resizebar);
if (fwin->titlebar)
wCoreDestroy(fwin->titlebar);
RemoveFromStackList(fwin->core);
wCoreDestroy(fwin->core);
if (fwin->title)
wfree(fwin->title);
for (i = 0; i < (fwin->flags.single_texture ? 1 : 3); i++) {
FREE_PIXMAP(fwin->title_back[i]);
if (wPreferences.new_style == TS_NEW) {
FREE_PIXMAP(fwin->lbutton_back[i]);
#ifdef XKB_BUTTON_HINT
FREE_PIXMAP(fwin->languagebutton_back[i]);
#endif
FREE_PIXMAP(fwin->rbutton_back[i]);
}
}
wfree(fwin);
}
void wFrameWindowChangeState(WFrameWindow * fwin, int state)
{
if (fwin->flags.state == state)

191
bazel/wmaker/framewin.h Normal file
View File

@@ -0,0 +1,191 @@
/*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef WMFRAMEWINDOW_H_
#define WMFRAMEWINDOW_H_
#include "wcore.h"
#include "pixmap.h"
#define BORDER_TOP 1
#define BORDER_BOTTOM 2
#define BORDER_LEFT 4
#define BORDER_RIGHT 8
#define BORDER_ALL (1|2|4|8)
#define WFF_TITLEBAR (1<<0)
#define WFF_LEFT_BUTTON (1<<1)
#define WFF_RIGHT_BUTTON (1<<2)
#define WFF_RESIZEBAR (1<<3)
#define WFF_BORDER (1<<4)
#define WFF_SINGLE_STATE (1<<5)
#ifdef XKB_BUTTON_HINT
#define WFF_LANGUAGE_BUTTON (1<<6)
#endif
#define WFF_SELECTED (1<<7)
#define WFF_IS_SHADED (1<<16)
typedef struct WFrameWindow {
WScreen *screen_ptr; /* pointer to the screen structure */
WCoreWindow *core;
WCoreWindow *titlebar; /* the titlebar */
WCoreWindow *left_button; /* miniaturize button */
#ifdef XKB_BUTTON_HINT
WCoreWindow *language_button;
#endif
WCoreWindow *right_button; /* close button */
short workspace; /* workspace that the window occupies */
short top_width;
int *title_clearance;
int *title_min_height;
int *title_max_height;
short bottom_width;
short resizebar_corner_width;
WCoreWindow *resizebar; /* bottom resizebar */
Pixmap title_back[3]; /* focused, unfocused, pfocused */
Pixmap resizebar_back[3]; /* any, None, None */
Pixmap lbutton_back[3];
Pixmap rbutton_back[3];
#ifdef XKB_BUTTON_HINT
Pixmap languagebutton_back[3];
#endif
WPixmap *lbutton_image;
WPixmap *rbutton_image;
#ifdef XKB_BUTTON_HINT
WPixmap *languagebutton_image;
#endif
union WTexture **title_texture;
union WTexture **resizebar_texture;
WMColor **title_color;
WMFont **font;
char *title; /* window name (title) */
#ifdef KEEP_XKB_LOCK_STATUS
int languagemode;
int last_languagemode;
#endif /* KEEP_XKB_LOCK_STATUS */
/* thing that uses this frame. passed as data to callbacks */
void *child;
/* callbacks */
void (*on_click_left)(WCoreWindow *sender, void *data, XEvent *event);
#ifdef XKB_BUTTON_HINT
void (*on_click_language)(WCoreWindow *sender, void *data, XEvent *event);
#endif
void (*on_click_right)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_dblclick_right)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_mousedown_titlebar)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_dblclick_titlebar)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_mousedown_resizebar)(WCoreWindow *sender, void *data, XEvent *event);
struct {
unsigned int state:2; /* 3 possible states */
unsigned int justification:2;
unsigned int titlebar:1;
unsigned int resizebar:1;
unsigned int left_button:1;
unsigned int right_button:1;
#ifdef XKB_BUTTON_HINT
unsigned int language_button:1;
#endif
unsigned int need_texture_remake:1;
unsigned int single_texture:1;
unsigned int hide_left_button:1;
unsigned int hide_right_button:1;
#ifdef XKB_BUTTON_HINT
unsigned int hide_language_button:1;
#endif
unsigned int need_texture_change:1;
unsigned int lbutton_dont_fit:1;
unsigned int rbutton_dont_fit:1;
#ifdef XKB_BUTTON_HINT
unsigned int languagebutton_dont_fit:1;
#endif
unsigned int repaint_only_titlebar:1;
unsigned int repaint_only_resizebar:1;
unsigned int is_client_window_frame:1;
unsigned int incomplete_title:1;
} flags;
int depth;
Visual *visual;
Colormap colormap;
unsigned long *border_pixel;
unsigned long *focused_border_pixel;
unsigned long *selected_border_pixel;
} WFrameWindow;
WFrameWindow*
wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int width, int height, int *clearance,
int *title_min, int *title_max, int flags,
union WTexture **title_texture,
union WTexture **resize_texture,
WMColor **color, WMFont **font,
int depth, Visual *visual, Colormap colormap);
void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags);
void wFrameWindowDestroy(WFrameWindow *fwin);
void wFrameWindowChangeState(WFrameWindow *fwin, int state);
void wFrameWindowPaint(WFrameWindow *fwin);
void wFrameWindowConfigure(WFrameWindow *fwin, int x, int y, int width, int height);
void wFrameWindowResize(WFrameWindow *fwin, int width, int height);
void wFrameWindowShowButton(WFrameWindow *fwin, int flags);
void wFrameWindowHideButton(WFrameWindow *fwin, int flags);
int wFrameWindowChangeTitle(WFrameWindow *fwin, const char *new_title);
#ifdef XKB_BUTTON_HINT
void wFrameWindowUpdateLanguageButton(WFrameWindow *fwin);
#endif
#endif

13
bazel/wmaker/geometry.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef WGEOMETRY_H_
#define WGEOMETRY_H_
typedef struct {
int x1, y1;
int x2, y2;
} WArea;
typedef struct WCoord {
int x, y;
} WCoord;
#endif // WGEOMETRY_H_

View File

@@ -1,35 +0,0 @@
#include "wmaker/get_command_for_window.h"
#include "wmaker/wconfig.h"
#include "wmaker/WindowMaker.h"
#include <X11/Xlib.h>
static char *getCommandForWindow(Window win, int elements)
{
char **argv, *command = NULL;
int argc;
if (XGetCommand(dpy, win, &argv, &argc)) {
if (argc > 0 && argv != NULL) {
if (elements == 0)
elements = argc;
command = wtokenjoin(argv, WMIN(argc, elements));
if (command[0] == 0) {
wfree(command);
command = NULL;
}
}
if (argv) {
XFreeStringList(argv);
}
}
return command;
}
/* Free result when done */
char *GetCommandForWindow(Window win)
{
return getCommandForWindow(win, 0);
}

View File

@@ -1,8 +0,0 @@
#ifndef WMGET_COMMAND_FOR_WINDOW_
#define WMGET_COMMAND_FOR_WINDOW_
#include <X11/X.h>
char *GetCommandForWindow(Window win);
#endif // WMGET_COMMAND_FOR_WINDOW_

View File

@@ -1,82 +0,0 @@
#include "wmaker/get_generic_value.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/wdefaults.h"
#include <stdio.h>
#include <string.h>
#include "WINGs/WUtil.h"
/* WARNING: Do not free the value returned by this function!! */
char *getString(WMPropList * key, WMPropList * value)
{
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."), WMGetFromPLString(key), "String");
return NULL;
}
return WMGetFromPLString(value);
}
WMPropList *get_generic_value(const char *instance, const char *class,
WMPropList *option, Bool default_icon)
{
WMPropList *value, *key, *dict;
value = NULL;
WMPLSetCaseSensitive(True);
/* Search the icon name using class and instance */
if (class && instance) {
char *buffer;
buffer = wmalloc(strlen(class) + strlen(instance) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
dict = WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, key);
WMReleasePropList(key);
if (dict)
value = WMGetFromPLDictionary(dict, option);
}
/* Search the icon name using instance */
if (!value && instance) {
key = WMCreatePLString(instance);
dict = WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, key);
WMReleasePropList(key);
if (dict)
value = WMGetFromPLDictionary(dict, option);
}
/* Search the icon name using class */
if (!value && class) {
key = WMCreatePLString(class);
dict = WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, key);
WMReleasePropList(key);
if (dict)
value = WMGetFromPLDictionary(dict, option);
}
/* Search the default icon name - See default_icon argument! */
if (!value && default_icon) {
WMPropList *field = get_attribute_prop_list(WA_AttributeField_AnyWindow);
if (field) {
dict = WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, field);
if (dict)
value = WMGetFromPLDictionary(dict, option);
}
}
WMPLSetCaseSensitive(False);
return value;
}

View File

@@ -1,11 +0,0 @@
#ifndef WMGET_GENERIC_VALUE_H_
#define WMGET_GENERIC_VALUE_H_
#include "WINGs/WUtil.h"
char *getString(WMPropList * key, WMPropList * value);
WMPropList *get_generic_value(const char *instance, const char *class,
WMPropList *option, Bool default_icon);
#endif // WMGET_GENERIC_VALUE_H_

6
bazel/wmaker/globals.c Normal file
View File

@@ -0,0 +1,6 @@
#include "wmaker/globals.h"
#include "X11/Xlib.h"
Display *dpy;
struct wmaker_global_variables;

166
bazel/wmaker/globals.h Normal file
View File

@@ -0,0 +1,166 @@
#ifndef WGLOBALS_H_
#define WGLOBALS_H_
#include "X11/Xlib.h"
#include "X11/Xutil.h"
extern Display *dpy;
/* program states */
typedef enum {
WSTATE_NORMAL = 0,
WSTATE_NEED_EXIT = 1,
WSTATE_NEED_RESTART = 2,
WSTATE_EXITING = 3,
WSTATE_RESTARTING = 4,
WSTATE_MODAL = 5,
WSTATE_NEED_REREAD = 6
} wprog_state;
extern struct wmaker_global_variables {
/* Tracking of the state of the program */
struct {
wprog_state state;
wprog_state signal_state;
} program;
/* locale to use. NULL==POSIX or C */
const char *locale;
/* Tracking of X events timestamps */
struct {
/* ts of the last event we received */
Time last_event;
/* ts on the last time we did XSetInputFocus() */
Time focus_change;
} timestamp;
/* Global Domains, for storing dictionaries */
struct {
/* Note: you must #include <defaults.h> if you want to use them */
struct WDDomain *wmaker;
struct WDDomain *window_attr;
struct WDDomain *root_menu;
} domain;
/* Screens related */
int screen_count;
/*
* Ignore Workspace Change:
* this variable is used to prevent workspace switch while certain
* operations are ongoing.
*/
Bool ignore_workspace_change;
/*
* Process WorkspaceMap Event:
* this variable is set when the Workspace Map window is being displayed,
* it is mainly used to avoid re-opening another one at the same time
*/
Bool process_workspacemap_event;
#ifdef HAVE_INOTIFY
struct {
int fd_event_queue; /* Inotify's queue file descriptor */
int wd_defaults; /* Watch Descriptor for the 'Defaults' configuration file */
} inotify;
#endif
/* definition for X Atoms */
struct {
/* Window-Manager related */
struct {
Atom state;
Atom change_state;
Atom protocols;
Atom take_focus;
Atom delete_window;
Atom save_yourself;
Atom client_leader;
Atom colormap_windows;
Atom colormap_notify;
Atom ignore_focus_events;
} wm;
/* GNUStep related */
struct {
Atom wm_attr;
Atom wm_miniaturize_window;
Atom wm_resizebar;
Atom titlebar_state;
} gnustep;
/* Destkop-environment related */
struct {
Atom gtk_object_path;
} desktop;
/* WindowMaker specific */
struct {
Atom menu;
Atom wm_protocols;
Atom state;
Atom wm_function;
Atom noticeboard;
Atom command;
Atom icon_size;
Atom icon_tile;
} wmaker;
} atom;
/* X Contexts */
struct {
XContext client_win;
XContext app_win;
XContext stack;
} context;
/* X Extensions */
struct {
#ifdef USE_XSHAPE
struct {
Bool supported;
int event_base;
} shape;
#endif
#ifdef KEEP_XKB_LOCK_STATUS
struct {
Bool supported;
int event_base;
} xkb;
#endif
#ifdef USE_RANDR
struct {
Bool supported;
int event_base;
} randr;
#endif
/*
* If no extension were activated, we would end up with an empty
* structure, which old compilers may not appreciate, so let's
* work around this with a simple:
*/
int dummy;
} xext;
/* Keyboard and shortcuts */
struct {
/*
* Bit-mask to hide special key modifiers which we don't want to
* impact the shortcuts (typically: CapsLock, NumLock, ScrollLock)
*/
unsigned int modifiers_mask;
} shortcut;
} w_global;
#endif // WGLOBALS_H_

View File

@@ -1,4 +0,0 @@
#include "wmaker/hack_mask.h"
unsigned int _NumLockMask = 0;
unsigned int _ScrollLockMask = 0;

View File

@@ -1,7 +0,0 @@
#ifndef WMHACK_MASK_H_
#define WMHACK_MASK_H_
extern unsigned int _NumLockMask;
extern unsigned int _ScrollLockMask;
#endif // WMHACK_MASK_H_

View File

@@ -1,85 +0,0 @@
#ifndef WMHACKED_KB_H_
#define WMHACKED_KB_H_
#include "wmaker/hacked_kb.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/hack_mask.h"
void
wHackedGrabButton(unsigned int button, unsigned int modifiers,
Window grab_window, Bool owner_events,
unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor)
{
XGrabButton(dpy, button, modifiers, grab_window, owner_events,
event_mask, pointer_mode, keyboard_mode, confine_to, cursor);
if (modifiers == AnyModifier)
return;
XGrabButton(dpy, button, modifiers | LockMask, grab_window, owner_events,
event_mask, pointer_mode, keyboard_mode, confine_to, cursor);
#ifdef NUMLOCK_HACK
/* same as above, but for mouse buttons */
if (_NumLockMask)
XGrabButton(dpy, button, modifiers | _NumLockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
if (_ScrollLockMask)
XGrabButton(dpy, button, modifiers | _ScrollLockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
if (_NumLockMask && _ScrollLockMask)
XGrabButton(dpy, button, modifiers | _ScrollLockMask | _NumLockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
if (_NumLockMask)
XGrabButton(dpy, button, modifiers | _NumLockMask | LockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
if (_ScrollLockMask)
XGrabButton(dpy, button, modifiers | _ScrollLockMask | LockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
if (_NumLockMask && _ScrollLockMask)
XGrabButton(dpy, button, modifiers | _ScrollLockMask | _NumLockMask | LockMask,
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
#endif /* NUMLOCK_HACK */
}
#ifdef NUMLOCK_HACK
void
wHackedGrabKey(int keycode, unsigned int modifiers,
Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode)
{
if (modifiers == AnyModifier)
return;
/* grab all combinations of the modifier with CapsLock, NumLock and
* ScrollLock. How much memory/CPU does such a monstrosity consume
* in the server?
*/
if (_NumLockMask)
XGrabKey(dpy, keycode, modifiers | _NumLockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
if (_ScrollLockMask)
XGrabKey(dpy, keycode, modifiers | _ScrollLockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
if (_NumLockMask && _ScrollLockMask)
XGrabKey(dpy, keycode, modifiers | _NumLockMask | _ScrollLockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
if (_NumLockMask)
XGrabKey(dpy, keycode, modifiers | _NumLockMask | LockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
if (_ScrollLockMask)
XGrabKey(dpy, keycode, modifiers | _ScrollLockMask | LockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
if (_NumLockMask && _ScrollLockMask)
XGrabKey(dpy, keycode, modifiers | _NumLockMask | _ScrollLockMask | LockMask,
grab_window, owner_events, pointer_mode, keyboard_mode);
/* phew, I guess that's all, right? */
}
#endif
#endif // WMHACKED_KB_H_

View File

@@ -1,20 +0,0 @@
#ifndef WMHACKED_GRAB_BUTTON_H_
#define WMHACKED_GRAB_BUTTON_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/hacked_kb.h"
#include <X11/X.h>
void wHackedGrabButton(unsigned int button, unsigned int modifiers,
Window grab_window, Bool owner_events,
unsigned int event_mask, int pointer_mode,
int keyboard_mode, Window confine_to, Cursor cursor);
#ifdef NUMLOCK_HACK
void wHackedGrabKey(int keycode, unsigned int modifiers,
Window grab_window, Bool owner_events, int pointer_mode,
int keyboard_mode);
#endif
#endif // WMHACKED_GRAB_BUTTON_H_

View File

@@ -1,25 +1,65 @@
#include "wmaker/icon/icon.h"
/* icon.c - window icon and dock and appicon parent
*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/WindowMaker.h"
#include "wmaker/application_tracking.h"
#include "wmaker/appicon_files.h"
#include "wmaker/atoms.h"
#include "wmaker/find_image.h"
#include "wmaker/get_generic_value.h"
#include "wmaker/hacked_kb.h"
#include "wmaker/wdefaults.h"
#include "wmaker/wcore.h"
#include "wconfig.h"
#include <stdint.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <X11/X.h>
#include <X11/Xatom.h>
#include <ctype.h>
#include "wrlib/wraster.h"
#include <sys/stat.h>
#include "WindowMaker.h"
#include "wcore.h"
#include "texture.h"
#include "window.h"
#include "icon.h"
#include "actions.h"
#include "stacking.h"
#include "application.h"
#include "defaults.h"
#include "appicon.h"
#include "wmspec.h"
#include "misc.h"
#include "startup.h"
#include "event.h"
#include "winmenu.h"
/**** Global varianebles ****/
#define MOD_MASK wPreferences.modifier_mask
#define CACHE_ICON_PATH "/" PACKAGE_TARNAME "/CachedPixmaps"
#define ICON_BORDER 3
static void miniwindowExpose(WObjDescriptor *desc, XEvent *event);
static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event);
static void miniwindowDblClick(WObjDescriptor *desc, XEvent *event);
static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y);
static void set_dockapp_in_icon(WIcon *icon);
static void get_rimage_icon_from_icon_win(WIcon *icon);
static void get_rimage_icon_from_user_icon(WIcon *icon);
@@ -27,6 +67,7 @@ static void get_rimage_icon_from_default_icon(WIcon *icon);
static void get_rimage_icon_from_x11(WIcon *icon);
static void icon_update_pixmap(WIcon *icon, RImage *image);
static void unset_icon_image(WIcon *icon);
/****** Notification Observers ******/
@@ -62,44 +103,21 @@ static void tileObserver(void *self, WMNotification *notif)
/************************************/
static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y, struct WIconEventHandler *event_handler)
static int getSize(Drawable d, unsigned int *w, unsigned int *h, unsigned int *dep)
{
WIcon *icon;
Window rjunk;
int xjunk, yjunk;
unsigned int bjunk;
icon = wmalloc(sizeof(WIcon));
icon->core = wCoreCreateTopLevel(scr,
coord_x,
coord_y,
wPreferences.icon_size,
wPreferences.icon_size,
0, scr->w_depth, scr->w_visual, scr->w_colormap,
scr->white_pixel);
/* will be overriden if this is a application icon */
icon->core->descriptor.handle_mousedown = event_handler->mouseDown;
icon->core->descriptor.handle_expose = event_handler->expose;
icon->core->descriptor.parent_type = WCLASS_MINIWINDOW;
icon->core->descriptor.parent = icon;
icon->core->stacking = wmalloc(sizeof(WStacking));
icon->core->stacking->above = NULL;
icon->core->stacking->under = NULL;
icon->core->stacking->window_level = NORMAL_ICON_LEVEL;
icon->core->stacking->child_of = NULL;
/* Icon image */
icon->file = NULL;
icon->file_image = NULL;
return icon;
return XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep);
}
WIcon *icon_create_for_wwindow(WWindow *wwin, struct WIconEventHandler *event_handler)
WIcon *icon_create_for_wwindow(WWindow *wwin)
{
WScreen *scr = wwin->screen_ptr;
WIcon *icon;
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y, event_handler);
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y);
icon->owner = wwin;
if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) {
@@ -132,11 +150,11 @@ WIcon *icon_create_for_wwindow(WWindow *wwin, struct WIconEventHandler *event_ha
return icon;
}
WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile, struct WIconEventHandler *event_handler)
WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile)
{
WIcon *icon;
icon = icon_create_core(scr, 0, 0, event_handler);
icon = icon_create_core(scr, 0, 0);
icon->tile_type = tile;
set_icon_image_from_database(icon, wm_instance, wm_class, command);
@@ -149,64 +167,71 @@ WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char *wm_in
return icon;
}
/* XGetIconName Wrapper */
Bool wGetIconName(Display *dpy, Window win, char **iconname)
static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y)
{
XTextProperty text_prop;
char **list;
int num;
WIcon *icon;
if (XGetWMIconName(dpy, win, &text_prop) != 0 && text_prop.value && text_prop.nitems > 0) {
if (text_prop.encoding == XA_STRING)
*iconname = (char *)text_prop.value;
else {
text_prop.nitems = strlen((char *)text_prop.value);
if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= Success && num > 0 && *list) {
XFree(text_prop.value);
*iconname = wstrdup(*list);
XFreeStringList(list);
} else
*iconname = (char *)text_prop.value;
icon = wmalloc(sizeof(WIcon));
icon->core = wCoreCreateTopLevel(scr,
coord_x,
coord_y,
wPreferences.icon_size,
wPreferences.icon_size,
0, scr->w_depth, scr->w_visual, scr->w_colormap,
scr->white_pixel);
/* will be overriden if this is a application icon */
icon->core->descriptor.handle_mousedown = miniwindowMouseDown;
icon->core->descriptor.handle_expose = miniwindowExpose;
icon->core->descriptor.parent_type = WCLASS_MINIWINDOW;
icon->core->descriptor.parent = icon;
icon->core->stacking = wmalloc(sizeof(WStacking));
icon->core->stacking->above = NULL;
icon->core->stacking->under = NULL;
icon->core->stacking->window_level = NORMAL_ICON_LEVEL;
icon->core->stacking->child_of = NULL;
/* Icon image */
icon->file = NULL;
icon->file_image = NULL;
return icon;
}
void wIconDestroy(WIcon *icon)
{
WCoreWindow *core = icon->core;
WScreen *scr = core->screen_ptr;
WMRemoveNotificationObserver(icon);
if (icon->handlerID)
WMDeleteTimerHandler(icon->handlerID);
if (icon->icon_win) {
int x = 0, y = 0;
if (icon->owner) {
x = icon->owner->icon_x;
y = icon->owner->icon_y;
}
return True;
XUnmapWindow(dpy, icon->icon_win);
XReparentWindow(dpy, icon->icon_win, scr->root_win, x, y);
}
*iconname = NULL;
return False;
}
int wIconGetSize(Drawable d, unsigned int *w, unsigned int *h, unsigned int *dep)
{
Window rjunk;
int xjunk, yjunk;
unsigned int bjunk;
return XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep);
}
void wIconChangeTitle(WIcon *icon, WWindow *wwin)
{
if (!icon || !wwin)
return;
/* Remove the previous icon title */
if (icon->icon_name != NULL)
if (icon->icon_name)
XFree(icon->icon_name);
/* Set the new one, using two methods to identify
the icon name or switch back to window name */
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (!icon->icon_name)
if (!wGetIconName(dpy, wwin->client_win, &icon->icon_name))
icon->icon_name = wNETWMGetWindowName(wwin->client_win);
}
if (icon->pixmap)
XFreePixmap(dpy, icon->pixmap);
void wIconSetHighlited(WIcon *icon, Bool flag)
{
if (icon->highlighted == flag)
return;
if (icon->mini_preview)
XFreePixmap(dpy, icon->mini_preview);
icon->highlighted = flag;
update_icon_pixmap(icon);
unset_icon_image(icon);
wCoreDestroy(icon->core);
wfree(icon);
}
static void drawIconTitleBackground(WScreen *scr, Pixmap pixmap, int height)
@@ -294,66 +319,21 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
icon->pixmap = pixmap;
}
/* Set the dockapp in the WIcon */
static void set_dockapp_in_icon(WIcon *icon)
void wIconChangeTitle(WIcon *icon, WWindow *wwin)
{
XWindowAttributes attr;
WScreen *scr = icon->core->screen_ptr;
unsigned int w, h, d;
if (!icon || !wwin)
return;
/* Reparent the dock application to the icon */
/* Remove the previous icon title */
if (icon->icon_name != NULL)
XFree(icon->icon_name);
/* We need the application size to center it
* and show in the correct position */
wIconGetSize(icon->icon_win, &w, &h, &d);
/* Set the background pixmap */
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
/* Set the icon border */
XSetWindowBorderWidth(dpy, icon->icon_win, 0);
/* Put the dock application in the icon */
XReparentWindow(dpy, icon->icon_win, icon->core->window,
(wPreferences.icon_size - w) / 2,
(wPreferences.icon_size - h) / 2);
/* Show it and save */
XMapWindow(dpy, icon->icon_win);
XAddToSaveSet(dpy, icon->icon_win);
/* Needed to move the icon clicking on the application part */
if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
(attr.all_event_masks & ButtonPressMask))
wHackedGrabButton(Button1, wPreferences.modifier_mask, icon->core->window, True,
ButtonPressMask, GrabModeSync, GrabModeAsync,
None, wPreferences.cursor[WCUR_ARROW]);
}
void update_icon_pixmap(WIcon *icon)
{
if (icon->pixmap != None)
XFreePixmap(dpy, icon->pixmap);
icon->pixmap = None;
/* Create the pixmap */
if (icon->file_image)
icon_update_pixmap(icon, icon->file_image);
/* If dockapp, put inside the icon */
if (icon->icon_win != None) {
/* file_image is NULL, because is docked app */
icon_update_pixmap(icon, NULL);
set_dockapp_in_icon(icon);
}
/* No pixmap, set default background */
if (icon->pixmap != None)
XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap);
/* Paint it */
wIconPaint(icon);
/* Set the new one, using two methods to identify
the icon name or switch back to window name */
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (!icon->icon_name)
if (!wGetIconName(dpy, wwin->client_win, &icon->icon_name))
icon->icon_name = wNETWMGetWindowName(wwin->client_win);
}
RImage *wIconValidateIconSize(RImage *icon, int max_size)
@@ -414,6 +394,30 @@ static char *get_name_for_wwin(WWindow *wwin)
return get_name_for_instance_class(wwin->wm_instance, wwin->wm_class);
}
char *get_name_for_instance_class(const char *wm_instance, const char *wm_class)
{
char *suffix;
int len;
if (wm_class && wm_instance) {
len = strlen(wm_class) + strlen(wm_instance) + 2;
suffix = wmalloc(len);
snprintf(suffix, len, "%s.%s", wm_instance, wm_class);
} else if (wm_class) {
len = strlen(wm_class) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wm_class);
} else if (wm_instance) {
len = strlen(wm_instance) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wm_instance);
} else {
return NULL;
}
return suffix;
}
static char *get_icon_cache_path(void)
{
const char *prefix;
@@ -540,6 +544,64 @@ void remove_cache_icon(char *filename)
wfree(cachepath);
}
static void cycleColor(void *data)
{
WIcon *icon = (WIcon *) data;
WScreen *scr = icon->core->screen_ptr;
XGCValues gcv;
icon->step--;
gcv.dash_offset = icon->step;
XChangeGC(dpy, scr->icon_select_gc, GCDashOffset, &gcv);
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
icon->handlerID = WMAddTimerHandler(COLOR_CYCLE_DELAY, cycleColor, icon);
}
void wIconSetHighlited(WIcon *icon, Bool flag)
{
if (icon->highlighted == flag)
return;
icon->highlighted = flag;
update_icon_pixmap(icon);
}
void wIconSelect(WIcon *icon)
{
WScreen *scr = icon->core->screen_ptr;
icon->selected = !icon->selected;
if (icon->selected) {
icon->step = 0;
if (!wPreferences.dont_blink)
icon->handlerID = WMAddTimerHandler(10, cycleColor, icon);
else
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
} else {
if (icon->handlerID) {
WMDeleteTimerHandler(icon->handlerID);
icon->handlerID = NULL;
}
XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, icon->core->height, True);
}
}
static void unset_icon_image(WIcon *icon)
{
if (icon->file) {
wfree(icon->file);
icon->file = NULL;
}
if (icon->file_image) {
RReleaseImage(icon->file_image);
icon->file_image = NULL;
}
}
void set_icon_image_from_image(WIcon *icon, RImage *image)
{
if (!icon)
@@ -551,17 +613,21 @@ void set_icon_image_from_image(WIcon *icon, RImage *image)
icon->file_image = image;
}
void unset_icon_image(WIcon *icon)
void set_icon_minipreview(WIcon *icon, RImage *image)
{
if (icon->file) {
wfree(icon->file);
icon->file = NULL;
}
Pixmap tmp;
RImage *scaled_mini_preview;
WScreen *scr = icon->core->screen_ptr;
if (icon->file_image) {
RReleaseImage(icon->file_image);
icon->file_image = NULL;
scaled_mini_preview = RSmoothScaleImage(image, wPreferences.minipreview_size - 2 * MINIPREVIEW_BORDER,
wPreferences.minipreview_size - 2 * MINIPREVIEW_BORDER);
if (RConvertImage(scr->rcontext, scaled_mini_preview, &tmp)) {
if (icon->mini_preview != None)
XFreePixmap(dpy, icon->mini_preview);
icon->mini_preview = tmp;
}
RReleaseImage(scaled_mini_preview);
}
void wIconUpdate(WIcon *icon)
@@ -594,6 +660,32 @@ void wIconUpdate(WIcon *icon)
update_icon_pixmap(icon);
}
void update_icon_pixmap(WIcon *icon)
{
if (icon->pixmap != None)
XFreePixmap(dpy, icon->pixmap);
icon->pixmap = None;
/* Create the pixmap */
if (icon->file_image)
icon_update_pixmap(icon, icon->file_image);
/* If dockapp, put inside the icon */
if (icon->icon_win != None) {
/* file_image is NULL, because is docked app */
icon_update_pixmap(icon, NULL);
set_dockapp_in_icon(icon);
}
/* No pixmap, set default background */
if (icon->pixmap != None)
XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap);
/* Paint it */
wIconPaint(icon);
}
static void get_rimage_icon_from_x11(WIcon *icon)
{
/* Remove the icon image */
@@ -641,6 +733,42 @@ static void get_rimage_icon_from_icon_win(WIcon *icon)
icon->file_image = image;
}
/* Set the dockapp in the WIcon */
static void set_dockapp_in_icon(WIcon *icon)
{
XWindowAttributes attr;
WScreen *scr = icon->core->screen_ptr;
unsigned int w, h, d;
/* Reparent the dock application to the icon */
/* We need the application size to center it
* and show in the correct position */
getSize(icon->icon_win, &w, &h, &d);
/* Set the background pixmap */
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
/* Set the icon border */
XSetWindowBorderWidth(dpy, icon->icon_win, 0);
/* Put the dock application in the icon */
XReparentWindow(dpy, icon->icon_win, icon->core->window,
(wPreferences.icon_size - w) / 2,
(wPreferences.icon_size - h) / 2);
/* Show it and save */
XMapWindow(dpy, icon->icon_win);
XAddToSaveSet(dpy, icon->icon_win);
/* Needed to move the icon clicking on the application part */
if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
(attr.all_event_masks & ButtonPressMask))
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
ButtonPressMask, GrabModeSync, GrabModeAsync,
None, wPreferences.cursor[WCUR_ARROW]);
}
/* Get the RImage from the XWindow wm_hints */
RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
{
@@ -653,7 +781,7 @@ RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
wwin = icon->owner;
if (!wIconGetSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) {
if (!getSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) {
icon->owner->wm_hints->flags &= ~IconPixmapHint;
return NULL;
}
@@ -668,289 +796,173 @@ RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
return image;
}
/* This function creates the RImage using the default icon */
RImage *get_default_image(WScreen *scr)
/* This function updates in the screen the icon title */
static void update_icon_title(WIcon *icon)
{
RImage *image = NULL;
char *path = NULL;
/* Get the filename full path */
path = get_default_image_path();
if (!path)
return NULL;
/* Get the default icon */
image = get_rimage_from_file(scr, path, wPreferences.icon_size);
if (!image)
wwarning(_("could not find default icon \"%s\""), path);
/* Resize the icon to the wPreferences.icon_size size
* usually this function will return early, because size is right */
image = wIconValidateIconSize(image, wPreferences.icon_size);
return image;
}
/* This function returns the image picture for the file_name file */
RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size)
{
RImage *image = NULL;
if (!file_name)
return NULL;
image = RLoadImage(scr->rcontext, file_name, 0);
if (!image)
wwarning(_("error loading image file \"%s\": %s"), file_name,
RMessageForError(RErrorCode));
image = wIconValidateIconSize(image, max_size);
return image;
}
/* Get the name of the Icon File. If default_icon is True, then, default value included */
char *wDefaultGetIconFile(const char *instance, const char *class, Bool default_icon)
{
WMPropList *value;
WScreen *scr = icon->core->screen_ptr;
int x, l, w;
char *tmp;
WMPropList *field = get_attribute_prop_list(WA_AttributeField_Icon);
/* draw the icon title */
if (icon->show_title && icon->icon_name != NULL) {
tmp = ShrinkString(scr->icon_title_font, icon->icon_name, wPreferences.icon_size - 4);
w = WMWidthOfString(scr->icon_title_font, tmp, l = strlen(tmp));
if (!field)
return NULL;
if (w > icon->core->width - 4)
x = (icon->core->width - 4) - w;
else
x = (icon->core->width - w) / 2;
if (!w_global.domain.window_attr || !w_global.domain.window_attr->dictionary)
return NULL;
value = get_generic_value(instance, class, field, default_icon);
if (!value)
return NULL;
tmp = getString(field, value);
return tmp;
WMDrawString(scr->wmscreen, icon->core->window, scr->icon_title_color,
scr->icon_title_font, x, 1, tmp, l);
wfree(tmp);
}
}
/* This function returns the default icon's full path
* If the path for an icon is not found, returns NULL */
char *get_default_image_path(void)
void wIconPaint(WIcon *icon)
{
char *path = NULL, *file = NULL;
if (!icon || !icon->core || !icon->core->screen_ptr)
return;
/* Get the default icon */
file = wDefaultGetIconFile(NULL, NULL, True);
if (file)
path = FindImage(wPreferences.icon_path, file);
WScreen *scr = icon->core->screen_ptr;
return path;
XClearWindow(dpy, icon->core->window);
update_icon_title(icon);
if (icon->selected)
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
}
/* Get the file name of the image, using instance and class */
char *get_icon_filename(const char *winstance, const char *wclass, const char *command,
Bool default_icon)
/******************************************************************/
static void miniwindowExpose(WObjDescriptor *desc, XEvent *event)
{
char *file_name;
char *file_path;
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
/* Get the file name of the image, using instance and class */
file_name = wDefaultGetIconFile(winstance, wclass, default_icon);
wIconPaint(desc->parent);
}
/* Check if the file really exists in the disk */
if (file_name)
file_path = FindImage(wPreferences.icon_path, file_name);
else
file_path = NULL;
static void miniwindowDblClick(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
/* If the specific icon filename is not found, and command is specified,
* then include the .app icons and re-do the search. */
if (!file_path && command) {
wApplicationExtractDirPackIcon(command, winstance, wclass);
file_name = wDefaultGetIconFile(winstance, wclass, False);
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
if (file_name) {
file_path = FindImage(wPreferences.icon_path, file_name);
if (!file_path)
wwarning(_("icon \"%s\" doesn't exist, check your config files"), file_name);
assert(icon->owner != NULL);
/* FIXME: Here, if file_path does not exist then the icon is still in the
* "icon database" (w_global.domain.window_attr->dictionary), but the file
* for the icon is no more on disk. Therefore, we should remove it from the
* database. Is possible to do that using wDefaultChangeIcon() */
wDeiconifyWindow(icon->owner);
}
static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
WWindow *wwin = icon->owner;
XEvent ev;
int x = wwin->icon_x, y = wwin->icon_y;
int dx = event->xbutton.x, dy = event->xbutton.y;
int grabbed = 0;
int clickButton = event->xbutton.button;
Bool hasMoved = False;
if (WCHECK_STATE(WSTATE_MODAL))
return;
if (IsDoubleClick(icon->core->screen_ptr, event)) {
miniwindowDblClick(desc, event);
return;
}
if (event->xbutton.button == Button1) {
if (event->xbutton.state & MOD_MASK)
wLowerFrame(icon->core);
else
wRaiseFrame(icon->core);
if (event->xbutton.state & ShiftMask) {
wIconSelect(icon);
wSelectWindow(icon->owner, !wwin->flags.selected);
}
} else if (event->xbutton.button == Button3) {
WObjDescriptor *desc;
OpenMiniwindowMenu(wwin, event->xbutton.x_root, event->xbutton.y_root);
/* allow drag select of menu */
desc = &wwin->screen_ptr->window_menu->menu->descriptor;
event->xbutton.send_event = True;
(*desc->handle_mousedown) (desc, event);
return;
}
/*
* Don't wfree(file_name) because it is a direct pointer inside the icon
* dictionary (w_global.domain.window_attr->dictionary) and not a result
* allocated with wstrdup()
*/
if (!file_path && default_icon)
file_path = get_default_image_path();
return file_path;
}
RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass, int max_size)
{
char *file_name = NULL;
/* Get the file name of the image, using instance and class */
file_name = get_icon_filename(winstance, wclass, NULL, True);
return get_rimage_from_file(scr, file_name, max_size);
}
static RImage *makeRImageFromARGBData(unsigned long *data)
{
int size, width, height, i;
RImage *image;
unsigned char *imgdata;
unsigned long pixel;
width = data[0];
height = data[1];
size = width * height;
if (size == 0)
return NULL;
image = RCreateImage(width, height, True);
for (imgdata = image->data, i = 2; i < size + 2; i++, imgdata += 4) {
pixel = data[i];
imgdata[3] = (pixel >> 24) & 0xff; /* A */
imgdata[0] = (pixel >> 16) & 0xff; /* R */
imgdata[1] = (pixel >> 8) & 0xff; /* G */
imgdata[2] = (pixel >> 0) & 0xff; /* B */
if (XGrabPointer(dpy, icon->core->window, False, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
}
return image;
}
/* Find the best icon to be used by Window Maker for appicon/miniwindows. */
static RImage *findBestIcon(unsigned long *data, unsigned long items)
{
int wanted;
int dx, dy, d;
int sx, sy, size;
int best_d, largest;
unsigned long i;
unsigned long *icon;
RImage *src_image, *ret_image;
double f;
if (wPreferences.enforce_icon_margin) {
/* better use only 75% of icon_size. For 64x64 this means 48x48
* This leaves room around the icon for the miniwindow title and
* results in better overall aesthetics -Dan */
wanted = (int)((double)wPreferences.icon_size * 0.75 + 0.5);
/* the size should be a multiple of 4 */
wanted = (wanted >> 2) << 2;
} else {
/* This is the "old" approach, which tries to find the largest
* icon that still fits into icon_size. */
wanted = wPreferences.icon_size;
}
/* try to find an icon which is close to the wanted size, but not larger */
icon = NULL;
best_d = wanted * wanted * 2;
for (i = 0L; i < items - 1;) {
/* get the current icon's size */
sx = (int)data[i];
sy = (int)data[i + 1];
if ((sx < 1) || (sy < 1))
while (1) {
WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask
| ButtonMotionMask | ExposureMask, &ev);
switch (ev.type) {
case Expose:
WMHandleEvent(&ev);
break;
size = sx * sy + 2;
/* check the size difference if it's not too large */
if ((sx <= wanted) && (sy <= wanted)) {
dx = wanted - sx;
dy = wanted - sy;
d = (dx * dx) + (dy * dy);
if (d < best_d) {
icon = &data[i];
best_d = d;
case MotionNotify:
hasMoved = True;
if (!grabbed) {
if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD
|| abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) {
XChangeActivePointerGrab(dpy, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask,
wPreferences.cursor[WCUR_MOVE], CurrentTime);
grabbed = 1;
} else {
break;
}
}
}
i += size;
}
/* if an icon has been found, no transformation is needed */
if (icon)
return makeRImageFromARGBData(icon);
/* We need to scale down an icon. Find the largest one, for it usually
* looks better to scale down a large image by a large scale than a
* small image by a small scale. */
largest = 0;
for (i = 0L; i < items - 1;) {
size = (int)data[i] * (int)data[i + 1];
if (size == 0)
x = ev.xmotion.x_root - dx;
y = ev.xmotion.y_root - dy;
XMoveWindow(dpy, icon->core->window, x, y);
break;
if (size > largest) {
icon = &data[i];
largest = size;
case ButtonPress:
break;
case ButtonRelease:
if (ev.xbutton.button != clickButton)
break;
if (wwin->icon_x != x || wwin->icon_y != y)
wwin->flags.icon_moved = 1;
XMoveWindow(dpy, icon->core->window, x, y);
wwin->icon_x = x;
wwin->icon_y = y;
XUngrabPointer(dpy, CurrentTime);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(wwin->screen_ptr, True);
if (wPreferences.single_click && !hasMoved)
miniwindowDblClick(desc, event);
return;
}
i += size + 2;
}
/* give up if there's no icon to work with */
if (!icon)
return NULL;
/* create a scaled down version of the icon */
src_image = makeRImageFromARGBData(icon);
if (src_image->width > src_image->height) {
f = (double)wanted / (double)src_image->width;
ret_image = RScaleImage(src_image, wanted, (int)(f * (double)(src_image->height)));
} else {
f = (double)wanted / (double)src_image->height;
ret_image = RScaleImage(src_image, (int)(f * (double)src_image->width), wanted);
}
RReleaseImage(src_image);
return ret_image;
}
RImage *get_window_image_from_x11(Window window)
void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const char *wm_class, const char *command)
{
RImage *image;
Atom type;
int format;
unsigned long items, rest;
unsigned long *property;
char *file = NULL;
/* Get the icon from X11 Window */
if (XGetWindowProperty(dpy, window, wm_global_net_wm_icon, 0L, LONG_MAX,
False, XA_CARDINAL, &type, &format, &items, &rest,
(unsigned char **)&property) != Success || !property)
return NULL;
if (type != XA_CARDINAL || format != 32 || items < 2) {
XFree(property);
return NULL;
file = get_icon_filename(wm_instance, wm_class, command, False);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(icon->core->screen_ptr, icon->file, wPreferences.icon_size);
wfree(file);
}
/* Find the best icon */
image = findBestIcon(property, items);
XFree(property);
if (!image)
return NULL;
/* Resize the image to the correct value */
image = wIconValidateIconSize(image, wPreferences.icon_size);
return image;
}

84
bazel/wmaker/icon.h Normal file
View File

@@ -0,0 +1,84 @@
/*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef WMICON_H_
#define WMICON_H_
#include "wcore.h"
#include "window.h"
#define TILE_NORMAL 0
#define TILE_CLIP 1
#define TILE_DRAWER 2
/* This is the border, in pixel, drawn around a Mini-Preview */
#define MINIPREVIEW_BORDER 1
typedef struct WIcon {
WCoreWindow *core;
WWindow *owner; /* owner window */
char *icon_name; /* the icon name hint */
Window icon_win; /* client suplied icon window */
char *file; /* the file with the icon image */
RImage *file_image; /* the image from the file */
unsigned int tile_type:4;
unsigned int show_title:1;
unsigned int selected:1;
unsigned int step:3; /* selection cycle step */
unsigned int shadowed:1; /* If the icon is to be blured */
unsigned int mapped:1;
unsigned int highlighted:1;
Pixmap pixmap;
Pixmap mini_preview;
WMHandlerID handlerID; /* timer handler ID for cycling select
* color */
} WIcon;
WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile);
WIcon *icon_create_for_wwindow(WWindow *wwin);
void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const char *wm_class, const char *command);
void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
void wIconUpdate(WIcon *icon);
void wIconSelect(WIcon *icon);
void wIconChangeTitle(WIcon *icon, WWindow *wwin);
void update_icon_pixmap(WIcon *icon);
int wIconChangeImageFile(WIcon *icon, const char *file);
RImage *wIconValidateIconSize(RImage *icon, int max_size);
RImage *get_rimage_icon_from_wm_hints(WIcon *icon);
char *wIconStore(WIcon *icon);
char *get_name_for_instance_class(const char *wm_instance, const char *wm_class);
void wIconSetHighlited(WIcon *icon, Bool flag);
void set_icon_image_from_image(WIcon *icon, RImage *image);
void set_icon_minipreview(WIcon *icon, RImage *image);
void remove_cache_icon(char *filename);
#endif /* WMICON_H_ */

View File

@@ -1,31 +0,0 @@
package(default_visibility = ["//visibility:public"])
cc_library(
name = "icon",
hdrs = ["icon.h"],
srcs = ["icon.c"],
deps = [
"//wmaker:application_tracking",
"//wmaker:appicon_files",
"//wmaker:atoms",
"//wmaker:find_image",
"//wmaker:get_generic_value",
"//wmaker:hacked_kb",
"//wmaker:base",
"//wmaker:wcore",
"@x11//:lib",
],
)
cc_library(
name = "appicon",
hdrs = ["appicon.h"],
srcs = ["appicon.c"],
deps = [
":icon",
"//wmaker:arrange_icons",
"//wmaker:base",
"//wmaker/menu",
"//wmaker/dnd:xdnd_init",
],
)

View File

@@ -1,56 +0,0 @@
/* appicon.h- application icon
*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef WMICON_APPICON_H_
#define WMICON_APPICON_H_
#include "wmaker/WindowMaker.h"
#include "wmaker/icon/icon.h"
#include "wrlib/wraster.h"
/* #include "window.h" */
/* #include "icon.h" */
/* #include "application.h" */
// The type definition for WAppIcon is in WindowMaker.h.
WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *wm_instance,
const char *wm_class, int tile,
struct WIconEventHandler *event_handler);
Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event);
void wAppIconDestroy(WAppIcon *aicon);
void wAppIconPaint(WAppIcon *aicon);
void wAppIconMove(WAppIcon *aicon, int x, int y);
void create_appicon_for_application(WApplication *wapp, WWindow *wwin);
void removeAppIconFor(WApplication * wapp);
void save_appicon(WAppIcon *aicon);
void paint_app_icon(WApplication *wapp);
void unpaint_app_icon(WApplication *wapp);
void wApplicationExtractDirPackIcon(const char *path, const char *wm_instance,
const char *wm_class);
WAppIcon *wAppIconFor(Window window);
void appIconMouseDown(WObjDescriptor * desc, XEvent * event);
#endif // WMICON_APPICON_H_

View File

@@ -1,63 +0,0 @@
#ifndef WMICON_BASE_H_
#define WMICON_BASE_H_
#include "wmaker/WindowMaker.h"
#define TILE_NORMAL 0
#define TILE_CLIP 1
#define TILE_DRAWER 2
/* This is the border, in pixel, drawn around a Mini-Preview */
#define MINIPREVIEW_BORDER 1
typedef void (WIconMiniwindowEventHandler_fn_t)(WObjDescriptor *desc, XEvent *event);
struct WIconEventHandler {
WIconMiniwindowEventHandler_fn_t *expose;
WIconMiniwindowEventHandler_fn_t *mouseDown;
WIconMiniwindowEventHandler_fn_t *dblClick;
};
WIcon *icon_create_for_wwindow(WWindow *wwin, struct WIconEventHandler *event_handler);
WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile, struct WIconEventHandler *event_handler);
Bool wGetIconName(Display *dpy, Window win, char **iconname);
int wIconGetSize(Drawable d, unsigned int *w, unsigned int *h, unsigned int *dep);
void wIconChangeTitle(WIcon *icon, WWindow *wwin);
void wIconSetHighlited(WIcon *icon, Bool flag);
void update_icon_pixmap(WIcon *icon);
void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const char *wm_class, const char *command);
void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
void wIconUpdate(WIcon *icon);
void wIconSelect(WIcon *icon);
void wIconChangeTitle(WIcon *icon, WWindow *wwin);
void update_icon_pixmap(WIcon *icon);
int wIconChangeImageFile(WIcon *icon, const char *file);
RImage *wIconValidateIconSize(RImage *icon, int max_size);
RImage *get_rimage_icon_from_wm_hints(WIcon *icon);
char *wIconStore(WIcon *icon);
void set_icon_image_from_image(WIcon *icon, RImage *image);
void unset_icon_image(WIcon *icon);
void remove_cache_icon(char *filename);
RImage *get_default_image(WScreen *scr);
RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size);
char *wDefaultGetIconFile(const char *instance, const char *class, Bool default_icon);
char *get_default_image_path(void);
char *get_icon_filename(const char *winstance, const char *wclass, const char *command,
Bool default_icon);
RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass, int max_size);
RImage *get_window_image_from_x11(Window window);
#endif // WMICON_BASE_H_

View File

@@ -1,108 +0,0 @@
static void miniwindowDblClick(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
assert(icon->owner != NULL);
wDeiconifyWindow(icon->owner);
}
static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
WWindow *wwin = icon->owner;
XEvent ev;
int x = wwin->icon_x, y = wwin->icon_y;
int dx = event->xbutton.x, dy = event->xbutton.y;
int grabbed = 0;
int clickButton = event->xbutton.button;
Bool hasMoved = False;
if (WCHECK_STATE(WSTATE_MODAL))
return;
if (IsDoubleClick(icon->core->screen_ptr, event)) {
miniwindowDblClick(desc, event);
return;
}
if (event->xbutton.button == Button1) {
if (event->xbutton.state & wPreferences.modifier_mask)
wLowerFrame(icon->core);
else
wRaiseFrame(icon->core);
if (event->xbutton.state & ShiftMask) {
wIconSelect(icon);
wSelectWindow(icon->owner, !wwin->flags.selected);
}
} else if (event->xbutton.button == Button3) {
WObjDescriptor *desc;
OpenMiniwindowMenu(wwin, event->xbutton.x_root, event->xbutton.y_root);
/* allow drag select of menu */
desc = &wwin->screen_ptr->window_menu->menu->descriptor;
event->xbutton.send_event = True;
(*desc->handle_mousedown) (desc, event);
return;
}
if (XGrabPointer(dpy, icon->core->window, False, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
}
while (1) {
WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask
| ButtonMotionMask | ExposureMask, &ev);
switch (ev.type) {
case Expose:
WMHandleEvent(&ev);
break;
case MotionNotify:
hasMoved = True;
if (!grabbed) {
if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD
|| abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) {
XChangeActivePointerGrab(dpy, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask,
wPreferences.cursor[WCUR_MOVE], CurrentTime);
grabbed = 1;
} else {
break;
}
}
x = ev.xmotion.x_root - dx;
y = ev.xmotion.y_root - dy;
XMoveWindow(dpy, icon->core->window, x, y);
break;
case ButtonPress:
break;
case ButtonRelease:
if (ev.xbutton.button != clickButton)
break;
if (wwin->icon_x != x || wwin->icon_y != y)
wwin->flags.icon_moved = 1;
XMoveWindow(dpy, icon->core->window, x, y);
wwin->icon_x = x;
wwin->icon_y = y;
XUngrabPointer(dpy, CurrentTime);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(wwin->screen_ptr, True);
if (wPreferences.single_click && !hasMoved)
miniwindowDblClick(desc, event);
return;
}
}
}

View File

@@ -1,662 +0,0 @@
/* icon.c - window icon and dock and appicon parent
*
* Window Maker window manager
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "wmaker/icon.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/actions.h"
#include "wmaker/appicon_files.h"
#include "wmaker/atoms.h"
#include "wmaker/destroy.h"
#include "wmaker/find_image.h"
#include "wmaker/get_generic_value.h"
#include "wmaker/hacked_kb.h"
#include "wmaker/icon.h"
#include "wmaker/icon_get_size.h"
#include "wmaker/is_double_click.h"
#include "wmaker/shrink_string.h"
#include "wmaker/stacking.h"
#include "wmaker/wconfig.h"
#include "wmaker/wcore.h"
#include "wmaker/wdefaults.h"
#include "wmaker/winmenu.h"
#include "wmaker/wmspec.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include "wrlib/wraster.h"
/**** Global varianebles ****/
#define MOD_MASK wPreferences.modifier_mask
#define CACHE_ICON_PATH "/" PACKAGE_TARNAME "/CachedPixmaps"
#define ICON_BORDER 3
static void miniwindowExpose(WObjDescriptor *desc, XEvent *event);
static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event);
static void set_dockapp_in_icon(WIcon *icon);
static void get_rimage_icon_from_icon_win(WIcon *icon);
static void get_rimage_icon_from_user_icon(WIcon *icon);
static void get_rimage_icon_from_default_icon(WIcon *icon);
static void get_rimage_icon_from_x11(WIcon *icon);
static void icon_update_pixmap(WIcon *icon, RImage *image);
RImage *wIconValidateIconSize(RImage *icon, int max_size)
{
RImage *nimage;
if (!icon)
return NULL;
/* We should hold "ICON_BORDER" (~2) pixels to include the icon border */
if (((max_size + ICON_BORDER) < icon->width) ||
((max_size + ICON_BORDER) < icon->height)) {
if (icon->width > icon->height)
nimage = RScaleImage(icon, max_size - ICON_BORDER,
(icon->height * (max_size - ICON_BORDER) / icon->width));
else
nimage = RScaleImage(icon, (icon->width * (max_size - ICON_BORDER) / icon->height),
max_size - ICON_BORDER);
RReleaseImage(icon);
icon = nimage;
}
return icon;
}
int wIconChangeImageFile(WIcon *icon, const char *file)
{
WScreen *scr = icon->core->screen_ptr;
char *path;
RImage *image = NULL;
/* If no new image, don't do nothing */
if (!file)
return 1;
/* Find the new image */
path = FindImage(wPreferences.icon_path, file);
if (!path)
return 0;
image = get_rimage_from_file(scr, path, wPreferences.icon_size);
if (!image) {
wfree(path);
return 0;
}
/* Set the new image */
set_icon_image_from_image(icon, image);
icon->file = wstrdup(path);
update_icon_pixmap(icon);
wfree(path);
return 1;
}
static char *get_name_for_wwin(WWindow *wwin)
{
return get_name_for_instance_class(wwin->wm_instance, wwin->wm_class);
}
static char *get_icon_cache_path(void)
{
const char *prefix;
char *path;
int ret;
prefix = wuserdatapath();
path = wstrconcat(prefix, CACHE_ICON_PATH "/");
/* If the folder exists, exit */
if (access(path, F_OK) == 0)
return path;
/* Create the folder */
ret = wmkdirhier(path);
/* Exit 1 on success, 0 on failure */
if (ret == 1)
return path;
/* Fail */
wfree(path);
return NULL;
}
static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
{
RImage *image = NULL;
XWMHints *hints = wwin->wm_hints;
if (hints && (hints->flags & IconPixmapHint) && hints->icon_pixmap != None)
image = RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
hints->icon_pixmap,
(hints->flags & IconMaskHint)
? hints->icon_mask : None);
return image;
}
/*
* wIconStore--
* Stores the client supplied icon at CACHE_ICON_PATH
* and returns the path for that icon. Returns NULL if there is no
* client supplied icon or on failure.
*
* Side effects:
* New directories might be created.
*/
char *wIconStore(WIcon *icon)
{
char *path, *dir_path, *file, *filename;
int len = 0;
RImage *image = NULL;
WWindow *wwin = icon->owner;
if (!wwin)
return NULL;
dir_path = get_icon_cache_path();
if (!dir_path)
return NULL;
file = get_name_for_wwin(wwin);
if (!file) {
wfree(dir_path);
return NULL;
}
/* Create the file name */
len = strlen(file) + 5;
filename = wmalloc(len);
snprintf(filename, len, "%s.xpm", file);
wfree(file);
/* Create the full path, including the filename */
len = strlen(dir_path) + strlen(filename) + 1;
path = wmalloc(len);
snprintf(path, len, "%s%s", dir_path, filename);
wfree(dir_path);
/* If icon exists, exit */
if (access(path, F_OK) == 0) {
wfree(path);
return filename;
}
if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
else
image = get_wwindow_image_from_wmhints(wwin, icon);
if (!image) {
wfree(path);
wfree(filename);
return NULL;
}
if (!RSaveImage(image, path, "XPM")) {
wfree(filename);
filename = NULL;
}
wfree(path);
RReleaseImage(image);
return filename;
}
void remove_cache_icon(char *filename)
{
char *cachepath;
if (!filename)
return;
cachepath = get_icon_cache_path();
if (!cachepath)
return;
/* Filename check/parse could be here */
if (!strncmp(filename, cachepath, strlen(cachepath)))
unlink(filename);
wfree(cachepath);
}
void set_icon_image_from_image(WIcon *icon, RImage *image)
{
if (!icon)
return;
unset_icon_image(icon);
icon->file_image = NULL;
icon->file_image = image;
}
void wIconUpdate(WIcon *icon)
{
WWindow *wwin = NULL;
if (icon && icon->owner)
wwin = icon->owner;
if (wwin && WFLAGP(wwin, always_user_icon)) {
/* Forced use user_icon */
get_rimage_icon_from_user_icon(icon);
} else if (icon->icon_win != None) {
/* Get the Pixmap from the WIcon */
get_rimage_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
/* Use _NET_WM_ICON icon */
get_rimage_icon_from_x11(icon);
} else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) {
/* Get the Pixmap from the wm_hints, else, from the user */
unset_icon_image(icon);
icon->file_image = get_rimage_icon_from_wm_hints(icon);
if (!icon->file_image)
get_rimage_icon_from_user_icon(icon);
} else {
/* Get the Pixmap from the user */
get_rimage_icon_from_user_icon(icon);
}
update_icon_pixmap(icon);
}
static void get_rimage_icon_from_x11(WIcon *icon)
{
/* Remove the icon image */
unset_icon_image(icon);
/* Set the new icon image */
icon->file_image = RRetainImage(icon->owner->net_icon_image);
}
static void get_rimage_icon_from_user_icon(WIcon *icon)
{
if (icon->file_image)
return;
get_rimage_icon_from_default_icon(icon);
}
static void get_rimage_icon_from_default_icon(WIcon *icon)
{
WScreen *scr = icon->core->screen_ptr;
/* If the icon don't have image, we should use the default image. */
if (!scr->def_icon_rimage)
scr->def_icon_rimage = get_default_image(scr);
/* Remove the icon image */
unset_icon_image(icon);
/* Set the new icon image */
icon->file_image = RRetainImage(scr->def_icon_rimage);
}
/* Get the RImage from the WIcon of the WWindow */
static void get_rimage_icon_from_icon_win(WIcon *icon)
{
RImage *image;
/* Create the new RImage */
image = get_window_image_from_x11(icon->icon_win);
/* Free the icon info */
unset_icon_image(icon);
/* Set the new info */
icon->file_image = image;
}
/* Set the dockapp in the WIcon */
static void set_dockapp_in_icon(WIcon *icon)
{
XWindowAttributes attr;
WScreen *scr = icon->core->screen_ptr;
unsigned int w, h, d;
/* Reparent the dock application to the icon */
/* We need the application size to center it
* and show in the correct position */
wIconGetSize(icon->icon_win, &w, &h, &d);
/* Set the background pixmap */
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
/* Set the icon border */
XSetWindowBorderWidth(dpy, icon->icon_win, 0);
/* Put the dock application in the icon */
XReparentWindow(dpy, icon->icon_win, icon->core->window,
(wPreferences.icon_size - w) / 2,
(wPreferences.icon_size - h) / 2);
/* Show it and save */
XMapWindow(dpy, icon->icon_win);
XAddToSaveSet(dpy, icon->icon_win);
/* Needed to move the icon clicking on the application part */
if ((XGetWindowAttributes(dpy, icon->icon_win, &attr)) &&
(attr.all_event_masks & ButtonPressMask))
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
ButtonPressMask, GrabModeSync, GrabModeAsync,
None, wPreferences.cursor[WCUR_ARROW]);
}
/* Get the RImage from the XWindow wm_hints */
RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
{
RImage *image = NULL;
unsigned int w, h, d;
WWindow *wwin;
if ((!icon) || (!icon->owner))
return NULL;
wwin = icon->owner;
if (!wIconGetSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) {
icon->owner->wm_hints->flags &= ~IconPixmapHint;
return NULL;
}
image = get_wwindow_image_from_wmhints(wwin, icon);
if (!image)
return NULL;
/* Resize the icon to the wPreferences.icon_size size */
image = wIconValidateIconSize(image, wPreferences.icon_size);
return image;
}
/******************************************************************/
static void miniwindowExpose(WObjDescriptor *desc, XEvent *event)
{
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
wIconPaint(desc->parent);
}
static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
WWindow *wwin = icon->owner;
XEvent ev;
int x = wwin->icon_x, y = wwin->icon_y;
int dx = event->xbutton.x, dy = event->xbutton.y;
int grabbed = 0;
int clickButton = event->xbutton.button;
Bool hasMoved = False;
if (WCHECK_STATE(WSTATE_MODAL))
return;
if (IsDoubleClick(icon->core->screen_ptr, event)) {
miniwindowDblClick(desc, event);
return;
}
if (event->xbutton.button == Button1) {
if (event->xbutton.state & MOD_MASK)
wLowerFrame(icon->core);
else
wRaiseFrame(icon->core);
if (event->xbutton.state & ShiftMask) {
wIconSelect(icon);
wSelectWindow(icon->owner, !wwin->flags.selected);
}
} else if (event->xbutton.button == Button3) {
WObjDescriptor *desc;
OpenMiniwindowMenu(wwin, event->xbutton.x_root, event->xbutton.y_root);
/* allow drag select of menu */
desc = &wwin->screen_ptr->window_menu->menu->descriptor;
event->xbutton.send_event = True;
(*desc->handle_mousedown) (desc, event);
return;
}
if (XGrabPointer(dpy, icon->core->window, False, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
}
while (1) {
WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask
| ButtonMotionMask | ExposureMask, &ev);
switch (ev.type) {
case Expose:
WMHandleEvent(&ev);
break;
case MotionNotify:
hasMoved = True;
if (!grabbed) {
if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD
|| abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) {
XChangeActivePointerGrab(dpy, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask,
wPreferences.cursor[WCUR_MOVE], CurrentTime);
grabbed = 1;
} else {
break;
}
}
x = ev.xmotion.x_root - dx;
y = ev.xmotion.y_root - dy;
XMoveWindow(dpy, icon->core->window, x, y);
break;
case ButtonPress:
break;
case ButtonRelease:
if (ev.xbutton.button != clickButton)
break;
if (wwin->icon_x != x || wwin->icon_y != y)
wwin->flags.icon_moved = 1;
XMoveWindow(dpy, icon->core->window, x, y);
wwin->icon_x = x;
wwin->icon_y = y;
XUngrabPointer(dpy, CurrentTime);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(wwin->screen_ptr, True);
if (wPreferences.single_click && !hasMoved)
miniwindowDblClick(desc, event);
return;
}
}
}
void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const char *wm_class, const char *command)
{
char *file = NULL;
file = get_icon_filename(wm_instance, wm_class, command, False);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(icon->core->screen_ptr, icon->file, wPreferences.icon_size);
wfree(file);
}
}
/* This function creates the RImage using the default icon */
RImage *get_default_image(WScreen *scr)
{
RImage *image = NULL;
char *path = NULL;
/* Get the filename full path */
path = get_default_image_path();
if (!path)
return NULL;
/* Get the default icon */
image = get_rimage_from_file(scr, path, wPreferences.icon_size);
if (!image)
wwarning(_("could not find default icon \"%s\""), path);
/* Resize the icon to the wPreferences.icon_size size
* usually this function will return early, because size is right */
image = wIconValidateIconSize(image, wPreferences.icon_size);
return image;
}
/* This function returns the image picture for the file_name file */
RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size)
{
RImage *image = NULL;
if (!file_name)
return NULL;
image = RLoadImage(scr->rcontext, file_name, 0);
if (!image)
wwarning(_("error loading image file \"%s\": %s"), file_name,
RMessageForError(RErrorCode));
image = wIconValidateIconSize(image, max_size);
return image;
}
/* Get the name of the Icon File. If default_icon is True, then, default value included */
char *wDefaultGetIconFile(const char *instance, const char *class, Bool default_icon)
{
WMPropList *value;
char *tmp;
WMPropList *field = get_attribute_prop_list(WA_AttributeField_Icon);
if (!field)
return NULL;
if (!w_global.domain.window_attr || !w_global.domain.window_attr->dictionary)
return NULL;
value = get_generic_value(instance, class, field, default_icon);
if (!value)
return NULL;
tmp = getString(field, value);
return tmp;
}
/* This function returns the default icon's full path
* If the path for an icon is not found, returns NULL */
char *get_default_image_path(void)
{
char *path = NULL, *file = NULL;
/* Get the default icon */
file = wDefaultGetIconFile(NULL, NULL, True);
if (file)
path = FindImage(wPreferences.icon_path, file);
return path;
}
/* Get the file name of the image, using instance and class */
char *get_icon_filename(const char *winstance, const char *wclass, const char *command,
Bool default_icon)
{
char *file_name;
char *file_path;
/* Get the file name of the image, using instance and class */
file_name = wDefaultGetIconFile(winstance, wclass, default_icon);
/* Check if the file really exists in the disk */
if (file_name)
file_path = FindImage(wPreferences.icon_path, file_name);
else
file_path = NULL;
/* If the specific icon filename is not found, and command is specified,
* then include the .app icons and re-do the search. */
if (!file_path && command) {
wApplicationExtractDirPackIcon(command, winstance, wclass);
file_name = wDefaultGetIconFile(winstance, wclass, False);
if (file_name) {
file_path = FindImage(wPreferences.icon_path, file_name);
if (!file_path)
wwarning(_("icon \"%s\" doesn't exist, check your config files"), file_name);
/* FIXME: Here, if file_path does not exist then the icon is still in the
* "icon database" (w_global.domain.window_attr->dictionary), but the file
* for the icon is no more on disk. Therefore, we should remove it from the
* database. Is possible to do that using wDefaultChangeIcon() */
}
}
/*
* Don't wfree(file_name) because it is a direct pointer inside the icon
* dictionary (w_global.domain.window_attr->dictionary) and not a result
* allocated with wstrdup()
*/
if (!file_path && default_icon)
file_path = get_default_image_path();
return file_path;
}
RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass, int max_size)
{
char *file_name = NULL;
/* Get the file name of the image, using instance and class */
file_name = get_icon_filename(winstance, wclass, NULL, True);
return get_rimage_from_file(scr, file_name, max_size);
}

View File

@@ -1,116 +0,0 @@
#include "wmaker/icon_action_handlers.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/is_double_click.h"
#include "wmaker/stacking.h"
static void miniwindowDblClick(WObjDescriptor *desc, XEvent *event);
void wMiniwindowMouseDown(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
WWindow *wwin = icon->owner;
XEvent ev;
int x = wwin->icon_x, y = wwin->icon_y;
int dx = event->xbutton.x, dy = event->xbutton.y;
int grabbed = 0;
int clickButton = event->xbutton.button;
Bool hasMoved = False;
if (WCHECK_STATE(WSTATE_MODAL))
return;
if (IsDoubleClick(icon->core->screen_ptr, event)) {
miniwindowDblClick(desc, event);
return;
}
if (event->xbutton.button == Button1) {
if (event->xbutton.state & wPreferences.modifier_mask)
wLowerFrame(icon->core);
else
wRaiseFrame(icon->core);
if (event->xbutton.state & ShiftMask) {
wIconSelect(icon);
wSelectWindow(icon->owner, !wwin->flags.selected);
}
} else if (event->xbutton.button == Button3) {
WObjDescriptor *desc;
OpenMiniwindowMenu(wwin, event->xbutton.x_root, event->xbutton.y_root);
/* allow drag select of menu */
desc = &wwin->screen_ptr->window_menu->menu->descriptor;
event->xbutton.send_event = True;
(*desc->handle_mousedown) (desc, event);
return;
}
if (XGrabPointer(dpy, icon->core->window, False, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
}
while (1) {
WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask
| ButtonMotionMask | ExposureMask, &ev);
switch (ev.type) {
case Expose:
WMHandleEvent(&ev);
break;
case MotionNotify:
hasMoved = True;
if (!grabbed) {
if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD
|| abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) {
XChangeActivePointerGrab(dpy, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask,
wPreferences.cursor[WCUR_MOVE], CurrentTime);
grabbed = 1;
} else {
break;
}
}
x = ev.xmotion.x_root - dx;
y = ev.xmotion.y_root - dy;
XMoveWindow(dpy, icon->core->window, x, y);
break;
case ButtonPress:
break;
case ButtonRelease:
if (ev.xbutton.button != clickButton)
break;
if (wwin->icon_x != x || wwin->icon_y != y)
wwin->flags.icon_moved = 1;
XMoveWindow(dpy, icon->core->window, x, y);
wwin->icon_x = x;
wwin->icon_y = y;
XUngrabPointer(dpy, CurrentTime);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(wwin->screen_ptr, True);
if (wPreferences.single_click && !hasMoved)
miniwindowDblClick(desc, event);
return;
}
}
}
static void miniwindowDblClick(WObjDescriptor *desc, XEvent *event)
{
WIcon *icon = desc->parent;
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
assert(icon->owner != NULL);
wDeiconifyWindow(icon->owner);
}

View File

@@ -1,10 +0,0 @@
#ifndef WMICON_ACTION_HANDLERS_H_
#define WMICON_ACTION_HANDLERS_H_
#include "wmaker/WindowMaker.h"
#include <X11/X.h>
void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event);
#endif // WMICON_ACTION_HANDLERS_H_

View File

@@ -1,46 +0,0 @@
#include "wmaker/icon_paint.h"
#include "wmaker/WindowMaker.h"
#include "wmaker/shrink_string.h"
#include <string.h>
#include <X11/Xlib.h>
/* This function updates in the screen the icon title */
static void update_icon_title(WIcon *icon)
{
WScreen *scr = icon->core->screen_ptr;
int x, l, w;
char *tmp;
/* draw the icon title */
if (icon->show_title && icon->icon_name != NULL) {
tmp = ShrinkString(scr->icon_title_font, icon->icon_name, wPreferences.icon_size - 4);
w = WMWidthOfString(scr->icon_title_font, tmp, l = strlen(tmp));
if (w > icon->core->width - 4)
x = (icon->core->width - 4) - w;
else
x = (icon->core->width - w) / 2;
WMDrawString(scr->wmscreen, icon->core->window, scr->icon_title_color,
scr->icon_title_font, x, 1, tmp, l);
wfree(tmp);
}
}
void wIconPaint(WIcon *icon)
{
if (!icon || !icon->core || !icon->core->screen_ptr)
return;
WScreen *scr = icon->core->screen_ptr;
XClearWindow(dpy, icon->core->window);
update_icon_title(icon);
if (icon->selected)
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
}

View File

@@ -1,8 +0,0 @@
#ifndef WICON_PAINT_H_
#define WICON_PAINT_H_
#include "wmaker/WindowMaker.h"
void wIconPaint(WIcon *icon);
#endif // WICON_PAINT_H_

View File

@@ -1,41 +0,0 @@
#include "wmaker/icon_select.h"
#include "wmaker/WindowMaker.h"
#include <X11/Xlib.h>
static void cycleColor(void *data)
{
WIcon *icon = (WIcon *) data;
WScreen *scr = icon->core->screen_ptr;
XGCValues gcv;
icon->step--;
gcv.dash_offset = icon->step;
XChangeGC(dpy, scr->icon_select_gc, GCDashOffset, &gcv);
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
icon->handlerID = WMAddTimerHandler(COLOR_CYCLE_DELAY, cycleColor, icon);
}
void wIconSelect(WIcon *icon)
{
WScreen *scr = icon->core->screen_ptr;
icon->selected = !icon->selected;
if (icon->selected) {
icon->step = 0;
if (!wPreferences.dont_blink)
icon->handlerID = WMAddTimerHandler(10, cycleColor, icon);
else
XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0,
icon->core->width - 1, icon->core->height - 1);
} else {
if (icon->handlerID) {
WMDeleteTimerHandler(icon->handlerID);
icon->handlerID = NULL;
}
XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, icon->core->height, True);
}
}

View File

@@ -1,8 +0,0 @@
#ifndef WICON_SELECT_H_
#define WICON_SELECT_H_
#include "wmaker/WindowMaker.h"
void wIconSelect(WIcon *icon);
#endif // WICON_SELECT_H_

View File

@@ -1,4 +0,0 @@
#include "wmaker/icon_set_highlighted.h"
#include "wmaker/WindowMaker.h"
#include "update_icon_pixmap.h"

Some files were not shown because too many files have changed in this diff Show More