forked from vitrine/wmaker
Compare commits
5 Commits
migrate-to
...
trial-rust
| Author | SHA1 | Date | |
|---|---|---|---|
| 8814830f89 | |||
| 3256959257 | |||
| 639a401f7f | |||
| 0aecec095f | |||
| 66e2ade2dc |
@@ -444,7 +444,7 @@ static Bool loadPixmaps(WMScreen * scr)
|
||||
if (!image)
|
||||
image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0);
|
||||
if (!image) {
|
||||
wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("WINGs: could not load widget images file: %s"), wraster_current_error_message());
|
||||
return False;
|
||||
}
|
||||
/* home icon */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
# http_archive(
|
||||
# name = "bazel_pkg_config",
|
||||
@@ -6,6 +6,26 @@
|
||||
# urls = ["https://github.com/cherrry/bazel_pkg_config/archive/master.zip"],
|
||||
# )
|
||||
|
||||
# To find additional information on this release or newer ones visit:
|
||||
# https://github.com/bazelbuild/rules_rust/releases
|
||||
http_archive(
|
||||
name = "rules_rust",
|
||||
integrity = "sha256-Weev1uz2QztBlDA88JX6A1N72SucD1V8lBsaliM0TTg=",
|
||||
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.48.0/rules_rust-v0.48.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
|
||||
|
||||
rules_rust_dependencies()
|
||||
rust_register_toolchains()
|
||||
|
||||
rust_register_toolchains(
|
||||
edition = "2021",
|
||||
versions = [
|
||||
"1.79.0"
|
||||
],
|
||||
)
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
|
||||
local_repository(
|
||||
name = "bazel_pkg_config",
|
||||
|
||||
@@ -1,88 +1,13 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
name = "appearance_settings",
|
||||
hdrs = ["appearance_settings.h"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "gnustep_compat",
|
||||
hdrs = ["GNUstep.h"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "notifications",
|
||||
hdrs = ["notifications.h"]
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "globals",
|
||||
hdrs = ["globals.h"],
|
||||
srcs = ["globals.c"],
|
||||
deps = ["@x11//:lib"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "keybind",
|
||||
hdrs = ["keybind.h"],
|
||||
srcs = ["keybind.c"],
|
||||
deps = ["@x11//:lib"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "cursor",
|
||||
hdrs = ["cursor.h"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "geometry",
|
||||
hdrs = ["geometry.h"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "preferences",
|
||||
hdrs = ["preferences.h"],
|
||||
srcs = ["preferences.c"],
|
||||
deps = [
|
||||
":cursor",
|
||||
":geometry",
|
||||
":wconfig",
|
||||
"//wrlib",
|
||||
"//WINGs",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "resources",
|
||||
hdrs = ["resources.h"],
|
||||
srcs = ["resources.c"],
|
||||
deps = [
|
||||
":globals",
|
||||
":wconfig",
|
||||
"//wmaker/screen:interface",
|
||||
"//wrlib",
|
||||
"//WINGs",
|
||||
"@x11//:lib",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
cc_library(
|
||||
name = "wconfig",
|
||||
hdrs = ["wconfig.h"],
|
||||
deps = ["//config"],
|
||||
)
|
||||
|
||||
# TODO: factor this apart into at least 1 library. (Shared functions defined in
|
||||
# main.c will have to go elsewhere.)
|
||||
cc_binary(
|
||||
name = "wmaker",
|
||||
copts = [
|
||||
"-DMAGICKCORE_HDRI_ENABLE=0",
|
||||
"-DMAGICKCORE_QUANTUM_DEPTH=16",
|
||||
"-DMAGICKCORE_CHANNEL_MASK_DEPTH=32",
|
||||
],
|
||||
srcs = [
|
||||
"WindowMaker.h",
|
||||
"actions.h",
|
||||
|
||||
@@ -88,6 +88,45 @@ typedef struct WObjDescriptor {
|
||||
void *parent; /* parent object (WWindow or WMenu) */
|
||||
} WObjDescriptor;
|
||||
|
||||
/* internal buttons */
|
||||
#define WBUT_CLOSE 0
|
||||
#define WBUT_BROKENCLOSE 1
|
||||
#define WBUT_ICONIFY 2
|
||||
#define WBUT_KILL 3
|
||||
#ifdef XKB_BUTTON_HINT
|
||||
#define WBUT_XKBGROUP1 4
|
||||
#define WBUT_XKBGROUP2 5
|
||||
#define WBUT_XKBGROUP3 6
|
||||
#define WBUT_XKBGROUP4 7
|
||||
#define PRED_BPIXMAPS 8 /* reserved for 4 groups */
|
||||
#else
|
||||
#define PRED_BPIXMAPS 4 /* count of WBUT icons */
|
||||
#endif /* XKB_BUTTON_HINT */
|
||||
|
||||
/* 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;
|
||||
|
||||
/* geometry displays */
|
||||
#define WDIS_NEW 0 /* new style */
|
||||
#define WDIS_CENTER 1 /* center of screen */
|
||||
@@ -240,6 +279,391 @@ typedef enum {
|
||||
#define WFLAGS_CRASHED (1<<0)
|
||||
|
||||
|
||||
/* notifications */
|
||||
|
||||
#ifdef MAINFILE
|
||||
#define NOTIFICATION(n) const char WN##n [] = #n
|
||||
#else
|
||||
#define NOTIFICATION(n) extern const char WN##n []
|
||||
#endif
|
||||
|
||||
NOTIFICATION(WindowAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(IconAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(IconTileSettingsChanged);
|
||||
|
||||
NOTIFICATION(MenuAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(MenuTitleAppearanceSettingsChanged);
|
||||
|
||||
|
||||
/* appearance settings clientdata flags */
|
||||
enum {
|
||||
WFontSettings = 1 << 0,
|
||||
WTextureSettings = 1 << 1,
|
||||
WColorSettings = 1 << 2
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
} WArea;
|
||||
|
||||
typedef struct WCoord {
|
||||
int x, y;
|
||||
} WCoord;
|
||||
|
||||
extern struct WPreferences {
|
||||
char *pixmap_path; /* : separated list of paths to find pixmaps */
|
||||
char *icon_path; /* : separated list of paths to find icons */
|
||||
WMArray *fallbackWMs; /* fallback window manager list */
|
||||
char *logger_shell; /* shell to log child stdi/o */
|
||||
RImage *button_images; /* titlebar button images */
|
||||
char smooth_workspace_back;
|
||||
signed char size_display; /* display type for resize geometry */
|
||||
signed char move_display; /* display type for move geometry */
|
||||
signed char window_placement; /* window placement mode */
|
||||
signed char colormap_mode; /* colormap focus mode */
|
||||
signed char focus_mode; /* window focusing mode */
|
||||
|
||||
char opaque_move; /* update window position during move */
|
||||
char opaque_resize; /* update window position during resize */
|
||||
char opaque_move_resize_keyboard; /* update window position during move,resize with keyboard */
|
||||
char wrap_menus; /* wrap menus at edge of screen */
|
||||
char scrollable_menus; /* let them be scrolled */
|
||||
char vi_key_menus; /* use h/j/k/l to select */
|
||||
char align_menus; /* align menu with their parents */
|
||||
char use_saveunders; /* turn on SaveUnders for menus, icons etc. */
|
||||
char no_window_over_dock;
|
||||
char no_window_over_icons;
|
||||
WCoord window_place_origin; /* Offset for windows placed on screen */
|
||||
|
||||
char constrain_window_size; /* don't let windows get bigger than screen */
|
||||
char windows_cycling; /* windoze cycling */
|
||||
char circ_raise; /* raise window after Alt-tabbing */
|
||||
char ignore_focus_click;
|
||||
char open_transients_with_parent; /* open transient window in same workspace as parent */
|
||||
signed char title_justification; /* titlebar text alignment */
|
||||
int window_title_clearance;
|
||||
int window_title_min_height;
|
||||
int window_title_max_height;
|
||||
int menu_title_clearance;
|
||||
int menu_title_min_height;
|
||||
int menu_title_max_height;
|
||||
int menu_text_clearance;
|
||||
char multi_byte_text;
|
||||
#ifdef KEEP_XKB_LOCK_STATUS
|
||||
char modelock;
|
||||
#endif
|
||||
char no_dithering; /* use dithering or not */
|
||||
char no_animations; /* enable/disable animations */
|
||||
char no_autowrap; /* wrap workspace when window is moved to the edge */
|
||||
char window_snapping; /* enable window snapping */
|
||||
int snap_edge_detect; /* how far from edge to begin snap */
|
||||
int snap_corner_detect; /* how far from corner to begin snap */
|
||||
char snap_to_top_maximizes_fullscreen;
|
||||
char drag_maximized_window; /* behavior when a maximized window is dragged */
|
||||
char move_half_max_between_heads; /* move half maximized window between available heads */
|
||||
char alt_half_maximize; /* alternative half-maximize feature behavior */
|
||||
char pointer_with_half_max_windows;
|
||||
|
||||
char highlight_active_app; /* show the focused app by highlighting its icon */
|
||||
char auto_arrange_icons; /* automagically arrange icons */
|
||||
char icon_box_position; /* position to place icons */
|
||||
signed char iconification_style; /* position to place icons */
|
||||
char disable_root_mouse; /* disable button events in root window */
|
||||
char auto_focus; /* focus window when it's mapped */
|
||||
char *icon_back_file; /* background image for icons */
|
||||
char enforce_icon_margin; /* auto-shrink icon images */
|
||||
|
||||
WCoord *root_menu_pos; /* initial position of the root menu*/
|
||||
WCoord *app_menu_pos;
|
||||
WCoord *win_menu_pos;
|
||||
|
||||
signed char icon_yard; /* aka iconbox */
|
||||
|
||||
int raise_delay; /* delay for autoraise. 0 is disabled */
|
||||
int cmap_size; /* size of dithering colormap in colors per channel */
|
||||
|
||||
int icon_size; /* size of the icon */
|
||||
signed char menu_style; /* menu decoration style */
|
||||
signed char workspace_name_display_position;
|
||||
unsigned int modifier_mask; /* mask to use as kbd modifier */
|
||||
char *modifier_labels[7]; /* Names of the modifiers */
|
||||
|
||||
unsigned int supports_tiff; /* Use tiff files */
|
||||
|
||||
char ws_advance; /* Create new workspace and advance */
|
||||
char ws_cycle; /* Cycle existing workspaces */
|
||||
char save_session_on_exit; /* automatically save session on exit */
|
||||
char sticky_icons; /* If miniwindows will be onmipresent */
|
||||
char dont_confirm_kill; /* do not confirm Kill application */
|
||||
char disable_miniwindows;
|
||||
char enable_workspace_pager;
|
||||
char ignore_gtk_decoration_hints;
|
||||
|
||||
char dont_blink; /* do not blink icon selection */
|
||||
char keep_dock_on_primary_head; /* keep dock on primary head */
|
||||
|
||||
/* Appearance options */
|
||||
char new_style; /* Use newstyle buttons */
|
||||
char superfluous; /* Use superfluous things */
|
||||
|
||||
/* root window mouse bindings */
|
||||
signed char mouse_button1; /* action for left mouse button */
|
||||
signed char mouse_button2; /* action for middle mouse button */
|
||||
signed char mouse_button3; /* action for right mouse button */
|
||||
signed char mouse_button8; /* action for 4th button aka backward mouse button */
|
||||
signed char mouse_button9; /* action for 5th button aka forward mouse button */
|
||||
signed char mouse_wheel_scroll; /* action for mouse wheel scroll */
|
||||
signed char mouse_wheel_tilt; /* action for mouse wheel tilt */
|
||||
|
||||
/* balloon text */
|
||||
char window_balloon;
|
||||
char miniwin_title_balloon;
|
||||
char miniwin_preview_balloon;
|
||||
char appicon_balloon;
|
||||
char help_balloon;
|
||||
|
||||
/* some constants */
|
||||
int dblclick_time; /* double click delay time in ms */
|
||||
|
||||
/* animate menus */
|
||||
signed char menu_scroll_speed; /* how fast menus are scrolled */
|
||||
|
||||
/* animate icon sliding */
|
||||
signed char icon_slide_speed; /* icon slide animation speed */
|
||||
|
||||
/* shading animation */
|
||||
signed char shade_speed;
|
||||
|
||||
/* bouncing animation */
|
||||
char bounce_appicons_when_urgent;
|
||||
char raise_appicons_when_bouncing;
|
||||
char do_not_make_appicons_bounce;
|
||||
|
||||
int edge_resistance;
|
||||
int resize_increment;
|
||||
char attract;
|
||||
|
||||
unsigned int workspace_border_size; /* Size in pixels of the workspace border */
|
||||
char workspace_border_position; /* Where to leave a workspace border */
|
||||
char single_click; /* single click to lauch applications */
|
||||
int history_lines; /* history of "Run..." dialog */
|
||||
char cycle_active_head_only; /* Cycle only windows on the active head */
|
||||
char cycle_ignore_minimized; /* Ignore minimized windows when cycling */
|
||||
char double_click_fullscreen; /* Double click on titlebar maximize a window to full screen*/
|
||||
char close_rootmenu_left_right_click;/* Close application menu when mouse (left or right) is clicked outside focus */
|
||||
char strict_windoze_cycle; /* don't close switch panel when shift is released */
|
||||
char panel_only_open; /* Only open the switch panel; don't switch */
|
||||
int minipreview_size; /* Size of Mini-Previews in pixels */
|
||||
|
||||
/* All delays here are in ms. 0 means instant auto-action. */
|
||||
int clip_auto_raise_delay; /* Delay after which the clip will be raised when entered */
|
||||
int clip_auto_lower_delay; /* Delay after which the clip will be lowered when leaved */
|
||||
int clip_auto_expand_delay; /* Delay after which the clip will expand when entered */
|
||||
int clip_auto_collapse_delay; /* Delay after which the clip will collapse when leaved */
|
||||
|
||||
RImage *swtileImage;
|
||||
RImage *swbackImage[9];
|
||||
|
||||
union WTexture *wsmbackTexture;
|
||||
|
||||
char show_clip_title;
|
||||
|
||||
char hot_corners; /* let corners execute actions */
|
||||
int hot_corner_delay; /* Delay after which the hot corner is triggered */
|
||||
int hot_corner_edge; /* Hot corner edge size */
|
||||
char *hot_corner_actions[4]; /* Action of each corner */
|
||||
|
||||
struct {
|
||||
#ifdef USE_ICCCM_WMREPLACE
|
||||
unsigned int replace:1; /* replace existing window manager */
|
||||
#endif
|
||||
unsigned int nodock:1; /* don't display the dock */
|
||||
unsigned int noclip:1; /* don't display the clip */
|
||||
unsigned int clip_merged_in_dock:1; /* disable clip, switch workspaces with dock */
|
||||
unsigned int nodrawer:1; /* don't use drawers */
|
||||
unsigned int wrap_appicons_in_dock:1; /* Whether to wrap appicons when Dock is moved up and down */
|
||||
unsigned int noupdates:1; /* don't require ~/GNUstep (-static) */
|
||||
unsigned int noautolaunch:1; /* don't autolaunch apps */
|
||||
unsigned int norestore:1; /* don't restore session */
|
||||
unsigned int restarting:2;
|
||||
} flags; /* internal flags */
|
||||
|
||||
/* Map table between w_cursor and actual X id */
|
||||
Cursor cursor[WCUR_LAST];
|
||||
|
||||
int switch_panel_icon_size; /* icon size in switch panel */
|
||||
|
||||
} wPreferences;
|
||||
|
||||
/****** Global Variables ******/
|
||||
extern Display *dpy;
|
||||
|
||||
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;
|
||||
|
||||
/****** Notifications ******/
|
||||
extern const char WMNManaged[];
|
||||
extern const char WMNUnmanaged[];
|
||||
extern const char WMNChangedWorkspace[];
|
||||
extern const char WMNChangedState[];
|
||||
extern const char WMNChangedFocus[];
|
||||
extern const char WMNChangedStacking[];
|
||||
extern const char WMNChangedName[];
|
||||
|
||||
extern const char WMNWorkspaceCreated[];
|
||||
extern const char WMNWorkspaceDestroyed[];
|
||||
extern const char WMNWorkspaceChanged[];
|
||||
extern const char WMNWorkspaceNameChanged[];
|
||||
|
||||
extern const char WMNResetStacking[];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#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_
|
||||
@@ -1,28 +0,0 @@
|
||||
#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_
|
||||
@@ -657,7 +657,7 @@ renderTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
|
||||
img = wTextureRenderImage(texture, width, height, WREL_FLAT);
|
||||
if (!img) {
|
||||
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("could not render texture: %s"), wraster_current_error_message());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ renderTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
if (limg) {
|
||||
RBevelImage(limg, RBEV_RAISED2);
|
||||
if (!RConvertImage(scr->rcontext, limg, lbutton))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
|
||||
x += limg->width;
|
||||
w -= limg->width;
|
||||
@@ -690,7 +690,7 @@ renderTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
if (timg) {
|
||||
RBevelImage(timg, RBEV_RAISED2);
|
||||
if (!RConvertImage(scr->rcontext, timg, languagebutton))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
|
||||
x += timg->width;
|
||||
w -= timg->width;
|
||||
@@ -706,7 +706,7 @@ renderTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
if (rimg) {
|
||||
RBevelImage(rimg, RBEV_RAISED2);
|
||||
if (!RConvertImage(scr->rcontext, rimg, rbutton))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
|
||||
w -= rimg->width;
|
||||
RReleaseImage(rimg);
|
||||
@@ -717,20 +717,20 @@ renderTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
RBevelImage(mimg, RBEV_RAISED2);
|
||||
|
||||
if (!RConvertImage(scr->rcontext, mimg, title))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
|
||||
RReleaseImage(mimg);
|
||||
} else {
|
||||
RBevelImage(img, RBEV_RAISED2);
|
||||
|
||||
if (!RConvertImage(scr->rcontext, img, title))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
}
|
||||
} else {
|
||||
RBevelImage(img, RBEV_RAISED2);
|
||||
|
||||
if (!RConvertImage(scr->rcontext, img, title))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
}
|
||||
|
||||
RReleaseImage(img);
|
||||
@@ -747,7 +747,7 @@ renderResizebarTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
|
||||
img = wTextureRenderImage(texture, width, height, WREL_FLAT);
|
||||
if (!img) {
|
||||
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("could not render texture: %s"), wraster_current_error_message());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ renderResizebarTexture(WScreen * scr, WTexture * texture, int width, int height,
|
||||
#endif /* SHADOW_RESIZEBAR */
|
||||
|
||||
if (!RConvertImage(scr->rcontext, img, pmap))
|
||||
wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image: %s"), wraster_current_error_message());
|
||||
|
||||
RReleaseImage(img);
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#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_
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "wmaker/globals.h"
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
|
||||
Display *dpy;
|
||||
struct wmaker_global_variables;
|
||||
@@ -1,166 +0,0 @@
|
||||
#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_
|
||||
@@ -308,7 +308,7 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
|
||||
}
|
||||
|
||||
if (!RConvertImage(scr->rcontext, tile, &pixmap))
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
|
||||
RReleaseImage(tile);
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "wmaker/keybind.h"
|
||||
|
||||
WShortKey wKeyBindings[WKBD_LAST];
|
||||
@@ -19,10 +19,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef WKEYBIND_H
|
||||
#define WKEYBIND_H
|
||||
|
||||
#include "X11/X.h"
|
||||
#ifndef WMKEYBIND_H
|
||||
#define WMKEYBIND_H
|
||||
|
||||
/* <X11/X.h> doesn't define these, even though XFree supports them */
|
||||
#ifndef Button6
|
||||
@@ -176,4 +174,8 @@ typedef struct WShortKey {
|
||||
|
||||
extern WShortKey wKeyBindings[WKBD_LAST];
|
||||
|
||||
#endif /* WKEYBIND_H */
|
||||
/* ---[ Functions ]------------------------------------------------------- */
|
||||
|
||||
void wKeyboardInitialize(void);
|
||||
|
||||
#endif /* WMKEYBIND_H */
|
||||
|
||||
@@ -60,12 +60,19 @@
|
||||
|
||||
#include "WINGs/WUtil.h"
|
||||
|
||||
/****** Global Variables ******/
|
||||
struct wmaker_global_variables w_global;
|
||||
|
||||
/* general info */
|
||||
|
||||
Display *dpy;
|
||||
|
||||
char *ProgName;
|
||||
|
||||
struct WPreferences wPreferences;
|
||||
|
||||
WShortKey wKeyBindings[WKBD_LAST];
|
||||
|
||||
/* notifications */
|
||||
const char WMNManaged[] = "WMNManaged";
|
||||
const char WMNUnmanaged[] = "WMNUnmanaged";
|
||||
|
||||
@@ -402,7 +402,7 @@ static Pixmap renderTexture(WMenu * menu)
|
||||
img = wTextureRenderImage(texture, menu->menu->width, menu->menu->height + 1, WREL_MENUENTRY);
|
||||
}
|
||||
if (!img) {
|
||||
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("could not render texture: %s"), wraster_current_error_message());
|
||||
|
||||
return None;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ static Pixmap renderTexture(WMenu * menu)
|
||||
}
|
||||
}
|
||||
if (!RConvertImage(scr->rcontext, img, &pix)) {
|
||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("error rendering image:%s"), wraster_current_error_message());
|
||||
}
|
||||
RReleaseImage(img);
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef WNOTIFICATIONS_H_
|
||||
#define WNOTIFICATIONS_H_
|
||||
|
||||
#ifdef MAINFILE
|
||||
#define NOTIFICATION(n) const char WN##n [] = #n
|
||||
#else
|
||||
#define NOTIFICATION(n) extern const char WN##n []
|
||||
#endif
|
||||
|
||||
NOTIFICATION(WindowAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(IconAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(IconTileSettingsChanged);
|
||||
|
||||
NOTIFICATION(MenuAppearanceSettingsChanged);
|
||||
|
||||
NOTIFICATION(MenuTitleAppearanceSettingsChanged);
|
||||
|
||||
extern const char WMNManaged[];
|
||||
extern const char WMNUnmanaged[];
|
||||
extern const char WMNChangedWorkspace[];
|
||||
extern const char WMNChangedState[];
|
||||
extern const char WMNChangedFocus[];
|
||||
extern const char WMNChangedStacking[];
|
||||
extern const char WMNChangedName[];
|
||||
|
||||
extern const char WMNWorkspaceCreated[];
|
||||
extern const char WMNWorkspaceDestroyed[];
|
||||
extern const char WMNWorkspaceChanged[];
|
||||
extern const char WMNWorkspaceNameChanged[];
|
||||
|
||||
extern const char WMNResetStacking[];
|
||||
|
||||
#endif // WNOTIFICATIONS_H_
|
||||
@@ -18,19 +18,17 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "wmaker/pixmap/pixmap.h"
|
||||
#include "wconfig.h"
|
||||
|
||||
#include "wmaker/globals.h"
|
||||
#include "wmaker/pixmap/interface.h"
|
||||
#include "wmaker/wconfig.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "wrlib/wraster.h"
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
#include "X11/Xutil.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "WindowMaker.h"
|
||||
#include "pixmap.h"
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -17,12 +17,22 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef WPIXMAP_PIXMAP_H_
|
||||
#define WPIXMAP_PIXMAP_H_
|
||||
#ifndef WMPIXMAP_H_
|
||||
#define WMPIXMAP_H_
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
typedef struct WPixmap {
|
||||
Pixmap image; /* icon image */
|
||||
Pixmap mask; /* icon mask */
|
||||
int width, height; /* size of pixmap */
|
||||
int depth; /* depth of pixmap */
|
||||
unsigned int shared:1; /* if pixmaps should be kept
|
||||
* when structure is freed */
|
||||
unsigned int client_owned:1;
|
||||
unsigned int client_owned_mask:1;
|
||||
} WPixmap;
|
||||
|
||||
#include "wmaker/pixmap/interface.h"
|
||||
#include "wmaker/screen/interface.h"
|
||||
#include "wrlib/wraster.h"
|
||||
|
||||
WPixmap *wPixmapCreate(Pixmap image, Pixmap mask);
|
||||
|
||||
@@ -33,4 +43,4 @@ WPixmap *wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask,
|
||||
unsigned long bg);
|
||||
void wPixmapDestroy(WPixmap *pix);
|
||||
|
||||
#endif // WPIXMAP_PIXMAP_H_
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
name = "interface",
|
||||
hdrs = ["interface.h"],
|
||||
deps = [
|
||||
"//wmaker/screen:interface",
|
||||
"//wrlib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "pixmap",
|
||||
hdrs = ["pixmap.h"],
|
||||
srcs = ["pixmap.c"],
|
||||
deps = [
|
||||
":interface",
|
||||
"//wmaker:globals",
|
||||
"//wmaker/screen:interface",
|
||||
"//wrlib",
|
||||
],
|
||||
)
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef WMPIXMAP_INTERFACE_H_
|
||||
#define WMPIXMAP_INTERFACE_H_
|
||||
|
||||
#include "wrlib/wraster.h"
|
||||
|
||||
typedef struct WPixmap {
|
||||
Pixmap image; /* icon image */
|
||||
Pixmap mask; /* icon mask */
|
||||
int width, height; /* size of pixmap */
|
||||
int depth; /* depth of pixmap */
|
||||
unsigned int shared:1; /* if pixmaps should be kept
|
||||
* when structure is freed */
|
||||
unsigned int client_owned:1;
|
||||
unsigned int client_owned_mask:1;
|
||||
} WPixmap;
|
||||
|
||||
|
||||
#endif // WMPIXMAP_INTERFACE_H_
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "wmaker/preferences.h"
|
||||
|
||||
struct WPreferences wPreferences;
|
||||
@@ -1,197 +0,0 @@
|
||||
#ifndef WPREFERENCES_H_
|
||||
#define WPREFERENCES_H_
|
||||
|
||||
#include "wmaker/wconfig.h"
|
||||
|
||||
#include "wmaker/cursor.h"
|
||||
#include "wmaker/geometry.h"
|
||||
|
||||
#include "wrlib/wraster.h"
|
||||
#include "WINGs/WUtil.h"
|
||||
|
||||
extern struct WPreferences {
|
||||
char *pixmap_path; /* : separated list of paths to find pixmaps */
|
||||
char *icon_path; /* : separated list of paths to find icons */
|
||||
WMArray *fallbackWMs; /* fallback window manager list */
|
||||
char *logger_shell; /* shell to log child stdi/o */
|
||||
RImage *button_images; /* titlebar button images */
|
||||
char smooth_workspace_back;
|
||||
signed char size_display; /* display type for resize geometry */
|
||||
signed char move_display; /* display type for move geometry */
|
||||
signed char window_placement; /* window placement mode */
|
||||
signed char colormap_mode; /* colormap focus mode */
|
||||
signed char focus_mode; /* window focusing mode */
|
||||
|
||||
char opaque_move; /* update window position during move */
|
||||
char opaque_resize; /* update window position during resize */
|
||||
char opaque_move_resize_keyboard; /* update window position during move,resize with keyboard */
|
||||
char wrap_menus; /* wrap menus at edge of screen */
|
||||
char scrollable_menus; /* let them be scrolled */
|
||||
char vi_key_menus; /* use h/j/k/l to select */
|
||||
char align_menus; /* align menu with their parents */
|
||||
char use_saveunders; /* turn on SaveUnders for menus, icons etc. */
|
||||
char no_window_over_dock;
|
||||
char no_window_over_icons;
|
||||
WCoord window_place_origin; /* Offset for windows placed on screen */
|
||||
|
||||
char constrain_window_size; /* don't let windows get bigger than screen */
|
||||
char windows_cycling; /* windoze cycling */
|
||||
char circ_raise; /* raise window after Alt-tabbing */
|
||||
char ignore_focus_click;
|
||||
char open_transients_with_parent; /* open transient window in same workspace as parent */
|
||||
signed char title_justification; /* titlebar text alignment */
|
||||
int window_title_clearance;
|
||||
int window_title_min_height;
|
||||
int window_title_max_height;
|
||||
int menu_title_clearance;
|
||||
int menu_title_min_height;
|
||||
int menu_title_max_height;
|
||||
int menu_text_clearance;
|
||||
char multi_byte_text;
|
||||
#ifdef KEEP_XKB_LOCK_STATUS
|
||||
char modelock;
|
||||
#endif
|
||||
char no_dithering; /* use dithering or not */
|
||||
char no_animations; /* enable/disable animations */
|
||||
char no_autowrap; /* wrap workspace when window is moved to the edge */
|
||||
char window_snapping; /* enable window snapping */
|
||||
int snap_edge_detect; /* how far from edge to begin snap */
|
||||
int snap_corner_detect; /* how far from corner to begin snap */
|
||||
char snap_to_top_maximizes_fullscreen;
|
||||
char drag_maximized_window; /* behavior when a maximized window is dragged */
|
||||
char move_half_max_between_heads; /* move half maximized window between available heads */
|
||||
char alt_half_maximize; /* alternative half-maximize feature behavior */
|
||||
char pointer_with_half_max_windows;
|
||||
|
||||
char highlight_active_app; /* show the focused app by highlighting its icon */
|
||||
char auto_arrange_icons; /* automagically arrange icons */
|
||||
char icon_box_position; /* position to place icons */
|
||||
signed char iconification_style; /* position to place icons */
|
||||
char disable_root_mouse; /* disable button events in root window */
|
||||
char auto_focus; /* focus window when it's mapped */
|
||||
char *icon_back_file; /* background image for icons */
|
||||
char enforce_icon_margin; /* auto-shrink icon images */
|
||||
|
||||
WCoord *root_menu_pos; /* initial position of the root menu*/
|
||||
WCoord *app_menu_pos;
|
||||
WCoord *win_menu_pos;
|
||||
|
||||
signed char icon_yard; /* aka iconbox */
|
||||
|
||||
int raise_delay; /* delay for autoraise. 0 is disabled */
|
||||
int cmap_size; /* size of dithering colormap in colors per channel */
|
||||
|
||||
int icon_size; /* size of the icon */
|
||||
signed char menu_style; /* menu decoration style */
|
||||
signed char workspace_name_display_position;
|
||||
unsigned int modifier_mask; /* mask to use as kbd modifier */
|
||||
char *modifier_labels[7]; /* Names of the modifiers */
|
||||
|
||||
unsigned int supports_tiff; /* Use tiff files */
|
||||
|
||||
char ws_advance; /* Create new workspace and advance */
|
||||
char ws_cycle; /* Cycle existing workspaces */
|
||||
char save_session_on_exit; /* automatically save session on exit */
|
||||
char sticky_icons; /* If miniwindows will be onmipresent */
|
||||
char dont_confirm_kill; /* do not confirm Kill application */
|
||||
char disable_miniwindows;
|
||||
char enable_workspace_pager;
|
||||
char ignore_gtk_decoration_hints;
|
||||
|
||||
char dont_blink; /* do not blink icon selection */
|
||||
char keep_dock_on_primary_head; /* keep dock on primary head */
|
||||
|
||||
/* Appearance options */
|
||||
char new_style; /* Use newstyle buttons */
|
||||
char superfluous; /* Use superfluous things */
|
||||
|
||||
/* root window mouse bindings */
|
||||
signed char mouse_button1; /* action for left mouse button */
|
||||
signed char mouse_button2; /* action for middle mouse button */
|
||||
signed char mouse_button3; /* action for right mouse button */
|
||||
signed char mouse_button8; /* action for 4th button aka backward mouse button */
|
||||
signed char mouse_button9; /* action for 5th button aka forward mouse button */
|
||||
signed char mouse_wheel_scroll; /* action for mouse wheel scroll */
|
||||
signed char mouse_wheel_tilt; /* action for mouse wheel tilt */
|
||||
|
||||
/* balloon text */
|
||||
char window_balloon;
|
||||
char miniwin_title_balloon;
|
||||
char miniwin_preview_balloon;
|
||||
char appicon_balloon;
|
||||
char help_balloon;
|
||||
|
||||
/* some constants */
|
||||
int dblclick_time; /* double click delay time in ms */
|
||||
|
||||
/* animate menus */
|
||||
signed char menu_scroll_speed; /* how fast menus are scrolled */
|
||||
|
||||
/* animate icon sliding */
|
||||
signed char icon_slide_speed; /* icon slide animation speed */
|
||||
|
||||
/* shading animation */
|
||||
signed char shade_speed;
|
||||
|
||||
/* bouncing animation */
|
||||
char bounce_appicons_when_urgent;
|
||||
char raise_appicons_when_bouncing;
|
||||
char do_not_make_appicons_bounce;
|
||||
|
||||
int edge_resistance;
|
||||
int resize_increment;
|
||||
char attract;
|
||||
|
||||
unsigned int workspace_border_size; /* Size in pixels of the workspace border */
|
||||
char workspace_border_position; /* Where to leave a workspace border */
|
||||
char single_click; /* single click to lauch applications */
|
||||
int history_lines; /* history of "Run..." dialog */
|
||||
char cycle_active_head_only; /* Cycle only windows on the active head */
|
||||
char cycle_ignore_minimized; /* Ignore minimized windows when cycling */
|
||||
char double_click_fullscreen; /* Double click on titlebar maximize a window to full screen*/
|
||||
char close_rootmenu_left_right_click;/* Close application menu when mouse (left or right) is clicked outside focus */
|
||||
char strict_windoze_cycle; /* don't close switch panel when shift is released */
|
||||
char panel_only_open; /* Only open the switch panel; don't switch */
|
||||
int minipreview_size; /* Size of Mini-Previews in pixels */
|
||||
|
||||
/* All delays here are in ms. 0 means instant auto-action. */
|
||||
int clip_auto_raise_delay; /* Delay after which the clip will be raised when entered */
|
||||
int clip_auto_lower_delay; /* Delay after which the clip will be lowered when leaved */
|
||||
int clip_auto_expand_delay; /* Delay after which the clip will expand when entered */
|
||||
int clip_auto_collapse_delay; /* Delay after which the clip will collapse when leaved */
|
||||
|
||||
RImage *swtileImage;
|
||||
RImage *swbackImage[9];
|
||||
|
||||
union WTexture *wsmbackTexture;
|
||||
|
||||
char show_clip_title;
|
||||
|
||||
char hot_corners; /* let corners execute actions */
|
||||
int hot_corner_delay; /* Delay after which the hot corner is triggered */
|
||||
int hot_corner_edge; /* Hot corner edge size */
|
||||
char *hot_corner_actions[4]; /* Action of each corner */
|
||||
|
||||
struct {
|
||||
#ifdef USE_ICCCM_WMREPLACE
|
||||
unsigned int replace:1; /* replace existing window manager */
|
||||
#endif
|
||||
unsigned int nodock:1; /* don't display the dock */
|
||||
unsigned int noclip:1; /* don't display the clip */
|
||||
unsigned int clip_merged_in_dock:1; /* disable clip, switch workspaces with dock */
|
||||
unsigned int nodrawer:1; /* don't use drawers */
|
||||
unsigned int wrap_appicons_in_dock:1; /* Whether to wrap appicons when Dock is moved up and down */
|
||||
unsigned int noupdates:1; /* don't require ~/GNUstep (-static) */
|
||||
unsigned int noautolaunch:1; /* don't autolaunch apps */
|
||||
unsigned int norestore:1; /* don't restore session */
|
||||
unsigned int restarting:2;
|
||||
} flags; /* internal flags */
|
||||
|
||||
/* Map table between w_cursor and actual X id */
|
||||
Cursor cursor[WCUR_LAST];
|
||||
|
||||
int switch_panel_icon_size; /* icon size in switch panel */
|
||||
|
||||
} wPreferences;
|
||||
|
||||
#endif // WPREFERENCES_H_
|
||||
@@ -19,19 +19,21 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "wconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wmaker/wconfig.h"
|
||||
#include "wmaker/globals.h"
|
||||
#include "wmaker/screen/interface.h"
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
#include "X11/Xutil.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "wrlib/wraster.h"
|
||||
#include "WINGs/WUtil.h"
|
||||
|
||||
#include "WindowMaker.h"
|
||||
#include "texture.h"
|
||||
#include "resources.h"
|
||||
#include "screen.h"
|
||||
|
||||
int wGetColorForColormap(Colormap colormap, const char *color_name, XColor *color)
|
||||
{
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef WRESOURCES_H_
|
||||
#define WRESOURCES_H_
|
||||
#ifndef WMRESOURCES_H_
|
||||
#define WMRESOURCES_H_
|
||||
|
||||
int wGetColorForColormap(Colormap colormap, const char *color_name, XColor *color);
|
||||
int wGetColor(WScreen *scr, const char *color_name, XColor *color);
|
||||
void wFreeColor(WScreen *scr, unsigned long pixel);
|
||||
|
||||
#endif // WRESOURCES_H_
|
||||
#endif
|
||||
|
||||
@@ -526,7 +526,7 @@ void create_logo_image(WScreen *scr)
|
||||
RImage *image = get_icon_image(scr, "Logo", "WMPanel", 128);
|
||||
|
||||
if (!image) {
|
||||
wwarning(_("could not load logo image for panels: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("could not load logo image for panels: %s"), wraster_current_error_message());
|
||||
} else {
|
||||
WMSetApplicationIconImage(scr->wmscreen, image);
|
||||
RReleaseImage(image);
|
||||
@@ -702,8 +702,8 @@ WScreen *wScreenInit(int screen_number)
|
||||
|
||||
scr->rcontext = RCreateContext(dpy, screen_number, &rattr);
|
||||
|
||||
if (!scr->rcontext && RErrorCode == RERR_STDCMAPFAIL) {
|
||||
wwarning("%s", RMessageForError(RErrorCode));
|
||||
if (!scr->rcontext && wraster_current_error_code() == RERR_STDCMAPFAIL) {
|
||||
wwarning("%s", wraster_current_error_message());
|
||||
|
||||
rattr.flags &= ~RC_StandardColormap;
|
||||
rattr.standard_colormap_mode = RUseStdColormap;
|
||||
@@ -712,7 +712,7 @@ WScreen *wScreenInit(int screen_number)
|
||||
}
|
||||
if (scr->rcontext == NULL) {
|
||||
wfatal(_("can't create Context on screen %d, %s"),
|
||||
screen_number, RMessageForError(RErrorCode));
|
||||
screen_number, wraster_current_error_message());
|
||||
goto abort_no_context;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
name = "interface",
|
||||
hdrs = ["interface.h"],
|
||||
deps = [
|
||||
"//wmaker:geometry",
|
||||
"//wmaker:wconfig",
|
||||
"//WINGs",
|
||||
],
|
||||
)
|
||||
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* 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 WMSCREEN_INTERFACE_H_
|
||||
#define WMSCREEN_INTERFACE_H_
|
||||
|
||||
#include "wmaker/wconfig.h"
|
||||
#include "wmaker/geometry.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "X11/Xatom.h"
|
||||
|
||||
#include "WINGs/WINGs.h"
|
||||
#include "WINGs/WUtil.h"
|
||||
|
||||
|
||||
#define PRINT_SCREEN 1
|
||||
#define PRINT_WINDOW 2
|
||||
#define PRINT_PARTIAL 3
|
||||
|
||||
/* internal buttons */
|
||||
#define WBUT_CLOSE 0
|
||||
#define WBUT_BROKENCLOSE 1
|
||||
#define WBUT_ICONIFY 2
|
||||
#define WBUT_KILL 3
|
||||
#ifdef XKB_BUTTON_HINT
|
||||
#define WBUT_XKBGROUP1 4
|
||||
#define WBUT_XKBGROUP2 5
|
||||
#define WBUT_XKBGROUP3 6
|
||||
#define WBUT_XKBGROUP4 7
|
||||
#define PRED_BPIXMAPS 8 /* reserved for 4 groups */
|
||||
#else
|
||||
#define PRED_BPIXMAPS 4 /* count of WBUT icons */
|
||||
#endif /* XKB_BUTTON_HINT */
|
||||
|
||||
typedef struct {
|
||||
WMRect *screens;
|
||||
int count; /* screen count, 0 = inactive */
|
||||
int primary_head; /* main working screen */
|
||||
} WXineramaInfo;
|
||||
|
||||
|
||||
/* an area of the screen reserved by some window */
|
||||
typedef struct WReservedArea {
|
||||
WArea area;
|
||||
Window window;
|
||||
struct WReservedArea *next;
|
||||
} WReservedArea;
|
||||
|
||||
|
||||
typedef struct WAppIconChain {
|
||||
struct WAppIcon *aicon;
|
||||
struct WAppIconChain *next;
|
||||
} WAppIconChain;
|
||||
|
||||
|
||||
/* Drawers, which are docks, really */
|
||||
typedef struct WDrawerChain {
|
||||
struct WDock *adrawer;
|
||||
struct WDrawerChain *next;
|
||||
} WDrawerChain;
|
||||
|
||||
|
||||
/*
|
||||
* each WScreen is saved into a context associated with its root window
|
||||
*/
|
||||
typedef struct _WScreen {
|
||||
int screen; /* screen number */
|
||||
Window info_window; /* for our window manager info stuff */
|
||||
#ifdef USE_ICCCM_WMREPLACE
|
||||
Atom sn_atom; /* window manager selection */
|
||||
#endif
|
||||
|
||||
int scr_width; /* size of the screen */
|
||||
int scr_height;
|
||||
|
||||
Window root_win; /* root window of screen */
|
||||
int depth; /* depth of the default visual */
|
||||
Colormap colormap; /* root colormap */
|
||||
int root_colormap_install_count;
|
||||
struct WWindow *original_cmap_window; /* colormap before installing
|
||||
* root colormap temporarily */
|
||||
struct WWindow *cmap_window;
|
||||
Colormap current_colormap;
|
||||
|
||||
Window w_win; /* window to use as drawable
|
||||
* for new GCs, pixmaps etc. */
|
||||
Visual *w_visual;
|
||||
int w_depth;
|
||||
Colormap w_colormap; /* our colormap */
|
||||
|
||||
WXineramaInfo xine_info;
|
||||
|
||||
Window no_focus_win; /* window to get focus when nobody
|
||||
* else can do it */
|
||||
|
||||
struct WWindow *focused_window; /* window that has the focus
|
||||
* Use this list if you want to
|
||||
* traverse the entire window list
|
||||
*/
|
||||
struct WWindow *bfs_focused_window; /* window that had focus before
|
||||
* another window entered fullscreen
|
||||
*/
|
||||
|
||||
WMArray *selected_windows;
|
||||
|
||||
WMArray *fakeGroupLeaders; /* list of fake window group ids */
|
||||
|
||||
struct WAppIcon *app_icon_list; /* list of all app-icons on screen */
|
||||
|
||||
struct WApplication *wapp_list; /* list of all aplications */
|
||||
|
||||
WMBag *stacking_list; /* bag of lists of windows
|
||||
* in stacking order.
|
||||
* Indexed by window level
|
||||
* and each list on the array
|
||||
* is ordered from the topmost to
|
||||
* the lowest window
|
||||
*/
|
||||
|
||||
int window_count; /* number of windows in window_list */
|
||||
|
||||
int workspace_count; /* number of workspaces */
|
||||
|
||||
struct WWorkspace **workspaces; /* workspace array */
|
||||
|
||||
int current_workspace; /* current workspace number */
|
||||
int last_workspace; /* last used workspace number */
|
||||
|
||||
|
||||
WReservedArea *reservedAreas; /* used to build totalUsableArea */
|
||||
|
||||
WArea *usableArea; /* area of the workspace where
|
||||
* we can put windows on, as defined
|
||||
* by other clients (not us) */
|
||||
WArea *totalUsableArea; /* same as above, but including
|
||||
* the dock and other stuff */
|
||||
|
||||
WMColor *black;
|
||||
WMColor *white;
|
||||
WMColor *gray;
|
||||
WMColor *darkGray;
|
||||
|
||||
/* shortcuts for the pixels of the above colors. just for convenience */
|
||||
WMPixel black_pixel;
|
||||
WMPixel white_pixel;
|
||||
WMPixel light_pixel;
|
||||
WMPixel dark_pixel;
|
||||
|
||||
Pixmap stipple_bitmap;
|
||||
Pixmap transp_stipple; /* for making holes in icon masks for
|
||||
* transparent icon simulation */
|
||||
WMFont *title_font; /* default font for the titlebars */
|
||||
WMFont *menu_title_font; /* font for menu titlebars */
|
||||
WMFont *menu_entry_font; /* font for menu items */
|
||||
WMFont *icon_title_font; /* for icon titles */
|
||||
WMFont *clip_title_font; /* for clip titles */
|
||||
WMFont *info_text_font; /* text on things like geometry
|
||||
* hint boxes */
|
||||
|
||||
XFontStruct *tech_draw_font; /* font for tech draw style geom view
|
||||
needs to be a core font so we can
|
||||
use it with a XORing GC */
|
||||
|
||||
WMFont *workspace_name_font;
|
||||
|
||||
WMColor *select_color;
|
||||
WMColor *select_text_color;
|
||||
/* foreground colors */
|
||||
WMColor *window_title_color[3]; /* window titlebar text (foc, unfoc, pfoc)*/
|
||||
WMColor *menu_title_color[3]; /* menu titlebar text */
|
||||
WMColor *clip_title_color[2]; /* clip title text */
|
||||
WMColor *mtext_color; /* menu item text */
|
||||
WMColor *dtext_color; /* disabled menu item text */
|
||||
|
||||
int frame_border_width;
|
||||
WMColor *frame_border_color;
|
||||
WMColor *frame_focused_border_color;
|
||||
WMColor *frame_selected_border_color;
|
||||
|
||||
WMPixel line_pixel;
|
||||
WMPixel frame_border_pixel; /* frame border */
|
||||
WMPixel frame_focused_border_pixel; /* frame border */
|
||||
WMPixel frame_selected_border_pixel;/* frame border */
|
||||
|
||||
|
||||
union WTexture *menu_title_texture[3];/* menu titlebar texture (tex, -, -) */
|
||||
union WTexture *window_title_texture[3]; /* win textures (foc, unfoc, pfoc) */
|
||||
union WTexture *resizebar_texture[3];/* window resizebar texture (tex, -, -) */
|
||||
|
||||
union WTexture *menu_item_texture; /* menu item texture */
|
||||
|
||||
struct WTexSolid *menu_item_auxtexture; /* additional texture to draw menu
|
||||
* cascade arrows */
|
||||
struct WTexSolid *icon_title_texture;/* icon titles */
|
||||
|
||||
struct WTexSolid *widget_texture;
|
||||
|
||||
struct WTexSolid *icon_back_texture; /* icon back color for shadowing */
|
||||
|
||||
|
||||
WMColor *icon_title_color; /* icon title color */
|
||||
|
||||
GC icon_select_gc;
|
||||
|
||||
GC frame_gc; /* gc for resize/move frame (root) */
|
||||
GC line_gc; /* gc for drawing XORed lines (root) */
|
||||
GC copy_gc; /* gc for XCopyArea() */
|
||||
GC stipple_gc; /* gc for stippled filling */
|
||||
GC draw_gc; /* gc for drawing misc things */
|
||||
GC mono_gc; /* gc for 1 bit drawables */
|
||||
|
||||
struct WPixmap *b_pixmaps[PRED_BPIXMAPS]; /* internal pixmaps for buttons*/
|
||||
struct WPixmap *menu_radio_indicator;/* left menu indicator */
|
||||
struct WPixmap *menu_check_indicator;/* left menu indicator for checkmark */
|
||||
struct WPixmap *menu_mini_indicator; /* for miniwindow */
|
||||
struct WPixmap *menu_hide_indicator; /* for hidden window */
|
||||
struct WPixmap *menu_shade_indicator; /* for shaded window */
|
||||
struct WPixmap *menu_snap_vertical_indicator; /* for vertical snap window */
|
||||
struct WPixmap *menu_snap_horizontal_indicator; /* for horizontal snap window */
|
||||
struct WPixmap *menu_snap_rh_indicator; /* for righ half snap window */
|
||||
struct WPixmap *menu_snap_lh_indicator; /* for left half snap window */
|
||||
struct WPixmap *menu_snap_th_indicator; /* for top half snap window */
|
||||
struct WPixmap *menu_snap_bh_indicator; /* for bottom half snap window */
|
||||
struct WPixmap *menu_snap_tl_indicator; /* for top left snap window */
|
||||
struct WPixmap *menu_snap_tr_indicator; /* for top rigt snap window */
|
||||
struct WPixmap *menu_snap_bl_indicator; /* for bottom left snap window */
|
||||
struct WPixmap *menu_snap_br_indicator; /* for bottom right snap window */
|
||||
struct WPixmap *menu_snap_tiled_indicator; /* for tiled window */
|
||||
struct WPixmap *menu_central_indicator; /* for central window */
|
||||
|
||||
int app_menu_x, app_menu_y; /* position for application menus */
|
||||
|
||||
struct WMenu *root_menu; /* root window menu */
|
||||
struct WMenu *switch_menu; /* window list menu */
|
||||
struct WMenu *workspace_menu; /* workspace operation */
|
||||
struct WMenu *window_menu; /* window command menu */
|
||||
struct WMenu *icon_menu; /* icon/appicon menu */
|
||||
struct WMenu *workspace_submenu; /* workspace list for window_menu */
|
||||
|
||||
struct WDock *dock; /* the application dock */
|
||||
struct WMenu *dock_pos_menu; /* Dock position menu */
|
||||
struct WPixmap *dock_dots; /* 3 dots for the Dock */
|
||||
Window dock_shadow; /* shadow for dock buttons */
|
||||
struct WAppIcon *clip_icon; /* The clip main icon, or the dock's, if they are merged */
|
||||
struct WMenu *clip_menu; /* Menu for clips */
|
||||
struct WMenu *clip_submenu; /* Workspace list for clips */
|
||||
struct WMenu *clip_options; /* Options for Clip */
|
||||
struct WMenu *clip_ws_menu; /* workspace menu for clip */
|
||||
struct WMenu *drawer_menu; /* Menu for drawers */
|
||||
struct WDock *last_dock;
|
||||
WAppIconChain *global_icons; /* for omnipresent icons chain in clip */
|
||||
int global_icon_count; /* How many global icons do we have */
|
||||
WDrawerChain *drawers; /* Chain of drawers */
|
||||
/* Cache the following two informations, as they are used quite a lot */
|
||||
int drawer_count; /* Nb of drawers that */
|
||||
struct WDock *attracting_drawer; /* The drawer that auto-attracts icons, or NULL */
|
||||
|
||||
struct RContext *rcontext; /* wrlib context */
|
||||
|
||||
WMScreen *wmscreen; /* for widget library */
|
||||
|
||||
struct RImage *icon_tile;
|
||||
struct RImage *clip_tile; /* tile with arrows to change workspace */
|
||||
struct RImage *drawer_tile; /* tile for a drawer (tile + arrow) */
|
||||
Pixmap icon_tile_pixmap; /* For app supplied icons */
|
||||
|
||||
struct RImage *def_icon_rimage; /* Default RImage icon */
|
||||
|
||||
struct WDialogData *dialog_data;
|
||||
|
||||
struct W_GeometryView *gview; /* size/position view */
|
||||
|
||||
/* state and other informations */
|
||||
short cascade_index; /* for cascade window placement */
|
||||
|
||||
WMPropList *session_state;
|
||||
|
||||
/* for double-click detection */
|
||||
Time last_click_time;
|
||||
Window last_click_window;
|
||||
int last_click_button;
|
||||
|
||||
/* balloon help data */
|
||||
struct _WBalloon *balloon;
|
||||
|
||||
/* workspace name data */
|
||||
Window workspace_name;
|
||||
WMHandlerID *workspace_name_timer;
|
||||
struct WorkspaceNameData *workspace_name_data;
|
||||
|
||||
/* mini screenshot data */
|
||||
Window mini_screenshot;
|
||||
time_t mini_screenshot_timeout;
|
||||
WMHandlerID *mini_screenshot_timer;
|
||||
|
||||
/* for raise-delay */
|
||||
WMHandlerID *autoRaiseTimer;
|
||||
Window autoRaiseWindow; /* window that is scheduled to be
|
||||
* raised */
|
||||
/* for hot-corners delay */
|
||||
WMHandlerID *hot_corner_timer;
|
||||
|
||||
/* for window shortcuts */
|
||||
WMArray *shortcutWindows[MAX_WINDOW_SHORTCUTS];
|
||||
|
||||
#ifdef USE_DOCK_XDND
|
||||
char *xdestring;
|
||||
#endif
|
||||
|
||||
struct NetData *netdata;
|
||||
|
||||
int helper_fd;
|
||||
pid_t helper_pid;
|
||||
|
||||
struct {
|
||||
unsigned int startup:1; /* during window manager startup */
|
||||
unsigned int regenerate_icon_textures:1;
|
||||
unsigned int dnd_data_convertion_status:1;
|
||||
unsigned int root_menu_changed_shortcuts:1;
|
||||
unsigned int added_workspace_menu:1;
|
||||
unsigned int added_windows_menu:1;
|
||||
unsigned int startup2:1; /* startup phase 2 */
|
||||
unsigned int next_click_is_not_double:1;
|
||||
unsigned int backimage_helper_launched:1;
|
||||
/* some client has issued a WM_COLORMAP_NOTIFY */
|
||||
unsigned int colormap_stuff_blocked:1;
|
||||
unsigned int doing_alt_tab:1;
|
||||
unsigned int jump_back_pending:1;
|
||||
unsigned int ignore_focus_events:1;
|
||||
unsigned int in_hot_corner:3;
|
||||
} flags;
|
||||
} WScreen;
|
||||
|
||||
#endif // WMSCREEN_INTERFACE_H_
|
||||
@@ -333,7 +333,7 @@ static RImage * get_texture_image(WScreen *scr, const char *pixmap_file)
|
||||
}
|
||||
image = RLoadImage(scr->rcontext, file, 0);
|
||||
if (!image) {
|
||||
wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode));
|
||||
wwarning(_("could not load texture pixmap \"%s\":%s"), file, wraster_current_error_message());
|
||||
wfree(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -451,7 +451,7 @@ RImage *wTextureRenderImage(WTexture * texture, int width, int height, int relie
|
||||
if (!image) {
|
||||
RColor gray;
|
||||
|
||||
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
|
||||
wwarning(_("could not render texture: %s"), wraster_current_error_message());
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (image == NULL) {
|
||||
|
||||
@@ -433,7 +433,7 @@ RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size)
|
||||
image = RLoadImage(scr->rcontext, file_name, 0);
|
||||
if (!image)
|
||||
wwarning(_("error loading image file \"%s\": %s"), file_name,
|
||||
RMessageForError(RErrorCode));
|
||||
wraster_current_error_message());
|
||||
|
||||
image = wIconValidateIconSize(image, max_size);
|
||||
|
||||
|
||||
@@ -488,7 +488,7 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, const char *wm_i
|
||||
|
||||
buf = wmalloc(len);
|
||||
snprintf(buf, len, _("Could not open specified icon \"%s\":%s"),
|
||||
file, RMessageForError(RErrorCode));
|
||||
file, wraster_current_error_message());
|
||||
wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, _("OK"), NULL, NULL);
|
||||
wfree(buf);
|
||||
wfree(file);
|
||||
|
||||
@@ -1,10 +1,31 @@
|
||||
load("@rules_rust//rust:defs.bzl", "rust_library")
|
||||
|
||||
rust_library(
|
||||
name = "error_code",
|
||||
srcs = ["error_code.rs"],
|
||||
edition = "2021",
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "error_code_cc_test",
|
||||
srcs = ["error_code_test.c"],
|
||||
deps = [":error_code"],
|
||||
)
|
||||
|
||||
rust_library(
|
||||
name = "wrlib_rs",
|
||||
srcs = ["wrlib.rs"],
|
||||
deps = [
|
||||
":ppm",
|
||||
":rimage",
|
||||
":wrlib",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
edition = "2021",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "wrlib",
|
||||
copts = [
|
||||
"-DMAGICKCORE_HDRI_ENABLE=0",
|
||||
"-DMAGICKCORE_QUANTUM_DEPTH=16",
|
||||
"-DMAGICKCORE_CHANNEL_MASK_DEPTH=32",
|
||||
],
|
||||
srcs = [
|
||||
"alpha_combine.c",
|
||||
"color.c",
|
||||
@@ -41,6 +62,7 @@ cc_library(
|
||||
"xutil.h",
|
||||
],
|
||||
deps = [
|
||||
":error_code",
|
||||
"//config",
|
||||
"@ImageMagick//:lib",
|
||||
"@MagickWand//:lib",
|
||||
|
||||
@@ -98,7 +98,7 @@ static Bool allocateStandardPseudoColor(RContext * ctx, XStandardColormap * stdc
|
||||
+ stdcmap->green_max * stdcmap->green_mult + stdcmap->blue_max * stdcmap->blue_mult + 1;
|
||||
|
||||
if (ctx->ncolors <= 1) {
|
||||
RErrorCode = RERR_INTERNAL;
|
||||
wraster_report_error_code(RERR_INTERNAL);
|
||||
puts("wraster: bad standard colormap");
|
||||
|
||||
return False;
|
||||
@@ -106,7 +106,7 @@ static Bool allocateStandardPseudoColor(RContext * ctx, XStandardColormap * stdc
|
||||
|
||||
ctx->colors = malloc(sizeof(XColor) * ctx->ncolors);
|
||||
if (!ctx->colors) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
|
||||
return False;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ static Bool allocateStandardPseudoColor(RContext * ctx, XStandardColormap * stdc
|
||||
free(ctx->colors);
|
||||
ctx->colors = NULL;
|
||||
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
|
||||
return False;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ static Bool setupStandardColormap(RContext * ctx, Atom property)
|
||||
#ifdef HAVE_LIBXMU
|
||||
if (!XmuLookupStandardColormap(ctx->dpy, ctx->screen_number,
|
||||
ctx->visual->visualid, ctx->depth, property, True, True)) {
|
||||
RErrorCode = RERR_STDCMAPFAIL;
|
||||
wraster_report_error_code(RERR_STDCMAPFAIL);
|
||||
|
||||
return False;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ static Bool setupStandardColormap(RContext * ctx, Atom property)
|
||||
#else
|
||||
(void) ctx;
|
||||
(void) property;
|
||||
RErrorCode = RERR_STDCMAPFAIL;
|
||||
wraster_report_error_code(RERR_STDCMAPFAIL);
|
||||
return False;
|
||||
#endif
|
||||
}
|
||||
@@ -248,14 +248,14 @@ static Bool allocatePseudoColor(RContext *ctx)
|
||||
|
||||
colors = malloc(sizeof(XColor) * ncolors);
|
||||
if (!colors) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
|
||||
ctx->pixels = malloc(sizeof(unsigned long) * ncolors);
|
||||
if (!ctx->pixels) {
|
||||
free(colors);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ static XColor *allocateGrayScale(RContext * ctx)
|
||||
|
||||
colors = malloc(sizeof(XColor) * ncolors);
|
||||
if (!colors) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
@@ -528,7 +528,7 @@ RContext *RCreateContext(Display * dpy, int screen_number, const RContextAttribu
|
||||
|
||||
context = malloc(sizeof(RContext));
|
||||
if (!context) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
memset(context, 0, sizeof(RContext));
|
||||
@@ -540,7 +540,7 @@ RContext *RCreateContext(Display * dpy, int screen_number, const RContextAttribu
|
||||
context->attribs = malloc(sizeof(RContextAttributes));
|
||||
if (!context->attribs) {
|
||||
free(context);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
if (!attribs)
|
||||
@@ -569,7 +569,7 @@ RContext *RCreateContext(Display * dpy, int screen_number, const RContextAttribu
|
||||
vinfo = XGetVisualInfo(context->dpy, VisualIDMask | VisualScreenMask, &templ, &nret);
|
||||
if (!vinfo || nret == 0) {
|
||||
free(context);
|
||||
RErrorCode = RERR_BADVISUALID;
|
||||
wraster_report_error_code(RERR_BADVISUALID);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image)
|
||||
btable = computeTable(bmask);
|
||||
|
||||
if (rtable == NULL || gtable == NULL || btable == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image)
|
||||
if (!err || !nerr) {
|
||||
NFREE(err);
|
||||
NFREE(nerr);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage * image)
|
||||
btable = computeTable(bmask);
|
||||
|
||||
if (rtable == NULL || gtable == NULL || btable == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -545,7 +545,7 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage * image)
|
||||
if (!err || !nerr) {
|
||||
NFREE(err);
|
||||
NFREE(nerr);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -592,7 +592,7 @@ static RXImage *image2StandardPseudoColor(RContext * ctx, RImage * image)
|
||||
btable = computeStdTable(ctx->std_rgb_map->blue_mult, ctx->std_rgb_map->blue_max);
|
||||
|
||||
if (rtable == NULL || gtable == NULL || btable == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -623,7 +623,7 @@ static RXImage *image2StandardPseudoColor(RContext * ctx, RImage * image)
|
||||
if (!err || !nerr) {
|
||||
NFREE(err);
|
||||
NFREE(nerr);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -743,7 +743,7 @@ static RXImage *image2GrayScale(RContext * ctx, RImage * image)
|
||||
table = computeTable(gmask);
|
||||
|
||||
if (table == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -778,7 +778,7 @@ static RXImage *image2GrayScale(RContext * ctx, RImage * image)
|
||||
if (!gerr || !ngerr) {
|
||||
NFREE(gerr);
|
||||
NFREE(ngerr);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1006,7 +1006,7 @@ Bool RGetClosestXColor(RContext * context, const RColor * color, XColor * retCol
|
||||
btable = computeStdTable(context->std_rgb_map->blue_mult, context->std_rgb_map->blue_max);
|
||||
|
||||
if (rtable == NULL || gtable == NULL || btable == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ Bool RGetClosestXColor(RContext * context, const RColor * color, XColor * retCol
|
||||
btable = computeTable(bmask);
|
||||
|
||||
if (rtable == NULL || gtable == NULL || btable == NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
index = rtable[color->red] * cpccpc + gtable[color->green] * cpc + btable[color->blue];
|
||||
@@ -1060,7 +1060,7 @@ Bool RGetClosestXColor(RContext * context, const RColor * color, XColor * retCol
|
||||
|
||||
*retColor = context->colors[index];
|
||||
} else {
|
||||
RErrorCode = RERR_INTERNAL;
|
||||
wraster_report_error_code(RERR_INTERNAL);
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ int RBlurImage(RImage * image)
|
||||
|
||||
pptr = malloc(image->width * ch);
|
||||
if (!pptr) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
#define MASK(prev, cur, next, ch)\
|
||||
|
||||
107
bazel/wrlib/error_code.rs
Normal file
107
bazel/wrlib/error_code.rs
Normal file
@@ -0,0 +1,107 @@
|
||||
use std::{
|
||||
os::raw::{c_char, c_int},
|
||||
sync::RwLock,
|
||||
};
|
||||
|
||||
static ERROR_STATUS: RwLock<ErrorCode> = RwLock::new(ErrorCode::None);
|
||||
|
||||
#[repr(i16)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ErrorCode {
|
||||
/// No known error status.
|
||||
None = 0,
|
||||
|
||||
/// Can't open file.
|
||||
Open = 1,
|
||||
|
||||
/// Error reading from file.
|
||||
Read = 2,
|
||||
|
||||
/// Error writing to file.
|
||||
Write = 3,
|
||||
|
||||
/// Out of memory.
|
||||
NoMemory = 4,
|
||||
|
||||
/// Out of color cells.
|
||||
NoColor = 5,
|
||||
|
||||
/// Image file is corrupted or invalid.
|
||||
BadImageFile = 6,
|
||||
|
||||
/// Image file format is unknown.
|
||||
BadFormat = 7,
|
||||
|
||||
/// No such image index in file.
|
||||
BadIndex = 8,
|
||||
|
||||
/// Invalid visual ID requested for context.
|
||||
BadVisualId = 16,
|
||||
|
||||
/// Failed to create std colormap.
|
||||
StdCmapFail = 17,
|
||||
|
||||
/// Internal X11 error.
|
||||
XError = 127,
|
||||
|
||||
/// Should not happen.
|
||||
Internal = 128,
|
||||
}
|
||||
|
||||
/// Sets the global error status in a thread-safe way. Panics if the error
|
||||
/// status lock has been poisoned.
|
||||
pub fn wraster_set_error_code(code: ErrorCode) {
|
||||
*ERROR_STATUS.write().unwrap() = code;
|
||||
}
|
||||
|
||||
/// Sets the global error status to a literal `value`. Panics if `value` does
|
||||
/// not correspond to a valid error value.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wraster_report_error_code(value: c_int) {
|
||||
let value = match value {
|
||||
0 => ErrorCode::None,
|
||||
1 => ErrorCode::Open,
|
||||
2 => ErrorCode::Read,
|
||||
3 => ErrorCode::Write,
|
||||
4 => ErrorCode::NoMemory,
|
||||
5 => ErrorCode::NoColor,
|
||||
6 => ErrorCode::BadImageFile,
|
||||
7 => ErrorCode::BadFormat,
|
||||
8 => ErrorCode::BadIndex,
|
||||
16 => ErrorCode::BadVisualId,
|
||||
17 => ErrorCode::StdCmapFail,
|
||||
127 => ErrorCode::XError,
|
||||
128 => ErrorCode::Internal,
|
||||
_ => panic!("unknown error code: {}", value),
|
||||
};
|
||||
*ERROR_STATUS.write().unwrap() = value;
|
||||
}
|
||||
|
||||
/// Returns the current error status. Panics if the error status lock has been
|
||||
/// poisoned.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wraster_current_error_code() -> i16 {
|
||||
*ERROR_STATUS.read().unwrap() as i16
|
||||
}
|
||||
|
||||
/// Returns a human-readable description of the current error status. Panics if
|
||||
/// the error status lock has been poisoned.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wraster_current_error_message() -> *const c_char {
|
||||
// TODO: i18n of these messages.
|
||||
match *ERROR_STATUS.read().unwrap() {
|
||||
ErrorCode::None => c"no error".as_ptr(),
|
||||
ErrorCode::Open => c"could not open file".as_ptr(),
|
||||
ErrorCode::Read => c"error reading from file".as_ptr(),
|
||||
ErrorCode::Write => c"error writing to file".as_ptr(),
|
||||
ErrorCode::NoMemory => c"out of memory".as_ptr(),
|
||||
ErrorCode::NoColor => c"out of color cells".as_ptr(),
|
||||
ErrorCode::BadImageFile => c"invalid or corrupted image file".as_ptr(),
|
||||
ErrorCode::BadFormat => c"image format is not supported".as_ptr(),
|
||||
ErrorCode::BadIndex => c"file does not contain requested image index".as_ptr(),
|
||||
ErrorCode::BadVisualId => c"request for an invalid Visual ID".as_ptr(),
|
||||
ErrorCode::StdCmapFail => c"failed to create X standard colormap".as_ptr(),
|
||||
ErrorCode::XError => c"internal X error".as_ptr(),
|
||||
ErrorCode::Internal => c"internal error".as_ptr(),
|
||||
}
|
||||
}
|
||||
40
bazel/wrlib/error_code_test.c
Normal file
40
bazel/wrlib/error_code_test.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/* error codes */
|
||||
#define RERR_NONE 0
|
||||
#define RERR_OPEN 1 /* cant open file */
|
||||
#define RERR_READ 2 /* error reading from file */
|
||||
#define RERR_WRITE 3 /* error writing to file */
|
||||
#define RERR_NOMEMORY 4 /* out of memory */
|
||||
#define RERR_NOCOLOR 5 /* out of color cells */
|
||||
#define RERR_BADIMAGEFILE 6 /* image file is corrupted or invalid */
|
||||
#define RERR_BADFORMAT 7 /* image file format is unknown */
|
||||
#define RERR_BADINDEX 8 /* no such image index in file */
|
||||
|
||||
#define RERR_BADVISUALID 16 /* invalid visual ID requested for context */
|
||||
#define RERR_STDCMAPFAIL 17 /* failed to created std colormap */
|
||||
|
||||
#define RERR_XERROR 127 /* internal X error */
|
||||
#define RERR_INTERNAL 128 /* should not happen */
|
||||
|
||||
void wraster_report_error_code(int value);
|
||||
|
||||
const char* wraster_current_error_message();
|
||||
|
||||
int wraster_current_error_code();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(wraster_current_error_code() == RERR_NONE);
|
||||
assert(strcmp(wraster_current_error_message(), "no error") == 0);
|
||||
|
||||
wraster_report_error_code(RERR_WRITE);
|
||||
|
||||
assert(wraster_current_error_code() == RERR_WRITE);
|
||||
assert(strcmp(wraster_current_error_message(), "error writing to file") == 0);
|
||||
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
|
||||
assert(wraster_current_error_code() == RERR_OPEN);
|
||||
assert(strcmp(wraster_current_error_message(), "could not open file") == 0);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ RImage *RLoadImage(RContext *context, const char *file, int index)
|
||||
image = RLoadMagick(file);
|
||||
break;
|
||||
#else
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
@@ -236,7 +236,7 @@ RImage *RLoadImage(RContext *context, const char *file, int index)
|
||||
break;
|
||||
|
||||
default:
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ static WRImgFormat identFile(const char *path)
|
||||
if (file != NULL)
|
||||
break;
|
||||
if (errno != EINTR) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return IM_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ static WRImgFormat identFile(const char *path)
|
||||
nread = fread(buffer, 1, sizeof(buffer), file);
|
||||
if (nread < sizeof(buffer) || ferror(file)) {
|
||||
fclose(file);
|
||||
RErrorCode = RERR_READ;
|
||||
wraster_report_error_code(RERR_READ);
|
||||
return IM_ERROR;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
@@ -56,7 +56,7 @@ RImage *RLoadGIF(const char *file, int index)
|
||||
index = 0;
|
||||
|
||||
/* default error message */
|
||||
RErrorCode = RERR_BADINDEX;
|
||||
wraster_report_error_code(RERR_BADINDEX);
|
||||
|
||||
#if USE_GIF == 4
|
||||
gif = DGifOpenFileName(file);
|
||||
@@ -70,13 +70,13 @@ RImage *RLoadGIF(const char *file, int index)
|
||||
#endif
|
||||
switch (gif_error) {
|
||||
case D_GIF_ERR_OPEN_FAILED:
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
break;
|
||||
case D_GIF_ERR_READ_FAILED:
|
||||
RErrorCode = RERR_READ;
|
||||
wraster_report_error_code(RERR_READ);
|
||||
break;
|
||||
default:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
@@ -88,7 +88,7 @@ RImage *RLoadGIF(const char *file, int index)
|
||||
#else
|
||||
DGifCloseFile(gif);
|
||||
#endif
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ RImage *RLoadGIF(const char *file, int index)
|
||||
|
||||
buffer = malloc(width * sizeof(GifPixelType));
|
||||
if (!buffer) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
@@ -199,18 +199,18 @@ RImage *RLoadGIF(const char *file, int index)
|
||||
#if USE_GIF == 4
|
||||
switch (GifLastError()) {
|
||||
case D_GIF_ERR_OPEN_FAILED:
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
break;
|
||||
case D_GIF_ERR_READ_FAILED:
|
||||
RErrorCode = RERR_READ;
|
||||
wraster_report_error_code(RERR_READ);
|
||||
break;
|
||||
default:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
/* With gif_lib v5 there's no way to know what went wrong */
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
#endif
|
||||
bye:
|
||||
if (image)
|
||||
|
||||
@@ -105,7 +105,7 @@ static RImage *do_read_jpeg_file(struct jpeg_decompress_struct *cinfo, const cha
|
||||
|
||||
file = fopen(file_name, "rb");
|
||||
if (!file) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -115,13 +115,13 @@ static RImage *do_read_jpeg_file(struct jpeg_decompress_struct *cinfo, const cha
|
||||
|
||||
if (cinfo->image_width < 1 || cinfo->image_height < 1) {
|
||||
buffer[0] = NULL; /* Initialize pointer to avoid spurious free in cleanup code */
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
goto abort_and_release_resources;
|
||||
}
|
||||
|
||||
buffer[0] = (JSAMPROW) malloc(cinfo->image_width * cinfo->num_components);
|
||||
if (!buffer[0]) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
goto abort_and_release_resources;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ static RImage *do_read_jpeg_file(struct jpeg_decompress_struct *cinfo, const cha
|
||||
jpeg_calc_output_dimensions(cinfo);
|
||||
image = RCreateImage(cinfo->image_width, cinfo->image_height, False);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
goto abort_and_release_resources;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ RImage *RLoadMagick(const char *file_name)
|
||||
PixelWand *bg_wand = NULL;
|
||||
|
||||
if (RInitMagickIfNeeded()) {
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ RImage *RLoadMagick(const char *file_name)
|
||||
|
||||
/* Read the input image */
|
||||
if (!MagickReadImage(m_wand, file_name)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ RImage *RLoadMagick(const char *file_name)
|
||||
|
||||
image = RCreateImage(w, h, (unsigned int) hasAlfa);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ RImage *RLoadMagick(const char *file_name)
|
||||
mrc = MagickExportImagePixels(m_wand, 0, 0, (size_t)w, (size_t)h, "RGBA", CharPixel, ptr);
|
||||
|
||||
if (mrc == MagickFalse) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
image = NULL;
|
||||
goto bye;
|
||||
|
||||
@@ -51,19 +51,19 @@ RImage *RLoadPNG(RContext *context, const char *file)
|
||||
|
||||
f = fopen(file, "rb");
|
||||
if (!f) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, (png_error_ptr) NULL, (png_error_ptr) NULL);
|
||||
if (!png) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pinfo = png_create_info_struct(png);
|
||||
if (!pinfo) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
png_destroy_read_struct(&png, NULL, NULL);
|
||||
return NULL;
|
||||
@@ -71,13 +71,13 @@ RImage *RLoadPNG(RContext *context, const char *file)
|
||||
|
||||
einfo = png_create_info_struct(png);
|
||||
if (!einfo) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
png_destroy_read_struct(&png, &pinfo, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RErrorCode = RERR_INTERNAL;
|
||||
wraster_report_error_code(RERR_INTERNAL);
|
||||
#if PNG_LIBPNG_VER - 0 < 10400
|
||||
if (setjmp(png->jmpbuf)) {
|
||||
#else
|
||||
@@ -100,7 +100,7 @@ RImage *RLoadPNG(RContext *context, const char *file)
|
||||
if (width < 1 || height < 1) {
|
||||
fclose(f);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ RImage *RLoadPNG(RContext *context, const char *file)
|
||||
|
||||
png_rows = calloc(height, sizeof(png_bytep));
|
||||
if (!png_rows) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
RReleaseImage(image);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
@@ -176,7 +176,7 @@ RImage *RLoadPNG(RContext *context, const char *file)
|
||||
for (y = 0; y < height; y++) {
|
||||
png_rows[y] = malloc(png_get_rowbytes(png, pinfo));
|
||||
if (!png_rows[y]) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
RReleaseImage(image);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
|
||||
@@ -126,13 +126,13 @@ static RImage *load_graymap(FILE *file, int w, int h, int max, int raw, const ch
|
||||
int x, y;
|
||||
|
||||
if (raw != '2' && raw != '5') {
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = RCreateImage(w, h, 0);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ static RImage *load_graymap(FILE *file, int w, int h, int max, int raw, const ch
|
||||
val = pm_getuint(file, filename);
|
||||
|
||||
if (val > max || val < 0) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
@@ -163,14 +163,14 @@ static RImage *load_graymap(FILE *file, int w, int h, int max, int raw, const ch
|
||||
|
||||
buf = malloc(w + 1);
|
||||
if (!buf) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
for (y = 0; y < h; y++) {
|
||||
if (!fread(buf, w, 1, file)) {
|
||||
free(buf);
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
@@ -196,13 +196,13 @@ static RImage *load_pixmap(FILE *file, int w, int h, int max, int raw, const cha
|
||||
unsigned char *ptr;
|
||||
|
||||
if (raw != '3' && raw != '6') {
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = RCreateImage(w, h, 0);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ static RImage *load_pixmap(FILE *file, int w, int h, int max, int raw, const cha
|
||||
val = pm_getuint(file, filename);
|
||||
|
||||
if (val > max || val < 0) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ static RImage *load_pixmap(FILE *file, int w, int h, int max, int raw, const cha
|
||||
i = 0;
|
||||
while (i < w * h) {
|
||||
if (fread(buf, 1, 3, file) != 3) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
@@ -256,13 +256,13 @@ static RImage *load_bitmap(FILE *file, int w, int h, int max, int raw, const cha
|
||||
unsigned char *ptr;
|
||||
|
||||
if (raw != '1' && raw != '4') {
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = RCreateImage(w, h, 0);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ static RImage *load_bitmap(FILE *file, int w, int h, int max, int raw, const cha
|
||||
val = pm_getuint(file, filename);
|
||||
|
||||
if (val > max || val < 0) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
@@ -321,20 +321,20 @@ RImage *RLoadPPM(const char *file_name)
|
||||
|
||||
file = fopen(file_name, "rb");
|
||||
if (!file) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get signature */
|
||||
if (!fgets(buffer, 255, file)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* accept bitmaps, pixmaps or graymaps */
|
||||
if (buffer[0] != 'P' || (buffer[1] < '1' || buffer[1] > '6')) {
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ RImage *RLoadPPM(const char *file_name)
|
||||
/* skip comments */
|
||||
while (1) {
|
||||
if (!fgets(buffer, 255, file)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -356,21 +356,21 @@ RImage *RLoadPPM(const char *file_name)
|
||||
/* get size */
|
||||
if (sscanf(buffer, "%i %i", &w, &h) != 2 || w < 1 || h < 1) {
|
||||
/* Short file */
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (type != '1' && type != '4') {
|
||||
if (!fgets(buffer, 255, file)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
/* get max value */
|
||||
if (sscanf(buffer, "%i", &m) != 1 || m < 1) {
|
||||
/* Short file */
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ RImage *RLoadTIFF(const char *file, int index)
|
||||
i = index;
|
||||
while (i > 0) {
|
||||
if (!TIFFReadDirectory(tif)) {
|
||||
RErrorCode = RERR_BADINDEX;
|
||||
wraster_report_error_code(RERR_BADINDEX);
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ RImage *RLoadTIFF(const char *file, int index)
|
||||
amode = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
|
||||
|
||||
if (width < 1 || height < 1) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
@@ -92,10 +92,10 @@ RImage *RLoadTIFF(const char *file, int index)
|
||||
#endif
|
||||
|
||||
if (!data) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
} else {
|
||||
if (!TIFFReadRGBAImage(tif, width, height, data, 0)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
} else {
|
||||
|
||||
/* convert data */
|
||||
|
||||
@@ -76,12 +76,12 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
|
||||
file = fopen(file_name, "rb");
|
||||
if (!file) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!fread(buffer, sizeof(buffer), 1, file)) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
#else
|
||||
(buffer[15] == ' ' || buffer[15] == 'X' || buffer[15] == 'L'))) {
|
||||
#endif
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
if (raw_data_size <= 0) {
|
||||
fprintf(stderr, _("wrlib: could not get size of WebP file \"%s\", %s\n"),
|
||||
file_name, strerror(errno));
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
raw_data = (uint8_t *) malloc(raw_data_size);
|
||||
|
||||
if (!raw_data) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
fclose(file);
|
||||
|
||||
if (r != raw_data_size) {
|
||||
RErrorCode = RERR_READ;
|
||||
wraster_report_error_code(RERR_READ);
|
||||
free(raw_data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
if (status != VP8_STATUS_OK) {
|
||||
fprintf(stderr, _("wrlib: could not get features from WebP file \"%s\", %s\n"),
|
||||
file_name, webp_message_from_status(status));
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
free(raw_data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
if (features.has_alpha) {
|
||||
image = RCreateImage(features.width, features.height, True);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
free(raw_data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
} else {
|
||||
image = RCreateImage(features.width, features.height, False);
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
free(raw_data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ RImage *RLoadWEBP(const char *file_name)
|
||||
|
||||
if (!ret) {
|
||||
fprintf(stderr, _("wrlib: failed to decode WebP from file \"%s\"\n"), file_name);
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ static RImage *create_rimage_from_xpm(RContext *context, XpmImage xpm)
|
||||
int *p;
|
||||
|
||||
if (xpm.height < 1 || xpm.width < 1) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (xpm.colorTable == NULL) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
return NULL;
|
||||
}
|
||||
image = RCreateImage(xpm.width, xpm.height, True);
|
||||
@@ -66,7 +66,7 @@ static RImage *create_rimage_from_xpm(RContext *context, XpmImage xpm)
|
||||
free(color_table[i]);
|
||||
}
|
||||
RReleaseImage(image);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -134,16 +134,16 @@ static int is_xpm_error(int status)
|
||||
|
||||
switch (status) {
|
||||
case XpmOpenFailed:
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
break;
|
||||
case XpmFileInvalid:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
break;
|
||||
case XpmNoMemory:
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
break;
|
||||
default:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -104,7 +104,7 @@ RImage *RGetImageFromXPMData(RContext * context, char **data)
|
||||
bsize = csize * w + 16;
|
||||
|
||||
if (!color_table[0] || !color_table[1] || !color_table[2] || !color_table[3] || !symbol_table || !bsize) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
free_color_symbol_table(color_table, symbol_table);
|
||||
return NULL;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ RImage *RGetImageFromXPMData(RContext * context, char **data)
|
||||
return image;
|
||||
|
||||
bad_format:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
free_color_symbol_table(color_table, symbol_table);
|
||||
if (image)
|
||||
RReleaseImage(image);
|
||||
@@ -258,7 +258,7 @@ RImage *RLoadXPM(RContext * context, const char *file)
|
||||
|
||||
f = fopen(file, "rb");
|
||||
if (!f) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
/* sig */
|
||||
@@ -294,7 +294,7 @@ RImage *RLoadXPM(RContext * context, const char *file)
|
||||
|
||||
if (!color_table[0] || !color_table[1] || !color_table[2] ||
|
||||
!color_table[3] || !symbol_table || !bsize || !buffer) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
fclose(f);
|
||||
free_color_symbol_table(color_table, symbol_table);
|
||||
if (buffer)
|
||||
@@ -438,7 +438,7 @@ RImage *RLoadXPM(RContext * context, const char *file)
|
||||
return image;
|
||||
|
||||
bad_format:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(f);
|
||||
free_color_symbol_table(color_table, symbol_table);
|
||||
if (buffer)
|
||||
@@ -448,7 +448,7 @@ RImage *RLoadXPM(RContext * context, const char *file)
|
||||
return NULL;
|
||||
|
||||
bad_file:
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
wraster_report_error_code(RERR_BADIMAGEFILE);
|
||||
fclose(f);
|
||||
free_color_symbol_table(color_table, symbol_table);
|
||||
if (buffer)
|
||||
|
||||
@@ -200,51 +200,6 @@ void RLightImage(RImage *image, const RColor *color)
|
||||
}
|
||||
}
|
||||
|
||||
const char *RMessageForError(int errorCode)
|
||||
{
|
||||
switch (errorCode) {
|
||||
case RERR_NONE:
|
||||
return _("no error");
|
||||
|
||||
case RERR_OPEN:
|
||||
return _("could not open file");
|
||||
|
||||
case RERR_READ:
|
||||
return _("error reading from file");
|
||||
|
||||
case RERR_WRITE:
|
||||
return _("error writing to file");
|
||||
|
||||
case RERR_NOMEMORY:
|
||||
return _("out of memory");
|
||||
|
||||
case RERR_NOCOLOR:
|
||||
return _("out of color cells");
|
||||
|
||||
case RERR_BADIMAGEFILE:
|
||||
return _("invalid or corrupted image file");
|
||||
|
||||
case RERR_BADFORMAT:
|
||||
return _("image format is not supported");
|
||||
|
||||
case RERR_BADINDEX:
|
||||
return _("file does not contain requested image index");
|
||||
|
||||
case RERR_BADVISUALID:
|
||||
return _("request for an invalid Visual ID");
|
||||
|
||||
case RERR_STDCMAPFAIL:
|
||||
return _("failed to create X standard colormap");
|
||||
|
||||
case RERR_XERROR:
|
||||
return _("internal X error");
|
||||
|
||||
default:
|
||||
case RERR_INTERNAL:
|
||||
return _("internal error");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef I18N
|
||||
/*
|
||||
* Setup internationalization on startup
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
|
||||
char *WRasterLibVersion = "0.9";
|
||||
|
||||
int RErrorCode = RERR_NONE;
|
||||
|
||||
#define HAS_ALPHA(I) ((I)->format == RRGBAFormat)
|
||||
|
||||
#define MAX_WIDTH 20000
|
||||
@@ -49,13 +47,13 @@ RImage *RCreateImage(unsigned width, unsigned height, int alpha)
|
||||
assert(width > 0 && height > 0);
|
||||
|
||||
if (width > MAX_WIDTH || height > MAX_HEIGHT) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = malloc(sizeof(RImage));
|
||||
if (!image) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -70,7 +68,7 @@ RImage *RCreateImage(unsigned width, unsigned height, int alpha)
|
||||
*/
|
||||
image->data = malloc(width * height * (alpha ? 4 : 3) + 4);
|
||||
if (!image->data) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
free(image);
|
||||
image = NULL;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ Bool RSaveTitledImage(RImage *image, const char *filename, const char *format, c
|
||||
if (strcasecmp(format, "XPM") == 0)
|
||||
return RSaveXPM(image, filename);
|
||||
|
||||
RErrorCode = RERR_BADFORMAT;
|
||||
wraster_report_error_code(RERR_BADFORMAT);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ Bool RSaveJPEG(RImage *img, const char *filename, char *title)
|
||||
|
||||
file = fopen(filename, "wb");
|
||||
if (!file) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Bool RSavePNG(RImage *img, const char *filename, char *title)
|
||||
|
||||
file = fopen(filename, "wb");
|
||||
if (file == NULL) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ Bool RSavePNG(RImage *img, const char *filename, char *title)
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL) {
|
||||
fclose(file);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ Bool RSavePNG(RImage *img, const char *filename, char *title)
|
||||
png_info_ptr = png_create_info_struct(png_ptr);
|
||||
if (png_info_ptr == NULL) {
|
||||
fclose(file);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Setup Exception handling */
|
||||
if (setjmp(png_jmpbuf (png_ptr))) {
|
||||
fclose(file);
|
||||
RErrorCode = RERR_INTERNAL;
|
||||
wraster_report_error_code(RERR_INTERNAL);
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ static Bool addcolor(XPMColor ** list, unsigned r, unsigned g, unsigned b, int *
|
||||
|
||||
if (!newc) {
|
||||
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
|
||||
return False;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ Bool RSaveXPM(RImage * image, const char *filename)
|
||||
|
||||
file = fopen(filename, "wb+");
|
||||
if (!file) {
|
||||
RErrorCode = RERR_OPEN;
|
||||
wraster_report_error_code(RERR_OPEN);
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ Bool RSaveXPM(RImage * image, const char *filename)
|
||||
errno = 0;
|
||||
fclose(file);
|
||||
if (ok && errno == ENOSPC) {
|
||||
RErrorCode = RERR_WRITE;
|
||||
wraster_report_error_code(RERR_WRITE);
|
||||
}
|
||||
|
||||
freecolormap(colormap);
|
||||
|
||||
@@ -568,16 +568,19 @@ void RPutXImage(RContext *context, Drawable d, GC gc, RXImage *ximage,
|
||||
unsigned width, unsigned height)
|
||||
__wrlib_nonnull(1, 3);
|
||||
|
||||
/* do not free the returned string! */
|
||||
const char *RMessageForError(int errorCode)
|
||||
__wrlib_useresult;
|
||||
|
||||
int RBlurImage(RImage *image)
|
||||
__wrlib_nonnull(1);
|
||||
|
||||
/****** Global Variables *******/
|
||||
/****** From error_code.rs ******/
|
||||
void wraster_report_error_code(int value);
|
||||
/* do not free the returned string! */
|
||||
const char* wraster_current_error_message()
|
||||
__wrlib_useresult;
|
||||
int wraster_current_error_code()
|
||||
__wrlib_useresult;
|
||||
|
||||
extern int RErrorCode;
|
||||
/****** Global Variables *******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
86
bazel/wrlib/wrlib.rs
Normal file
86
bazel/wrlib/wrlib.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
use std::os::raw::{c_char, c_int, c_uchar, c_ulong};
|
||||
|
||||
#[repr(C)]
|
||||
pub enum RImageFormat {
|
||||
RGBAFormat = 0,
|
||||
RRGBAFormat = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct RImage {
|
||||
data: *mut c_uchar,
|
||||
width: c_int,
|
||||
height: c_int,
|
||||
format: RImageFormat,
|
||||
ref_count: c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct RContext {
|
||||
// display: *mut Display,
|
||||
display: usize,
|
||||
screen_number: c_int,
|
||||
// cmap: Colormap,
|
||||
|
||||
// attribs: *mut RContextAttributes,
|
||||
attribs: usize,
|
||||
|
||||
// copy_gc: GC,
|
||||
|
||||
// visual: *mut Visual,
|
||||
visual: usize,
|
||||
depth: c_int,
|
||||
// drawable: Window,
|
||||
vclass: c_int,
|
||||
|
||||
black: c_ulong,
|
||||
white: c_ulong,
|
||||
|
||||
red_offset: c_int,
|
||||
green_offset: c_int,
|
||||
blue_offset: c_int,
|
||||
|
||||
std_rgb_map: usize,
|
||||
std_gray_map: usize,
|
||||
// std_rgb_map: *mut XStandardColorMap,
|
||||
// std_gray_map: *mut XStandardColorMap,
|
||||
|
||||
ncolors: c_int,
|
||||
colors: usize,
|
||||
// colors: *mut XColor,
|
||||
pixels: *mut c_ulong,
|
||||
|
||||
flags: u8,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum RScalingFilter {
|
||||
RBoxFilter,
|
||||
RTriangleFilter,
|
||||
RBellFilter,
|
||||
RBSplineFilter,
|
||||
RLanczos3Filter,
|
||||
RMitchellFilter,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn r_destroy_conversion_tables() -> ();
|
||||
|
||||
pub fn RLoadPPM(file: *const c_char) -> *mut RImage;
|
||||
|
||||
pub fn RLoadXPM(context: *mut RContext, file: *const c_char) -> *mut RImage;
|
||||
|
||||
pub fn RReleaseCache() -> ();
|
||||
|
||||
pub fn wraster_rotate_image_180(source: *const RImage) -> *mut RImage;
|
||||
|
||||
pub fn wraster_change_filter(ty: RScalingFilter) -> ();
|
||||
|
||||
pub fn RShutdown() -> ();
|
||||
|
||||
#[must_use]
|
||||
pub fn RSupportedFileFormats() -> *mut *const c_char;
|
||||
|
||||
#[must_use]
|
||||
pub fn RGetImageFileFormat(file: *const c_char) -> *mut c_char;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ RImage *RCreateImageFromDrawable(RContext * context, Drawable drawable, Pixmap m
|
||||
pimg = XGetImage(context->dpy, drawable, 0, 0, w, h, AllPlanes, ZPixmap);
|
||||
|
||||
if (!pimg) {
|
||||
RErrorCode = RERR_XERROR;
|
||||
wraster_report_error_code(RERR_XERROR);
|
||||
return NULL;
|
||||
}
|
||||
mimg = NULL;
|
||||
|
||||
@@ -65,21 +65,21 @@ RXImage *RCreateXImage(RContext * context, int depth, unsigned width, unsigned h
|
||||
|
||||
rximg = malloc(sizeof(RXImage));
|
||||
if (!rximg) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
#ifndef USE_XSHM
|
||||
rximg->image = XCreateImage(context->dpy, visual, depth, ZPixmap, 0, NULL, width, height, 8, 0);
|
||||
if (!rximg->image) {
|
||||
free(rximg);
|
||||
RErrorCode = RERR_XERROR;
|
||||
wraster_report_error_code(RERR_XERROR);
|
||||
return NULL;
|
||||
}
|
||||
rximg->image->data = malloc(rximg->image->bytes_per_line * height);
|
||||
if (!rximg->image->data) {
|
||||
XDestroyImage(rximg->image);
|
||||
free(rximg);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
#else /* USE_XSHM */
|
||||
@@ -91,14 +91,14 @@ RXImage *RCreateXImage(RContext * context, int depth, unsigned width, unsigned h
|
||||
rximg->image = XCreateImage(context->dpy, visual, depth, ZPixmap, 0, NULL, width, height, 8, 0);
|
||||
if (!rximg->image) {
|
||||
free(rximg);
|
||||
RErrorCode = RERR_XERROR;
|
||||
wraster_report_error_code(RERR_XERROR);
|
||||
return NULL;
|
||||
}
|
||||
rximg->image->data = malloc(rximg->image->bytes_per_line * height);
|
||||
if (!rximg->image->data) {
|
||||
XDestroyImage(rximg->image);
|
||||
free(rximg);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
@@ -207,7 +207,7 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width
|
||||
if (!ximg) {
|
||||
ximg = malloc(sizeof(RXImage));
|
||||
if (!ximg) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
ximg->is_shared = 0;
|
||||
@@ -216,7 +216,7 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width
|
||||
#else /* !USE_XSHM */
|
||||
ximg = malloc(sizeof(RXImage));
|
||||
if (!ximg) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
wraster_report_error_code(RERR_NOMEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user