Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2007-12-24 21:27:28 +0300
committerTon Roosendaal <ton@blender.org>2007-12-24 21:27:28 +0300
commita1c8543f2acd7086d412cb794b32f96794b00659 (patch)
tree449643369b86531dbbd883193efaeee7d1fb4418 /source/blender/windowmanager
parent8a07e665c28a94ffd188daa431a4fd0c5a460eba (diff)
Step 3 for the initial commits for 2.5: removing src/ and python,
adding new windowmanager module, and the first bits of new editors module.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/Makefile34
-rw-r--r--source/blender/windowmanager/WM_api.h77
-rw-r--r--source/blender/windowmanager/WM_types.h70
-rw-r--r--source/blender/windowmanager/intern/Makefile98
-rw-r--r--source/blender/windowmanager/intern/wm.c164
-rw-r--r--source/blender/windowmanager/intern/wm_apple.c138
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c879
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c470
-rw-r--r--source/blender/windowmanager/intern/wm_files.c929
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c302
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c112
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c125
-rw-r--r--source/blender/windowmanager/intern/wm_window.c491
-rw-r--r--source/blender/windowmanager/wm.h43
-rw-r--r--source/blender/windowmanager/wm_cursors.h115
-rw-r--r--source/blender/windowmanager/wm_event_system.h97
-rw-r--r--source/blender/windowmanager/wm_event_types.h255
-rw-r--r--source/blender/windowmanager/wm_files.h36
-rw-r--r--source/blender/windowmanager/wm_window.h59
19 files changed, 4494 insertions, 0 deletions
diff --git a/source/blender/windowmanager/Makefile b/source/blender/windowmanager/Makefile
new file mode 100644
index 00000000000..ad574aa0d4c
--- /dev/null
+++ b/source/blender/windowmanager/Makefile
@@ -0,0 +1,34 @@
+#
+# $Id: Makefile
+#
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) Blender Foundation.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+# Bounces make to subdirectories.
+
+SOURCEDIR = source/blender/windowmanager
+DIRS = intern
+
+include nan_subdirs.mk
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
new file mode 100644
index 00000000000..880bee6d53c
--- /dev/null
+++ b/source/blender/windowmanager/WM_api.h
@@ -0,0 +1,77 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef WM_API_H
+#define WM_API_H
+
+/* dna-savable wmStructs here */
+#include "DNA_windowmanager_types.h"
+
+struct bContext;
+struct wmEvent;
+struct wmEventHandler;
+
+ /* general API */
+void WM_setprefsize (int stax, int stay, int sizx, int sizy);
+
+void WM_init (struct bContext *C);
+void WM_exit (struct bContext *C);
+void WM_main (struct bContext *C);
+
+ /* files */
+int WM_read_homefile (struct bContext *C, int from_memory);
+int WM_write_homefile (struct bContext *C, struct wmOperator *op);
+void WM_read_file (struct bContext *C, char *name);
+void WM_write_file (struct bContext *C, char *target);
+void WM_read_autosavefile(struct bContext *C);
+void WM_write_autosave (struct bContext *C);
+
+ /* mouse cursors */
+void WM_init_cursor_data (void);
+void WM_set_cursor (struct bContext *C, int curs);
+
+ /* keymap and handlers */
+void WM_keymap_set_item (ListBase *lb, char *idname, short type,
+ short val, int modifier, short keymodifier);
+void WM_keymap_verify_item(ListBase *lb, char *idname, short type,
+ short val, int modifier, short keymodifier);
+struct wmEventHandler *WM_event_add_keymap_handler(ListBase *keymap, ListBase *handlers);
+struct wmEventHandler *WM_event_add_modal_keymap_handler(ListBase *keymap, ListBase *handlers, wmOperator *op);
+
+ /* operator api, default callbacks */
+ /* confirm menu + exec */
+int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
+ /* context checks */
+int WM_operator_winactive (struct bContext *C);
+
+ /* operator api */
+wmOperatorType *WM_operatortype_find(const char *idname);
+void WM_operator_register(wmWindowManager *wm, wmOperator *ot);
+
+
+#endif /* WM_API_H */
+
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
new file mode 100644
index 00000000000..c3a1662c1e1
--- /dev/null
+++ b/source/blender/windowmanager/WM_types.h
@@ -0,0 +1,70 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef WM_TYPES_H
+#define WM_TYPES_H
+
+/* exported types for WM */
+
+/* ************** wmOperatorType ************************ */
+
+/* flag */
+#define OPTYPE_REGISTER 1
+
+/* ************** wmKeyMap ************************ */
+
+/* modifier */
+#define KM_SHIFT 1
+#define KM_CTRL 2
+#define KM_ALT 4
+#define KM_OSKEY 8
+ /* means modifier should be pressed 2nd */
+#define KM_SHIFT2 16
+#define KM_CTRL2 32
+#define KM_ALT2 64
+#define KM_OSKEY2 128
+
+/* val */
+#define KM_PRESS 2
+#define KM_RELEASE 1
+
+
+/* ************** custom wmEvent data ************** */
+
+#define DEV_STYLUS 1
+#define DEV_ERASER 2
+
+typedef struct wmTabletData {
+ int Active; /* 0=None, 1=Stylus, 2=Eraser */
+ float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
+ float Xtilt; /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
+ float Ytilt; /* as above */
+} wmTabletData;
+
+
+#endif /* WM_TYPES_H */
+
diff --git a/source/blender/windowmanager/intern/Makefile b/source/blender/windowmanager/intern/Makefile
new file mode 100644
index 00000000000..3eb4ef7a028
--- /dev/null
+++ b/source/blender/windowmanager/intern/Makefile
@@ -0,0 +1,98 @@
+#
+# $Id: Makefile 11904 2007-08-31 16:16:33Z sirdude $
+#
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = windowmanager
+DIR = $(OCGDIR)/blender/$(LIBNAME)
+
+include nan_compile.mk
+
+CFLAGS += $(LEVEL_1_C_WARNINGS)
+
+# OpenGL and Python
+CPPFLAGS += $(OGL_CPPFLAGS)
+CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+
+# PreProcessor stuff
+
+CPPFLAGS += -I$(NAN_GHOST)/include
+CPPFLAGS += -I$(NAN_BMFONT)/include
+CPPFLAGS += -I$(NAN_ELBEEM)/include
+CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS)
+
+# modules
+CPPFLAGS += -I../../editors/include
+CPPFLAGS += -I../../python
+CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I../../blenlib
+CPPFLAGS += -I../../blenkernel
+CPPFLAGS += -I../../nodes
+CPPFLAGS += -I../../imbuf
+CPPFLAGS += -I../../blenloader
+CPPFLAGS += -I../../render/extern/include
+CPPFLAGS += -I../../ftfont
+CPPFLAGS += -I../../radiosity/extern/include
+CPPFLAGS += -I../../../kernel/gen_system
+
+# path to the guarded memory allocator
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+CPPFLAGS += -I$(NAN_MEMUTIL)/include
+
+ifeq ($(INTERNATIONAL), true)
+ CPPFLAGS += -DINTERNATIONAL
+endif
+
+ifeq ($(WITH_VERSE), true)
+ CPPFLAGS += -DWITH_VERSE
+ CPPFLAGS += -I$(NAN_VERSE)/include
+ # print some other debug information
+ ifeq ($(VERSE_DEBUG_PRINT), true)
+ CPPFLAGS += -DVERSE_DEBUG_PRINT
+ endif
+endif
+
+ifeq ($(WITH_QUICKTIME),true)
+ CPPFLAGS += -I../quicktime
+ CPPFLAGS += -DWITH_QUICKTIME
+endif
+
+ifeq ($(OS),linux)
+ ifeq ($(CPU),alpha)
+ CPPFLAGS += -I$(NAN_MESA)/include
+ endif
+ ifeq ($(CPU),i386)
+ CPPFLAGS += -I$(NAN_MESA)/include
+ endif
+ ifeq ($(CPU),powerpc)
+ CPPFLAGS += -I/usr/src/MesaCVS/include
+ endif
+endif
+
+# path to our own headerfiles
+CPPFLAGS += -I..
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
new file mode 100644
index 00000000000..1576f4b3a40
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm.c
@@ -0,0 +1,164 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+#include "wm_event_types.h"
+
+/* ****************************************************** */
+#define MAX_OP_REGISTERED 32
+
+/* all operations get registered in the windowmanager here */
+/* called on event handling by event_system.c */
+void WM_operator_register(wmWindowManager *wm, wmOperator *op)
+{
+ wmOperator *opc= MEM_mallocN(sizeof(wmOperator), "operator registry");
+ int tot;
+
+ *opc= *op;
+ BLI_addtail(&wm->operators, opc);
+
+ tot= BLI_countlist(&wm->operators);
+
+ while(tot>MAX_OP_REGISTERED) {
+ wmOperator *opt= wm->operators.first;
+ BLI_remlink(&wm->operators, opt);
+ MEM_freeN(opt);
+ tot--;
+ }
+}
+
+/* **************** standard keymap for WM ********************** */
+
+/* default keymap for windows and screens, only call once per WM */
+static void wm_window_keymap(wmWindowManager *wm)
+{
+ /* note, this doesn't replace existing keymap items */
+ WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_window_duplicate", AKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
+}
+
+/* ****************************************** */
+
+void wm_check(bContext *C)
+{
+
+ /* wm context */
+ if(C->wm==NULL) C->wm= G.main->wm.first;
+ if(C->wm==NULL) return;
+ if(C->wm->windows.first==NULL) return;
+
+ /* case: no open windows at all, for old file reads */
+ wm_window_add_ghostwindows(C->wm);
+
+ if(C->window==NULL) C->window= C->wm->windrawable;
+
+ if(C->wm->initialized==0) {
+ wm_window_keymap(C->wm);
+ C->wm->initialized= 1;
+ }
+}
+
+/* on startup, it adds all data, for matching */
+void wm_add_default(bContext *C)
+{
+ wmWindowManager *wm= alloc_libblock(&G.main->wm, ID_WM, "WinMan");
+ wmWindow *win;
+
+ C->wm= wm;
+
+ win= wm_window_new(C, C->screen);
+ wm->windrawable= win;
+ C->window= win;
+}
+
+
+/* context is allowed to be NULL, do net free wm itself (library.c) */
+void wm_close_and_free(bContext *C, wmWindowManager *wm)
+{
+ wmWindow *win;
+
+ while((win= wm->windows.first)) {
+ BLI_remlink(&wm->windows, win);
+ wm_window_free(C, win);
+ }
+
+ BLI_freelistN(&wm->operators);
+ BLI_freelistN(&wm->windowkeymap);
+ BLI_freelistN(&wm->screenkeymap);
+
+ if(C && C->wm==wm) C->wm= NULL;
+}
+
+void wm_close_and_free_all(bContext *C, ListBase *wmlist)
+{
+ wmWindowManager *wm;
+
+ while((wm=wmlist->first)) {
+ wm_close_and_free(C, wm);
+ BLI_remlink(wmlist, wm);
+ MEM_freeN(wm);
+ }
+}
+
+void WM_main(bContext *C)
+{
+ while(1) {
+
+ /* get events from ghost, handle window events, add to window queues */
+ /* WM_init has assigned to ghost the bContext already */
+ wm_window_process_events(1);
+
+ /* per window, all events to the window, screen, area and region handlers */
+ wm_event_do_handlers(C);
+
+ }
+}
+
+/* While (local_event) {
+Update controller stack if active changed ()
+Match event to an action()
+Process_event()
+Do_notifications()
+Do_draw_updates()
+}
+*/
+
diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c
new file mode 100644
index 00000000000..e04457fc515
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_apple.c
@@ -0,0 +1,138 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef __APPLE__
+
+#include "BKE_global.h"
+#include "WM_api.h"
+
+#include <OpenGL/OpenGL.h>
+#define __CARBONSOUND__
+/* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */
+#define ID ID_
+#include <Carbon/Carbon.h>
+
+
+/* To avoid killing small end comps, we want to allow
+blender to start maximised if all the followings are true :
+- Renderer is OpenGL capable
+- Hardware acceleration
+- VRAM > 16 Mo
+
+ We will bail out if VRAM is less than 8Mo
+ */
+/* bad global, used in wm_window.c to open windows */
+int macPrefState = 0;
+
+static int checkAppleVideoCard(void)
+{
+ CGLRendererInfoObj rend;
+ long theErr;
+ unsigned long display_mask;
+ long nrend;
+ int j;
+ long value;
+ long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */
+
+ display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() );
+
+ theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend);
+ if (theErr == 0) {
+ theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend);
+ if (theErr == 0) {
+ for (j = 0; j < nrend; j++) {
+ theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value);
+ if (value > maxvram)
+ maxvram = value;
+ if ((theErr == 0) && (value >= 20000000)) {
+ theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value);
+ if ((theErr == 0) && (value != 0)) {
+ theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value);
+ if ((theErr == 0) && (value != 0)) {
+ /*fprintf(stderr,"make it big\n");*/
+ CGLDestroyRendererInfo (rend);
+ macPrefState = 8;
+ return 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (maxvram < 7500000 ) { /* put a standard alert and quit*/
+ SInt16 junkHit;
+ char inError[] = "* Not enough VRAM ";
+ char inText[] = "* blender needs at least 8Mb ";
+ inError[0] = 16;
+ inText[0] = 28;
+
+ fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
+ StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit);
+ abort();
+ }
+CGLDestroyRendererInfo (rend);
+return 0;
+}
+
+static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right)
+{
+ Rect outAvailableRect;
+
+ GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
+
+ *top = outAvailableRect.top;
+ *left = outAvailableRect.left;
+ *bottom = outAvailableRect.bottom;
+ *right = outAvailableRect.right;
+}
+
+
+void wm_set_apple_prefsize(int scr_x, int scr_y)
+{
+
+ /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */
+
+ if (checkAppleVideoCard()) {
+ short top, left, bottom, right;
+
+ getMacAvailableBounds(&top, &left, &bottom, &right);
+ WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
+ G.windowstate= 0;
+
+ } else {
+
+ /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
+ WM_setprefsize(120, 40, 850, 684);
+ G.windowstate= 0;
+ }
+}
+
+
+#endif /* __APPLE__ */
+
+
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
new file mode 100644
index 00000000000..8c86070ca61
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -0,0 +1,879 @@
+/**
+* $Id: wm_cursors.c
+*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*
+* The Original Code is Copyright (C) 2005-2007 Blender Foundation
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): Matt Ebb
+*
+* ***** END GPL/BL DUAL LICENSE BLOCK *****
+*/
+
+#include <stdio.h>
+
+#include "GHOST_C-api.h"
+
+#include "DNA_listBase.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_global.h"
+
+#include "WM_api.h"
+#include "wm_cursors.h"
+
+/* XXX this still is mess from old code */
+
+
+
+/* Some simple ghost <-> blender conversions */
+static GHOST_TStandardCursor convert_cursor(int curs)
+{
+ switch(curs) {
+ default:
+ case CURSOR_STD: return GHOST_kStandardCursorDefault;
+ case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow;
+ case CURSOR_WAIT: return GHOST_kStandardCursorWait;
+ case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair;
+ case CURSOR_HELP: return GHOST_kStandardCursorHelp;
+ case CURSOR_X_MOVE: return GHOST_kStandardCursorLeftRight;
+ case CURSOR_Y_MOVE: return GHOST_kStandardCursorUpDown;
+ case CURSOR_PENCIL: return GHOST_kStandardCursorPencil;
+ }
+}
+
+void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2],
+ unsigned char bitmap[16][2], int hotx, int hoty)
+{
+ GHOST_SetCustomCursorShape(win->ghostwin, bitmap, mask, hotx, hoty);
+}
+
+static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useBig)
+{
+ if (useBig) {
+ GHOST_SetCustomCursorShapeEx(win->ghostwin,
+ (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask,
+ cursor->big_sizex,cursor->big_sizey,
+ cursor->big_hotx,cursor->big_hoty,
+ cursor->fg_color, cursor->bg_color);
+ } else {
+ GHOST_SetCustomCursorShapeEx(win->ghostwin,
+ (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask,
+ cursor->small_sizex,cursor->small_sizey,
+ cursor->small_hotx,cursor->small_hoty,
+ cursor->fg_color, cursor->bg_color);
+ }
+}
+
+
+/* Cursor Globals */
+static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs */
+static short CurrentCursor=-1, LastCursor=-1;
+
+void WM_set_cursor(bContext *C, int curs)
+{
+ wmWindow *win= C->window;
+
+ if (win==NULL) return; /* Can't set custom cursor before Window init */
+ win->cursor= curs;
+
+ if (curs==CURSOR_NONE) {
+ GHOST_SetCursorVisibility(win->ghostwin, 0);
+ return;
+ }
+
+ GHOST_SetCursorVisibility(win->ghostwin, 1);
+
+ /* detect if we use system cursor or Blender cursor */
+ if(curs>=BC_GHOST_CURSORS) {
+ GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs));
+ return;
+ }
+
+ if ((curs<LASTCURSOR)||(curs>=BC_NUMCURSORS)) return;
+
+
+ LastCursor=CurrentCursor;
+ CurrentCursor=curs;
+
+ if (curs==LASTCURSOR) curs=LastCursor;
+
+ if (curs==SYSCURSOR) { /* System default Cursor */
+ GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD));
+ }
+ else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) {
+ window_set_custom_cursor_ex(win, BlenderCursor[curs], 0);
+ }
+ else {
+ window_set_custom_cursor_ex(win, BlenderCursor[curs], 1);
+ }
+}
+
+/* ******************************************************************
+Custom Cursor Description:
+
+Each bit represents a pixel, so 1 byte = 8 pixels,
+the bytes go Left to Right. Top to bottom
+the bits in a byte go right to left
+(ie; 0x01, 0x80 represents a line of 16 pix with the first and last pix set.)
+
+A 0 in the bitmap = bg_color, a 1 fg_color
+a 0 in the mask = transparent pix.
+
+Until 32x32 cursors are supported on all platforms, the size of the
+small cursors MUST be 16x16.
+
+Large cursors have a MAXSIZE of 32x32.
+
+Other than that, the specified size of the cursors is just a guideline,
+However, the char array that defines the BM and MASK must be byte aligned.
+ie a 17x17 cursor needs 3 bytes (cols) * 17 bytes (rows)
+(3 bytes = 17 bits rounded up to nearest whole byte). Pad extra bits
+in mask with 0's.
+
+Setting big_bm=NULL disables the large version of the cursor.
+
+*******************************************************************
+
+There is a nice Python GUI utility that can be used for drawing cursors in
+this format in the Blender source distribution, in
+blender/source/tools/MakeCursor.py . Start it with $ python MakeCursor.py
+It will copy its output to the console when you press 'Do it'.
+
+*/
+
+/* Because defining a cursor mixes declarations and executable code
+each cursor needs it's own scoping block or it would be split up
+over several hundred lines of code. To enforce/document this better
+I define 2 pretty braindead macros so it's obvious what the extra "[]"
+are for */
+
+#define BEGIN_CURSOR_BLOCK {
+#define END_CURSOR_BLOCK }
+
+void WM_init_cursor_data(void){
+
+ /********************** NW_ARROW Cursor **************************/
+BEGIN_CURSOR_BLOCK
+ static char nw_sbm[]={
+ 0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00,
+ 0x21, 0x00, 0x41, 0x00, 0x81, 0x00, 0x01, 0x01,
+ 0x01, 0x02, 0xc1, 0x03, 0x49, 0x00, 0x8d, 0x00,
+ 0x8b, 0x00, 0x10, 0x01, 0x90, 0x01, 0x60, 0x00,
+ };
+
+ static char nw_smsk[]={
+ 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00,
+ 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01,
+ 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xff, 0x00,
+ 0xfb, 0x00, 0xf0, 0x01, 0xf0, 0x01, 0x60, 0x00,
+ };
+
+ static BCursor NWArrowCursor = {
+ /*small*/
+ nw_sbm, nw_smsk,
+ 16, 16,
+ 6, 7,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_NW_ARROWCURSOR]=&NWArrowCursor;
+END_CURSOR_BLOCK
+
+ ///********************** NS_ARROW Cursor *************************/
+BEGIN_CURSOR_BLOCK
+ static char ns_sbm[]={
+ 0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0x08,
+ 0x04, 0x10, 0x3c, 0x1e, 0x20, 0x02, 0x20, 0x02,
+ 0x20, 0x02, 0x20, 0x02, 0x3c, 0x1e, 0x04, 0x10,
+ 0x08, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01
+ };
+
+ static char ns_smsk[]={
+ 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f,
+ 0xfc, 0x1f, 0xfc, 0x1f, 0xe0, 0x03, 0xe0, 0x03,
+ 0xe0, 0x03, 0xe0, 0x03, 0xfc, 0x1f, 0xfc, 0x1f,
+ 0xf8, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01
+ };
+
+ static BCursor NSArrowCursor = {
+ /*small*/
+ ns_sbm, ns_smsk,
+ 16, 16,
+ 6, 7,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_NS_ARROWCURSOR]=&NSArrowCursor;
+
+END_CURSOR_BLOCK
+ /********************** EW_ARROW Cursor *************************/
+BEGIN_CURSOR_BLOCK
+ static char ew_sbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c,
+ 0x2c, 0x34, 0xe6, 0x67, 0x03, 0xc0, 0x01, 0x80,
+ 0x03, 0xc0, 0xe6, 0x67, 0x2c, 0x34, 0x38, 0x1c,
+ 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ static char ew_smsk[]={
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c,
+ 0x3c, 0x3c, 0xfe, 0x7f, 0xff, 0xff, 0x3f, 0xfc,
+ 0xff, 0xff, 0xfe, 0x7f, 0x3c, 0x3c, 0x38, 0x1c,
+ 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ static BCursor EWArrowCursor = {
+ /*small*/
+ ew_sbm, ew_smsk,
+ 16, 16,
+ 7, 6,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_EW_ARROWCURSOR]=&EWArrowCursor;
+END_CURSOR_BLOCK
+
+ /********************** Wait Cursor *****************************/
+BEGIN_CURSOR_BLOCK
+ static char wait_sbm[]={
+ 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x84, 0x21,
+ 0xc8, 0x13, 0xd0, 0x0b, 0xa0, 0x04, 0x20, 0x05,
+ 0xa0, 0x04, 0x10, 0x09, 0x88, 0x11, 0xc4, 0x23,
+ 0xe2, 0x47, 0xfa, 0x5f, 0x02, 0x40, 0xfe, 0x7f,
+ };
+
+ static char wait_smsk[]={
+ 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x8c, 0x31,
+ 0xd8, 0x1b, 0xf0, 0x0f, 0xe0, 0x06, 0x60, 0x07,
+ 0xe0, 0x06, 0x30, 0x0d, 0x98, 0x19, 0xcc, 0x33,
+ 0xe6, 0x67, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
+ };
+
+ static char wait_lbm[]={
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30,
+ 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x18,
+ 0x18, 0xc0, 0x03, 0x0c, 0x30, 0x20, 0x07, 0x06,
+ 0x60, 0xf0, 0x0f, 0x03, 0xc0, 0xd0, 0x8d, 0x01,
+ 0x80, 0x79, 0xcf, 0x00, 0x00, 0xf3, 0x67, 0x00,
+ 0x00, 0x66, 0x37, 0x00, 0x00, 0x8c, 0x33, 0x00,
+ 0x00, 0x0c, 0x32, 0x00, 0x00, 0xcc, 0x33, 0x00,
+ 0x00, 0x8c, 0x30, 0x00, 0x00, 0x46, 0x61, 0x00,
+ 0x00, 0x03, 0xc3, 0x00, 0x80, 0x01, 0x83, 0x01,
+ 0xc0, 0xc0, 0x03, 0x03, 0x60, 0xa0, 0x05, 0x06,
+ 0x30, 0xf0, 0x0f, 0x0c, 0x18, 0xf8, 0x1d, 0x18,
+ 0x0c, 0x5c, 0x3f, 0x30, 0x0c, 0xff, 0x5f, 0x30,
+ 0x0c, 0xf7, 0xfe, 0x31, 0xcc, 0xfb, 0x9f, 0x33,
+ 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30,
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ };
+
+ static char wait_lmsk[]={
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ 0x3c, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x1e,
+ 0x78, 0xc0, 0x03, 0x0f, 0xf0, 0xa0, 0x87, 0x07,
+ 0xe0, 0xf1, 0xcf, 0x03, 0xc0, 0xf3, 0xef, 0x01,
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
+ 0x00, 0x3c, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
+ 0x00, 0xbc, 0x3c, 0x00, 0x00, 0xde, 0x79, 0x00,
+ 0x00, 0x0f, 0xf3, 0x00, 0x80, 0x07, 0xe3, 0x01,
+ 0xc0, 0xc3, 0xc3, 0x03, 0xe0, 0xe1, 0x87, 0x07,
+ 0xf0, 0xf0, 0x0f, 0x0f, 0x78, 0xf8, 0x1f, 0x1e,
+ 0x3c, 0x7c, 0x3f, 0x3c, 0x3c, 0xff, 0x7f, 0x3c,
+ 0xbc, 0xff, 0xff, 0x3d, 0xfc, 0xfb, 0xbf, 0x3f,
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
+ };
+
+ static BCursor WaitCursor = {
+ /*small*/
+ wait_sbm, wait_smsk,
+ 16, 16,
+ 7, 7,
+ /*big*/
+ wait_lbm, wait_lmsk,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_WAITCURSOR]=&WaitCursor;
+END_CURSOR_BLOCK
+
+ /********************** Cross Cursor ***************************/
+BEGIN_CURSOR_BLOCK
+ static char cross_sbm[]={
+ 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x7e, 0x7e,
+ 0x7e, 0x7e, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00,
+ };
+
+ static char cross_smsk[]={
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
+ 0x80, 0x01, 0x80, 0x01, 0xc0, 0x03, 0x7f, 0xfe,
+ 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
+ };
+ static char cross_lbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x78, 0x1e, 0x00, 0xfc, 0x1f, 0xf8, 0x3f,
+ 0xfc, 0x1f, 0xf8, 0x3f, 0x00, 0x78, 0x1e, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0xc0, 0x03, 0x00,
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ static char cross_lmsk[]={
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0x70, 0x0e, 0x00,
+ 0x00, 0x78, 0x1e, 0x00, 0xff, 0x1f, 0xf8, 0xff,
+ 0xff, 0x1f, 0xf8, 0xff, 0x00, 0x78, 0x1e, 0x00,
+ 0x00, 0x70, 0x0e, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ };
+
+ static BCursor CrossCursor = {
+ /*small*/
+ cross_sbm, cross_smsk,
+ 16, 16,
+ 7, 7,
+ /*big*/
+ cross_lbm, cross_lmsk,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_CROSSCURSOR]=&CrossCursor;
+END_CURSOR_BLOCK
+
+ /********************** EditCross Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+ static char editcross_sbm[]={
+ 0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03,
+ 0x1d, 0x03, 0x11, 0x03, 0x0e, 0x03, 0x00, 0x03,
+ 0xf8, 0x7c, 0xf8, 0x7c, 0x00, 0x03, 0x00, 0x03,
+ 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00,
+ };
+
+ static char editcross_smsk[]={
+ 0x0e, 0x00, 0x1f, 0x00, 0x1f, 0x03, 0x1f, 0x03,
+ 0x1f, 0x03, 0x1f, 0x03, 0x0e, 0x03, 0x80, 0x07,
+ 0xfc, 0xfc, 0xfc, 0xfc, 0x80, 0x07, 0x00, 0x03,
+ 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
+ };
+
+ static BCursor EditCrossCursor = {
+ /*small*/
+ editcross_sbm, editcross_smsk,
+ 16, 16,
+ 9, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_EDITCROSSCURSOR]=&EditCrossCursor;
+END_CURSOR_BLOCK
+
+ /********************** Box Select *************************/
+BEGIN_CURSOR_BLOCK
+ static char box_sbm[32]={
+ 0x7f, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x06,
+ 0x41, 0x06, 0x41, 0x06, 0x7f, 0x06, 0x00, 0x06,
+ 0xe0, 0x79, 0xe0, 0x79, 0x00, 0x06, 0x00, 0x06,
+ 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
+ };
+
+ static char box_smsk[32]={
+ 0x7f, 0x00, 0x7f, 0x00, 0x63, 0x06, 0x63, 0x06,
+ 0x63, 0x06, 0x7f, 0x06, 0x7f, 0x06, 0x00, 0x0f,
+ 0xf0, 0xf9, 0xf0, 0xf9, 0x00, 0x0f, 0x00, 0x06,
+ 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06,
+
+ };
+
+ static BCursor BoxSelCursor = {
+ /*small*/
+ box_sbm, box_smsk,
+ 16, 16,
+ 9, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_BOXSELCURSOR]=&BoxSelCursor;
+
+END_CURSOR_BLOCK
+ /********************** Knife Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+ static char knife_sbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x2c,
+ 0x00, 0x5a, 0x00, 0x34, 0x00, 0x2a, 0x00, 0x17,
+ 0x80, 0x06, 0x40, 0x03, 0xa0, 0x03, 0xd0, 0x01,
+ 0x68, 0x00, 0x1c, 0x00, 0x06, 0x00, 0x00, 0x00
+ };
+
+ static char knife_smsk[]={
+ 0x00, 0x60, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0xfe,
+ 0x00, 0xfe, 0x00, 0x7e, 0x00, 0x7f, 0x80, 0x3f,
+ 0xc0, 0x0e, 0x60, 0x07, 0xb0, 0x07, 0xd8, 0x03,
+ 0xec, 0x01, 0x7e, 0x00, 0x1f, 0x00, 0x07, 0x00
+ };
+
+ static char knife_lbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c,
+ 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7f,
+ 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0xc0, 0x5f,
+ 0x00, 0x00, 0xc0, 0x6f, 0x00, 0x00, 0xc0, 0x37,
+ 0x00, 0x00, 0xa8, 0x1b, 0x00, 0x00, 0x54, 0x0d,
+ 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x54, 0x00,
+ 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x53, 0x00,
+ 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0xd0, 0x0f, 0x00, 0x00, 0xe8, 0x07, 0x00,
+ 0x00, 0xf4, 0x07, 0x00, 0x00, 0xfa, 0x00, 0x00,
+ 0x00, 0x3d, 0x00, 0x00, 0x80, 0x0e, 0x00, 0x00,
+ 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00,
+ 0x30, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ };
+
+ static char knife_lmsk[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x7e,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x80, 0xff,
+ 0x00, 0x00, 0xc0, 0xbf, 0x00, 0x00, 0xe0, 0xdf,
+ 0x00, 0x00, 0xe0, 0xef, 0x00, 0x00, 0xf8, 0x77,
+ 0x00, 0x00, 0xfc, 0x3b, 0x00, 0x00, 0xfe, 0x1d,
+ 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0xfe, 0x01,
+ 0x00, 0x00, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00,
+ 0x00, 0xe0, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0x00,
+ 0x00, 0xd8, 0x1f, 0x00, 0x00, 0xec, 0x0f, 0x00,
+ 0x00, 0xf6, 0x0f, 0x00, 0x00, 0xfb, 0x06, 0x00,
+ 0x80, 0xbd, 0x01, 0x00, 0xc0, 0x6e, 0x00, 0x00,
+ 0xe0, 0x1b, 0x00, 0x00, 0xf0, 0x06, 0x00, 0x00,
+ 0xb8, 0x01, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ };
+
+ static BCursor KnifeCursor = {
+ /*small*/
+ knife_sbm, knife_smsk,
+ 16, 16,
+ 0, 15,
+ /*big*/
+ knife_lbm, knife_lmsk,
+ 32,32,
+ 0, 31,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_KNIFECURSOR]=&KnifeCursor;
+
+END_CURSOR_BLOCK
+
+ /********************** Loop Select Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char vloop_sbm[]={
+ 0x00, 0x00, 0x7e, 0x00, 0x3e, 0x00, 0x1e, 0x00,
+ 0x0e, 0x00, 0x66, 0x60, 0x62, 0x6f, 0x00, 0x00,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x00, 0x00, 0x60, 0x60, 0x60, 0x6f, 0x00, 0x00,
+};
+
+static char vloop_smsk[]={
+ 0xff, 0x01, 0xff, 0x00, 0x7f, 0x00, 0x3f, 0x00,
+ 0xff, 0xf0, 0xff, 0xff, 0xf7, 0xff, 0xf3, 0xf0,
+ 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
+ 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xf0,
+};
+
+
+
+static char vloop_lbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00,
+ 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00,
+ 0xfc, 0x03, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00,
+ 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00,
+ 0x3c, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x00, 0x3c,
+ 0x0c, 0x3c, 0xff, 0x3c, 0x0c, 0x3c, 0xff, 0x3c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c,
+ 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c,
+ 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c,
+ 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c,
+ 0x00, 0x3c, 0xff, 0x3c, 0x00, 0x3c, 0xff, 0x3c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static char vloop_lmsk[]={
+ 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00,
+ 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+ 0xff, 0x3f, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00,
+ 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff,
+ 0x0f, 0xff, 0x00, 0xff, 0x0f, 0xff, 0x00, 0xff,
+ 0x03, 0x3c, 0x00, 0x3c, 0x03, 0x3c, 0x00, 0x3c,
+ 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c,
+ 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c,
+ 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
+};
+
+
+
+ static BCursor VLoopCursor = {
+ /*small*/
+ vloop_sbm, vloop_smsk,
+ 16, 16,
+ 0, 0,
+ /*big*/
+ vloop_lbm, vloop_lmsk,
+ 32,32,
+ 0, 0,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_VLOOPCURSOR]=&VLoopCursor;
+
+END_CURSOR_BLOCK
+
+
+ /********************** TextEdit Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+ static char textedit_sbm[]={
+ 0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x60, 0x03, 0x10, 0x04, 0xe0, 0x03,
+ };
+
+ static char textedit_smsk[]={
+ 0xe0, 0x03, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xe0, 0x03,
+ };
+
+ static BCursor TextEditCursor = {
+ /*small*/
+ textedit_sbm, textedit_smsk,
+ 16, 16,
+ 9, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_TEXTEDITCURSOR]=&TextEditCursor;
+END_CURSOR_BLOCK
+
+
+ /********************** Paintbrush Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+ static char paintbrush_sbm[]={
+
+ 0x00, 0xe0, 0x00, 0x98, 0x00, 0x44, 0x00, 0x42,
+ 0x00, 0x21, 0x80, 0x20, 0x40, 0x13, 0x40, 0x17,
+ 0xa0, 0x0b, 0x98, 0x05, 0x04, 0x02, 0x02, 0x01,
+ 0x02, 0x01, 0x02, 0x01, 0x81, 0x00, 0x7f, 0x00,
+
+
+
+ };
+
+ static char paintbrush_smsk[]={
+ 0x00, 0xe0, 0x00, 0xf8, 0x00, 0x7c, 0x00, 0x7e,
+ 0x00, 0x3f, 0x80, 0x3f, 0xc0, 0x1f, 0xc0, 0x1f,
+ 0xe0, 0x0f, 0xf8, 0x07, 0xfc, 0x03, 0xfe, 0x01,
+ 0xfe, 0x01, 0xfe, 0x01, 0xff, 0x00, 0x7f, 0x00,
+
+
+ };
+
+ static BCursor PaintBrushCursor = {
+ /*small*/
+ paintbrush_sbm, paintbrush_smsk,
+ 16, 16,
+ 0, 15,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+ };
+
+ BlenderCursor[BC_PAINTBRUSHCURSOR]=&PaintBrushCursor;
+END_CURSOR_BLOCK
+
+
+/********************** Hand Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char hand_sbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x0d,
+ 0x98, 0x6d, 0x98, 0x6d, 0xb0, 0x6d, 0xb0, 0x6d,
+ 0xe0, 0x6f, 0xe6, 0x7f, 0xee, 0x7f, 0xfc, 0x3f,
+ 0xf8, 0x3f, 0xf0, 0x1f, 0xc0, 0x1f, 0xc0, 0x1f,
+};
+
+static char hand_smsk[]={
+ 0x00, 0x00, 0x80, 0x01, 0xc0, 0x0f, 0xd8, 0x7f,
+ 0xfc, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xf8, 0xff,
+ 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f,
+ 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x3f, 0xe0, 0x3f,
+};
+
+
+static BCursor HandCursor = {
+ /*small*/
+ hand_sbm, hand_smsk,
+ 16, 16,
+ 8, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+};
+
+BlenderCursor[BC_HANDCURSOR]=&HandCursor;
+
+END_CURSOR_BLOCK
+
+/********************** NSEW Scroll Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char nsewscroll_sbm[]={
+ 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70,
+ 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
+};
+
+static char nsewscroll_smsk[]={
+ 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07,
+ 0xc0, 0x03, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8,
+ 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0xc0, 0x03,
+ 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01,
+};
+
+
+static BCursor NSEWScrollCursor = {
+ /*small*/
+ nsewscroll_sbm, nsewscroll_smsk,
+ 16, 16,
+ 8, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+};
+
+BlenderCursor[BC_NSEW_SCROLLCURSOR]=&NSEWScrollCursor;
+
+END_CURSOR_BLOCK
+
+
+/********************** NS Scroll Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char nsscroll_sbm[]={
+ 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
+};
+
+static char nsscroll_smsk[]={
+ 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03,
+ 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01,
+};
+
+
+static BCursor NSScrollCursor = {
+ /*small*/
+ nsscroll_sbm, nsscroll_smsk,
+ 16, 16,
+ 8, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+};
+
+BlenderCursor[BC_NS_SCROLLCURSOR]=&NSScrollCursor;
+
+END_CURSOR_BLOCK
+
+
+/********************** EW Scroll Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char ewscroll_sbm[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70,
+ 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static char ewscroll_smsk[]={
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8,
+ 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+
+static BCursor EWScrollCursor = {
+ /*small*/
+ ewscroll_sbm, ewscroll_smsk,
+ 16, 16,
+ 8, 8,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+};
+
+BlenderCursor[BC_EW_SCROLLCURSOR]=&EWScrollCursor;
+
+END_CURSOR_BLOCK
+
+/********************** Eyedropper Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+static char eyedropper_sbm[]={
+ 0x00, 0x30, 0x00, 0x48, 0x00, 0x85, 0x80, 0x82,
+ 0x40, 0x40, 0x80, 0x20, 0x40, 0x11, 0xa0, 0x23,
+ 0xd0, 0x15, 0xe8, 0x0a, 0x74, 0x01, 0xb4, 0x00,
+ 0x4a, 0x00, 0x35, 0x00, 0x08, 0x00, 0x04, 0x00,
+};
+
+static char eyedropper_smsk[]={
+ 0x00, 0x30, 0x00, 0x78, 0x00, 0xfd, 0x80, 0xff,
+ 0xc0, 0x7f, 0x80, 0x3f, 0xc0, 0x1f, 0xe0, 0x3f,
+ 0xf0, 0x1f, 0xf8, 0x0b, 0xfc, 0x01, 0xfc, 0x00,
+ 0x7e, 0x00, 0x3f, 0x00, 0x0c, 0x00, 0x04, 0x00,
+};
+
+
+static BCursor EyedropperCursor = {
+ /*small*/
+ eyedropper_sbm, eyedropper_smsk,
+ 16, 16,
+ 1, 15,
+ /*big*/
+ NULL, NULL,
+ 32,32,
+ 15, 15,
+ /*color*/
+ BC_BLACK, BC_WHITE
+};
+
+BlenderCursor[BC_EYEDROPPER_CURSOR]=&EyedropperCursor;
+
+END_CURSOR_BLOCK
+
+/********************** Put the cursors in the array ***********************/
+
+
+
+}
+
+
+
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
new file mode 100644
index 00000000000..782c1325e2f
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -0,0 +1,470 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "DNA_listBase.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+#include "DNA_userdef_types.h" /* U.flag & TWOBUTTONMOUSE */
+
+#include "MEM_guardedalloc.h"
+
+#include "GHOST_C-api.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+#include "wm_event_types.h"
+
+/* ************ event management ************** */
+
+static void wm_event_add(wmWindow *win, wmEvent *event_to_add)
+{
+ wmEvent *event= MEM_callocN(sizeof(wmEvent), "event");
+
+ *event= *event_to_add;
+ BLI_addtail(&win->queue, event);
+}
+
+wmEvent *wm_event_next(wmWindow *win)
+{
+ wmEvent *event= win->queue.first;
+
+ if(event) BLI_remlink(&win->queue, event);
+ return event;
+}
+
+static void wm_event_free(wmEvent *event)
+{
+ if(event->customdata) MEM_freeN(event->customdata);
+ MEM_freeN(event);
+}
+
+void wm_event_free_all(wmWindow *win)
+{
+ wmEvent *event;
+
+ while((event= win->queue.first)) {
+ BLI_remlink(&win->queue, event);
+ wm_event_free(event);
+ }
+}
+
+/* ********************* handlers *************** */
+
+void wm_event_free_handlers(ListBase *lb)
+{
+ wmEventHandler *handler;
+
+ for(handler= lb->first; handler; handler= handler->next) {
+ if(handler->op)
+ MEM_freeN(handler->op);
+ }
+ BLI_freelistN(lb);
+}
+
+static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *km)
+{
+ if(winevent->type!=km->type) return 0;
+
+ if(km->val) /* KM_PRESS, KM_RELEASE */
+ if(winevent->val!=km->val-1) return 0;
+
+ if(winevent->shift!=km->shift) return 0;
+ if(winevent->ctrl!=km->ctrl) return 0;
+ if(winevent->alt!=km->alt) return 0;
+ if(winevent->oskey!=km->oskey) return 0;
+ if(winevent->keymodifier!=km->keymodifier) return 0;
+
+ /* optional boundbox */
+
+ return 1;
+}
+
+static int wm_handler_operator_call(bContext *C, wmEventHandler *handler, wmEvent *event)
+{
+ int retval= 0;
+
+ /* derived, modal or blocking operator */
+ if(handler->op) {
+ if( handler->op->type->poll(C)) {
+ if(handler->op->type->interactive)
+ retval= handler->op->type->interactive(C, handler->op, event);
+ else
+ printf("wm_handler_operator_call error\n");
+ }
+ }
+ else {
+ wmOperatorType *ot= WM_operatortype_find(event->keymap_idname);
+ if(ot) {
+ if(ot->poll(C)) {
+ /* operator on stack, register or new modal handle malloc-copies */
+ wmOperator op;
+
+ memset(&op, 0, sizeof(wmOperator));
+ op.type= ot;
+
+ if(op.type->interactive)
+ retval= op.type->interactive(C, &op, event);
+ else if(&op.type->exec)
+ retval= op.type->exec(C, &op);
+
+ if( ot->flag & OPTYPE_REGISTER)
+ WM_operator_register(C->wm, &op);
+ }
+ }
+ }
+ if(retval)
+ return WM_HANDLER_BREAK;
+
+ return WM_HANDLER_CONTINUE;
+}
+
+static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+{
+ wmEventHandler *handler;
+ int action= WM_HANDLER_CONTINUE;
+
+ if(handlers==NULL) return action;
+
+ for(handler= handlers->first; handler; handler= handler->next) {
+ if(handler->keymap) {
+ wmKeymapItem *km;
+
+ for(km= handler->keymap->first; km; km= km->next) {
+ if(wm_eventmatch(event, km)) {
+
+ if(event->type!=MOUSEMOVE)
+ printf("handle evt %d win %d op %s\n", event->type, C->window->winid, km->idname);
+
+ event->keymap_idname= km->idname; /* weak, but allows interactive callback to not use rawkey */
+
+ action= wm_handler_operator_call(C, handler, event);
+ }
+ }
+ if(action==WM_HANDLER_BREAK)
+ break;
+ }
+ /* modal+blocking handler */
+ if(handler->flag & WM_HANDLER_BLOCKING)
+ action= WM_HANDLER_BREAK;
+ }
+ return action;
+}
+
+static int wm_event_inside_i(wmEvent *event, rcti *rect)
+{
+ return BLI_in_rcti(rect, event->x, event->y);
+}
+//static int wm_event_inside_f(wmEvent *event, rctf *rect)
+//{
+// return BLI_in_rctf(rect, (float)event->x, (float)event->y);
+//}
+
+/* called in main loop */
+/* goes over entire hierarchy: events -> window -> screen -> area -> region */
+void wm_event_do_handlers(bContext *C)
+{
+ wmWindow *win;
+
+ for(win= C->wm->windows.first; win; win= win->next) {
+ wmEvent *event;
+
+ /* MVC demands to not draw in event handlers... for now we leave it */
+ /* it also updates context (win, screen) */
+ wm_window_make_drawable(C, win);
+
+ if( C->screen==NULL )
+ wm_event_free_all(C->window);
+
+ while( (event=wm_event_next(C->window)) ) {
+ int action= wm_handlers_do(C, event, &C->window->handlers);
+
+ if(action==WM_HANDLER_CONTINUE)
+ action= wm_handlers_do(C, event, &C->screen->handlers);
+
+ if(action==WM_HANDLER_CONTINUE) {
+ ScrArea *sa= C->screen->areabase.first;
+
+ for(; sa; sa= sa->next) {
+ if(wm_event_inside_i(event, &sa->winrct)) {
+
+ C->curarea= sa;
+ action= wm_handlers_do(C, event, &sa->handlers);
+ if(action==WM_HANDLER_CONTINUE) {
+ ARegion *ar= sa->regionbase.first;
+
+ for(; ar; ar= ar->next) {
+ if(wm_event_inside_i(event, &ar->winrct)) {
+ C->region= ar;
+ action= wm_handlers_do(C, event, &ar->handlers);
+ if(action==WM_HANDLER_BREAK)
+ break;
+ }
+ }
+ }
+ if(action==WM_HANDLER_BREAK)
+ break;
+ }
+ }
+ }
+ wm_event_free(event);
+ }
+ }
+}
+
+/* lets not expose struct outside wm? */
+void WM_event_set_handler_flag(wmEventHandler *handler, int flag)
+{
+ handler->flag= flag;
+}
+
+wmEventHandler *WM_event_add_modal_keymap_handler(ListBase *keymap, ListBase *handlers, wmOperator *op)
+{
+ /* debug test; operator not in registry */
+ if(op->type->flag & OPTYPE_REGISTER) {
+ printf("error: handler (%s) cannot be modal, was registered\n", op->type->idname);
+ }
+ else {
+ wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event handler");
+ wmOperator *opc= MEM_mallocN(sizeof(wmOperator), "operator modal");
+
+ BLI_addtail(handlers, handler);
+ handler->keymap= keymap;
+ *opc= *op;
+ handler->op= opc;
+
+ return handler;
+ }
+ return NULL;
+}
+
+wmEventHandler *WM_event_add_keymap_handler(ListBase *keymap, ListBase *handlers)
+{
+ wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event handler");
+
+ BLI_addtail(handlers, handler);
+ handler->keymap= keymap;
+
+ return handler;
+}
+
+/* ********************* ghost stuff *************** */
+
+static int convert_key(GHOST_TKey key)
+{
+ if (key>=GHOST_kKeyA && key<=GHOST_kKeyZ) {
+ return (AKEY + ((int) key - GHOST_kKeyA));
+ } else if (key>=GHOST_kKey0 && key<=GHOST_kKey9) {
+ return (ZEROKEY + ((int) key - GHOST_kKey0));
+ } else if (key>=GHOST_kKeyNumpad0 && key<=GHOST_kKeyNumpad9) {
+ return (PAD0 + ((int) key - GHOST_kKeyNumpad0));
+ } else if (key>=GHOST_kKeyF1 && key<=GHOST_kKeyF12) {
+ return (F1KEY + ((int) key - GHOST_kKeyF1));
+ } else {
+ switch (key) {
+ case GHOST_kKeyBackSpace: return BACKSPACEKEY;
+ case GHOST_kKeyTab: return TABKEY;
+ case GHOST_kKeyLinefeed: return LINEFEEDKEY;
+ case GHOST_kKeyClear: return 0;
+ case GHOST_kKeyEnter: return RETKEY;
+
+ case GHOST_kKeyEsc: return ESCKEY;
+ case GHOST_kKeySpace: return SPACEKEY;
+ case GHOST_kKeyQuote: return QUOTEKEY;
+ case GHOST_kKeyComma: return COMMAKEY;
+ case GHOST_kKeyMinus: return MINUSKEY;
+ case GHOST_kKeyPeriod: return PERIODKEY;
+ case GHOST_kKeySlash: return SLASHKEY;
+
+ case GHOST_kKeySemicolon: return SEMICOLONKEY;
+ case GHOST_kKeyEqual: return EQUALKEY;
+
+ case GHOST_kKeyLeftBracket: return LEFTBRACKETKEY;
+ case GHOST_kKeyRightBracket: return RIGHTBRACKETKEY;
+ case GHOST_kKeyBackslash: return BACKSLASHKEY;
+ case GHOST_kKeyAccentGrave: return ACCENTGRAVEKEY;
+
+ case GHOST_kKeyLeftShift: return LEFTSHIFTKEY;
+ case GHOST_kKeyRightShift: return RIGHTSHIFTKEY;
+ case GHOST_kKeyLeftControl: return LEFTCTRLKEY;
+ case GHOST_kKeyRightControl: return RIGHTCTRLKEY;
+ case GHOST_kKeyCommand: return COMMANDKEY;
+ case GHOST_kKeyLeftAlt: return LEFTALTKEY;
+ case GHOST_kKeyRightAlt: return RIGHTALTKEY;
+
+ case GHOST_kKeyCapsLock: return CAPSLOCKKEY;
+ case GHOST_kKeyNumLock: return 0;
+ case GHOST_kKeyScrollLock: return 0;
+
+ case GHOST_kKeyLeftArrow: return LEFTARROWKEY;
+ case GHOST_kKeyRightArrow: return RIGHTARROWKEY;
+ case GHOST_kKeyUpArrow: return UPARROWKEY;
+ case GHOST_kKeyDownArrow: return DOWNARROWKEY;
+
+ case GHOST_kKeyPrintScreen: return 0;
+ case GHOST_kKeyPause: return PAUSEKEY;
+
+ case GHOST_kKeyInsert: return INSERTKEY;
+ case GHOST_kKeyDelete: return DELKEY;
+ case GHOST_kKeyHome: return HOMEKEY;
+ case GHOST_kKeyEnd: return ENDKEY;
+ case GHOST_kKeyUpPage: return PAGEUPKEY;
+ case GHOST_kKeyDownPage: return PAGEDOWNKEY;
+
+ case GHOST_kKeyNumpadPeriod: return PADPERIOD;
+ case GHOST_kKeyNumpadEnter: return PADENTER;
+ case GHOST_kKeyNumpadPlus: return PADPLUSKEY;
+ case GHOST_kKeyNumpadMinus: return PADMINUS;
+ case GHOST_kKeyNumpadAsterisk: return PADASTERKEY;
+ case GHOST_kKeyNumpadSlash: return PADSLASHKEY;
+
+ case GHOST_kKeyGrLess: return GRLESSKEY;
+
+ default:
+ return UNKNOWNKEY; /* GHOST_kKeyUnknown */
+ }
+ }
+}
+
+/* adds customdata to event */
+static void update_tablet_data(wmWindow *win, wmEvent *event)
+{
+ const GHOST_TabletData *td= GHOST_GetTabletData(win->ghostwin);
+
+ /* if there's tablet data from an active tablet device then add it */
+ if ((td != NULL) && td->Active) {
+ struct wmTabletData *wmtab= MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
+
+ wmtab->Active = td->Active;
+ wmtab->Pressure = td->Pressure;
+ wmtab->Xtilt = td->Xtilt;
+ wmtab->Ytilt = td->Ytilt;
+
+ event->custom= EVT_TABLET;
+ event->customdata= wmtab;
+ }
+}
+
+
+/* windows store own event queues, no bContext here */
+void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
+{
+ wmEvent event, *evt= win->eventstate;
+
+ /* initialize and copy state (only mouse x y and modifiers) */
+ event= *evt;
+
+ switch (type) {
+ /* mouse move */
+ case GHOST_kEventCursorMove: {
+ if(win->active) {
+ GHOST_TEventCursorData *cd= customdata;
+ int cx, cy;
+
+ GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
+
+ event.type= MOUSEMOVE;
+ event.x= evt->x= cx;
+ event.y= evt->y= (win->sizey-1) - cy;
+
+ update_tablet_data(win, &event);
+ wm_event_add(win, &event);
+ }
+ break;
+ }
+ /* mouse button */
+ case GHOST_kEventButtonDown:
+ case GHOST_kEventButtonUp: {
+ GHOST_TEventButtonData *bd= customdata;
+ event.val= (type==GHOST_kEventButtonDown);
+
+ if (bd->button == GHOST_kButtonMaskLeft)
+ event.type= LEFTMOUSE;
+ else if (bd->button == GHOST_kButtonMaskRight)
+ event.type= RIGHTMOUSE;
+ else
+ event.type= MIDDLEMOUSE;
+
+ update_tablet_data(win, &event);
+ wm_event_add(win, &event);
+
+ break;
+ }
+ /* keyboard */
+ case GHOST_kEventKeyDown:
+ case GHOST_kEventKeyUp: {
+ GHOST_TEventKeyData *kd= customdata;
+ event.type= convert_key(kd->key);
+ event.ascii= kd->ascii;
+ event.val= (type==GHOST_kEventKeyDown);
+
+ /* modifiers */
+ if (event.type==LEFTSHIFTKEY || event.type==RIGHTSHIFTKEY) {
+ event.shift= evt->shift= event.val;
+ } else if (event.type==LEFTCTRLKEY || event.type==RIGHTCTRLKEY) {
+ event.ctrl= evt->ctrl= event.val;
+ } else if (event.type==LEFTALTKEY || event.type==RIGHTALTKEY) {
+ event.alt= evt->alt= event.val;
+ } else if (event.type==COMMANDKEY) {
+ event.oskey= evt->oskey= event.val;
+ }
+
+ wm_event_add(win, &event);
+
+ break;
+ }
+
+ case GHOST_kEventWheel: {
+ GHOST_TEventWheelData* wheelData = customdata;
+
+ if (wheelData->z > 0)
+ event.type= WHEELUPMOUSE;
+ else
+ event.type= WHEELDOWNMOUSE;
+
+ event.val= wheelData->z; /* currently -1 or +1, see ghost for improvements here... */
+ wm_event_add(win, &event);
+
+ break;
+ }
+ case GHOST_kEventUnknown:
+ case GHOST_kNumEventTypes:
+ break;
+ }
+}
+
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
new file mode 100644
index 00000000000..20539e15bc0
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -0,0 +1,929 @@
+/**
+ * $Id: wm_files.c
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation 2007
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+ /* placed up here because of crappy
+ * winsock stuff.
+ */
+#include <stdio.h>
+#include <string.h>
+
+#ifdef WIN32
+#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
+#ifndef _WIN32_IE
+#define _WIN32_IE 0x0400 /* minimal requirements for SHGetSpecialFolderPath on MINGW MSVC has this defined already */
+#endif
+#include <shlobj.h> /* for SHGetSpecialFolderPath, has to be done before BLI_winstuff because 'near' is disabled through BLI_windstuff */
+#include "BLI_winstuff.h"
+#include <process.h> /* getpid */
+#else
+#include <unistd.h> /* getpid */
+#endif
+
+#include "MEM_guardedalloc.h"
+#include "MEM_CacheLimiterC-Api.h"
+
+#include "BIF_language.h"
+#ifdef INTERNATIONAL
+#include "FTF_Api.h"
+#endif
+
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
+
+#include "DNA_object_types.h"
+#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_exotic.h"
+#include "BKE_font.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_packedFile.h"
+#include "BKE_texture.h"
+#include "BKE_utildefines.h"
+
+#ifdef WITH_VERSE
+#include "BKE_verse.h"
+#endif
+
+#include "BIF_fsmenu.h"
+#include "BIF_interface.h"
+#include "BIF_usiblender.h" /* XXX */
+
+#include "BIF_editsound.h"
+#include "BIF_editmode_undo.h"
+#include "BIF_filelist.h"
+#include "BIF_resources.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+#include "BIF_toolbox.h"
+
+#ifdef WITH_VERSE
+#include "BIF_verse.h"
+#endif
+
+#include "BDR_editobject.h"
+
+#include "BLO_readfile.h"
+#include "BLO_writefile.h"
+
+// XXX #include "BPY_extern.h"
+
+#include "datatoc.h"
+
+#include "WM_api.h"
+#include "wm.h"
+
+/***/
+
+/* define for setting colors in theme below */
+#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a;
+
+/* patching UserDef struct and Themes */
+static void init_userdef_themes(void)
+{
+
+// XXX BIF_InitTheme(); // sets default again
+
+// countall();
+
+ /* the UserDef struct is not corrected with do_versions() .... ugh! */
+ if(U.wheellinescroll == 0) U.wheellinescroll = 3;
+ if(U.menuthreshold1==0) {
+ U.menuthreshold1= 5;
+ U.menuthreshold2= 2;
+ }
+ if(U.tb_leftmouse==0) {
+ U.tb_leftmouse= 5;
+ U.tb_rightmouse= 5;
+ }
+ if(U.mixbufsize==0) U.mixbufsize= 2048;
+ if (BLI_streq(U.tempdir, "/")) {
+ char *tmp= getenv("TEMP");
+
+ strcpy(U.tempdir, tmp?tmp:"/tmp/");
+ }
+ if (U.savetime <= 0) {
+ U.savetime = 1;
+// XXX error(".B.blend is buggy, please consider removing it.\n");
+ }
+ /* transform widget settings */
+ if(U.tw_hotspot==0) {
+ U.tw_hotspot= 14;
+ U.tw_size= 20; // percentage of window size
+ U.tw_handlesize= 16; // percentage of widget radius
+ }
+ if(U.pad_rot_angle==0)
+ U.pad_rot_angle= 15;
+
+ if(U.flag & USER_CUSTOM_RANGE)
+ vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
+
+ if (G.main->versionfile <= 191) {
+ strcpy(U.plugtexdir, U.textudir);
+ strcpy(U.sounddir, "/");
+ }
+
+ /* patch to set Dupli Armature */
+ if (G.main->versionfile < 220) {
+ U.dupflag |= USER_DUP_ARM;
+ }
+
+ /* userdef new option */
+ if (G.main->versionfile <= 222) {
+ U.vrmlflag= USER_VRML_LAYERS;
+ }
+
+ /* added seam, normal color, undo */
+ if (G.main->versionfile <= 234) {
+ bTheme *btheme;
+
+ U.uiflag |= USER_GLOBALUNDO;
+ if (U.undosteps==0) U.undosteps=32;
+
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->tv3d.edge_seam[3]==0) {
+ SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
+ }
+ if(btheme->tv3d.normal[3]==0) {
+ SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
+ }
+ if(btheme->tv3d.face_dot[3]==0) {
+ SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
+ btheme->tv3d.facedot_size= 4;
+ }
+ }
+ }
+ if (G.main->versionfile <= 235) {
+ /* illegal combo... */
+ if (U.flag & USER_LMOUSESELECT)
+ U.flag &= ~USER_TWOBUTTONMOUSE;
+ }
+ if (G.main->versionfile <= 236) {
+ bTheme *btheme;
+ /* new space type */
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->ttime.back[3]==0) {
+ btheme->ttime = btheme->tsnd; // copy from sound
+ }
+ if(btheme->text.syntaxn[3]==0) {
+ SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
+ SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
+ SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
+ SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
+ SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
+ }
+ }
+ }
+ if (G.main->versionfile <= 237) {
+ bTheme *btheme;
+ /* bone colors */
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->tv3d.bone_solid[3]==0) {
+ SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
+ SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
+ }
+ }
+ }
+ if (G.main->versionfile <= 238) {
+ bTheme *btheme;
+ /* bone colors */
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->tnla.strip[3]==0) {
+ SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
+ SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
+ }
+ }
+ }
+ if (G.main->versionfile <= 239) {
+ bTheme *btheme;
+
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* Lamp theme, check for alpha==0 is safe, then color was never set */
+ if(btheme->tv3d.lamp[3]==0) {
+ SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
+/* TEMPORAL, remove me! (ton) */
+ U.uiflag |= USER_PLAINMENUS;
+ }
+
+ /* check for text field selection highlight, set it to text editor highlight by default */
+ if(btheme->tui.textfield_hi[3]==0) {
+ SETCOL(btheme->tui.textfield_hi,
+ btheme->text.shade2[0],
+ btheme->text.shade2[1],
+ btheme->text.shade2[2],
+ 255);
+ }
+ }
+ if(U.obcenter_dia==0) U.obcenter_dia= 6;
+ }
+ if (G.main->versionfile <= 241) {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* Node editor theme, check for alpha==0 is safe, then color was never set */
+ if(btheme->tnode.syntaxn[3]==0) {
+ /* re-uses syntax color storage */
+ btheme->tnode= btheme->tv3d;
+ SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
+ SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
+ SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */
+ SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */
+ SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */
+ SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */
+ }
+ /* Group theme colors */
+ if(btheme->tv3d.group[3]==0) {
+ SETCOL(btheme->tv3d.group, 0x10, 0x40, 0x10, 255);
+ SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
+ }
+ /* Sequence editor theme*/
+ if(btheme->tseq.movie[3]==0) {
+ SETCOL(btheme->tseq.movie, 81, 105, 135, 255);
+ SETCOL(btheme->tseq.image, 109, 88, 129, 255);
+ SETCOL(btheme->tseq.scene, 78, 152, 62, 255);
+ SETCOL(btheme->tseq.audio, 46, 143, 143, 255);
+ SETCOL(btheme->tseq.effect, 169, 84, 124, 255);
+ SETCOL(btheme->tseq.plugin, 126, 126, 80, 255);
+ SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
+ SETCOL(btheme->tseq.meta, 109, 145, 131, 255);
+ }
+ if(!(btheme->tui.iconfile)) {
+ BLI_strncpy(btheme->tui.iconfile, "", sizeof(btheme->tui.iconfile));
+ }
+ }
+
+ /* set defaults for 3D View rotating axis indicator */
+ /* since size can't be set to 0, this indicates it's not saved in .B.blend */
+ if (U.rvisize == 0) {
+ U.rvisize = 15;
+ U.rvibright = 8;
+ U.uiflag |= USER_SHOW_ROTVIEWICON;
+ }
+
+ }
+ if (G.main->versionfile <= 242) {
+ bTheme *btheme;
+
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* long keyframe color */
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->tact.strip[3]==0) {
+ SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
+ SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
+ SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
+ }
+
+ /* IPO-Editor - Vertex Size*/
+ if(btheme->tipo.vertex_size == 0) {
+ btheme->tipo.vertex_size= 3;
+ }
+ }
+ }
+ if (G.main->versionfile <= 243) {
+ /* set default number of recently-used files (if not set) */
+ if (U.recent_files == 0) U.recent_files = 10;
+ }
+ if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
+ }
+ if(U.coba_weight.tot==0)
+ init_colorband(&U.coba_weight, 1);
+ }
+ if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) {
+ bTheme *btheme;
+ for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* these should all use the same colour */
+ SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
+ SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
+ }
+ }
+
+ /* GL Texture Garbage Collection (variable abused above!) */
+ if (U.textimeout == 0) {
+ U.texcollectrate = 60;
+ U.textimeout = 120;
+ }
+ if (U.memcachelimit <= 0) {
+ U.memcachelimit = 32;
+ }
+ if (U.frameserverport == 0) {
+ U.frameserverport = 8080;
+ }
+
+ MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
+
+ /* funny name, but it is GE stuff, moves userdef stuff to engine */
+// XXX space_set_commmandline_options();
+ /* this timer uses U */
+// XXX reset_autosave();
+
+#ifdef WITH_VERSE
+ if(strlen(U.versemaster)<1) {
+ strcpy(U.versemaster, "master.uni-verse.org");
+ }
+ if(strlen(U.verseuser)<1) {
+ char *name = verse_client_name();
+ strcpy(U.verseuser, name);
+ MEM_freeN(name);
+ }
+#endif
+
+}
+
+/* To be able to read files without windows closing, opening, moving
+ we try to prepare for worst case:
+ - active window gets active screen from file
+ - restoring the screens from non-active windows
+ Best case is all screens match, in that case they get assigned to proper window
+*/
+static void wm_window_match_init(bContext *C, ListBase *wmlist)
+{
+ wmWindowManager *wm= G.main->wm.first;
+ wmWindow *win;
+
+ *wmlist= G.main->wm;
+ G.main->wm.first= G.main->wm.last= NULL;
+
+return;
+ if(wm==NULL) return;
+ if(G.fileflags & G_FILE_NO_UI) return;
+
+ /* we take apart the used screens from non-active window */
+ for(win= wm->windows.first; win; win= win->next) {
+ BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
+ if(win!=C->window) {
+ BLI_remlink(&G.main->screen, win->screen);
+ //BLI_addtail(screenbase, win->screen);
+ }
+ }
+}
+
+/* match old WM with new, 4 cases:
+ 1- no current wm, no read wm: make new default
+ 2- no current wm, but read wm: that's OK, do nothing
+ 3- current wm, but not in file: try match screen names
+ 4- current wm, and wm in file: try match ghostwin
+
+*/
+static void wm_window_match_do(bContext *C, ListBase *wmlist)
+{
+ wmWindowManager *oldwm, *wm;
+ wmWindow *oldwin, *win;
+
+ /* cases 1 and 2 */
+ if(wmlist->first==NULL) {
+ if(G.main->wm.first); /* nothing todo */
+ else
+ wm_add_default(C);
+ }
+ else {
+ /* cases 3 and 4 */
+
+ /* we've read file without wm... */
+ if(G.main->wm.first==NULL) {
+ /* match oldwm to new dbase, only old files */
+
+ for(wm= wmlist->first; wm; wm= wm->id.next) {
+ for(win= wm->windows.first; win; win= win->next) {
+ win->screen= (bScreen *)find_id("SR", win->screenname);
+ if(win->screen->winid==0) {
+ if(win->screen==NULL)
+ win->screen= C->screen; /* active screen */
+
+ win->screen->winid= win->winid;
+ }
+ }
+ }
+ /* XXX still solve, case where multiple windows open */
+
+ G.main->wm= *wmlist;
+ }
+ else {
+ /* what if old was 3, and loaded 1? */
+ /* this code could move to setup_appdata */
+ oldwm= wmlist->first;
+ wm= G.main->wm.first;
+ /* only first wm in list has ghostwins */
+ for(win= wm->windows.first; win; win= win->next) {
+ for(oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
+
+ if(oldwin->winid == win->winid ) {
+ win->ghostwin= oldwin->ghostwin;
+ oldwin->ghostwin= NULL;
+ }
+ }
+ }
+ wm_close_and_free_all(C, wmlist);
+ }
+ }
+}
+
+#ifdef WITH_VERSE
+static void verse_unsub(void)
+{
+ extern ListBase session_list;
+ struct VerseSession *session;
+ struct VNode *vnode;
+
+ session = session_list.first;
+ while(session) {
+ vnode = session->nodes.lb.first;
+ while(vnode) {
+ switch(vnode->type) {
+ case V_NT_OBJECT:
+ unsubscribe_from_obj_node(vnode);
+ break;
+ case V_NT_GEOMETRY:
+ unsubscribe_from_geom_node(vnode);
+ break;
+ case V_NT_BITMAP:
+ unsubscribe_from_bitmap_node(vnode);
+ break;
+ }
+ vnode = vnode->next;
+ }
+ session = session->next;
+ }
+}
+#endif
+
+void WM_read_file(bContext *C, char *name)
+{
+ int retval;
+
+#ifdef WITH_VERSE
+ verse_unsub(); /* bad call here (ton) */
+#endif
+
+ /* first try to append data from exotic file formats... */
+ /* it throws error box when file doesnt exist and returns -1 */
+ retval= BKE_read_exotic(name);
+
+ /* we didn't succeed, now try to read Blender file */
+ if (retval== 0) {
+ ListBase wmbase;
+
+ /* put aside screens to match with persistant windows later */
+ wm_window_match_init(C, &wmbase);
+
+ retval= BKE_read_file(C, name, NULL);
+
+ /* match the read WM with current WM */
+ wm_window_match_do(C, &wmbase);
+
+// XXX mainwindow_set_filename_to_title(G.main->name);
+// countall(); <-- will be listener
+// XXX sound_initialize_sounds();
+
+// winqueue_break= 1; /* leave queues everywhere */
+
+ if(retval==2) init_userdef_themes(); // in case a userdef is read from regular .blend
+
+ if (retval!=0) G.relbase_valid = 1;
+
+// XXX undo_editmode_clear();
+ BKE_reset_undo();
+ BKE_write_undo(C, "original"); /* save current state */
+
+// refresh_interface_font();
+ }
+// else if(retval==1)
+// XXX BIF_undo_push("Import file");
+}
+
+static void outliner_242_patch(void)
+{
+ ScrArea *sa;
+
+ for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl= sa->spacedata.first;
+ for(; sl; sl= sl->next) {
+ if(sl->spacetype==SPACE_OOPS) {
+ SpaceOops *soops= (SpaceOops *)sl;
+ if(soops->type!=SO_OUTLINER) {
+ soops->type= SO_OUTLINER;
+// XXX init_v2d_oops(sa, soops);
+ }
+ }
+ }
+ }
+ G.fileflags |= G_FILE_GAME_MAT;
+}
+
+/* called on startup, (context entirely filled with NULLs) */
+/* or called for 'Erase All' */
+int WM_read_homefile(bContext *C, int from_memory)
+{
+ ListBase wmbase;
+ char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
+ char *home= BLI_gethome();
+ int success;
+
+ BLI_clean(home);
+
+ free_ttfont(); /* still weird... what does it here? */
+
+ G.relbase_valid = 0;
+ if (!from_memory) BLI_make_file_string(G.sce, tstr, home, ".B.blend");
+ strcpy(scestr, G.sce); /* temporary store */
+
+ /* prevent loading no UI */
+ G.fileflags &= ~G_FILE_NO_UI;
+
+ /* put aside screens to match with persistant windows later */
+ wm_window_match_init(C, &wmbase);
+
+ if (!from_memory && BLI_exists(tstr)) {
+ success = BKE_read_file(C, tstr, NULL);
+ } else {
+ success = BKE_read_file_from_memory(C, datatoc_B_blend, datatoc_B_blend_size, NULL);
+ /* outliner patch for 2.42 .b.blend */
+ outliner_242_patch();
+ }
+
+ /* match the read WM with current WM */
+ wm_window_match_do(C, &wmbase);
+
+ strcpy(G.sce, scestr); /* restore */
+
+ init_userdef_themes();
+
+ /* XXX */
+ G.save_over = 0; // start with save preference untitled.blend
+ G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.blend... */
+// mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender"
+
+#ifdef INTERNATIONAL
+// XXX read_languagefile();
+#endif
+
+// refresh_interface_font();
+
+// undo_editmode_clear();
+ BKE_reset_undo();
+ BKE_write_undo(C, "original"); /* save current state */
+
+ return success;
+}
+
+
+static void get_autosave_location(char buf[FILE_MAXDIR+FILE_MAXFILE])
+{
+ char pidstr[32];
+#ifdef WIN32
+ char subdir[9];
+ char savedir[FILE_MAXDIR];
+#endif
+
+ sprintf(pidstr, "%d.blend", abs(getpid()));
+
+#ifdef WIN32
+ if (!BLI_exists(U.tempdir)) {
+ BLI_strncpy(subdir, "autosave", sizeof(subdir));
+ BLI_make_file_string("/", savedir, BLI_gethome(), subdir);
+
+ /* create a new autosave dir
+ * function already checks for existence or not */
+ BLI_recurdir_fileops(savedir);
+
+ BLI_make_file_string("/", buf, savedir, pidstr);
+ return;
+ }
+#endif
+
+ BLI_make_file_string("/", buf, U.tempdir, pidstr);
+}
+
+void WM_read_autosavefile(bContext *C)
+{
+ char tstr[FILE_MAX], scestr[FILE_MAX];
+ int save_over;
+
+ BLI_strncpy(scestr, G.sce, FILE_MAX); /* temporal store */
+
+ get_autosave_location(tstr);
+
+ save_over = G.save_over;
+ BKE_read_file(C, tstr, NULL);
+ G.save_over = save_over;
+ BLI_strncpy(G.sce, scestr, FILE_MAX);
+}
+
+
+void read_Blog(void)
+{
+ char name[FILE_MAX], filename[FILE_MAX];
+ LinkNode *l, *lines;
+ struct RecentFile *recent;
+ char *line;
+ int num;
+
+ BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
+ lines= BLI_read_file_as_lines(name);
+
+ G.recent_files.first = G.recent_files.last = NULL;
+
+ /* read list of recent opend files from .Blog to memory */
+ for (l= lines, num= 0; l && (num<U.recent_files); l= l->next, num++) {
+ line = l->link;
+ if (!BLI_streq(line, "")) {
+ if (num==0)
+ strcpy(G.sce, line);
+
+ recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile");
+ BLI_addtail(&(G.recent_files), recent);
+ recent->filename = (char*)MEM_mallocN(sizeof(char)*(strlen(line)+1), "name of file");
+ recent->filename[0] = '\0';
+
+ strcpy(recent->filename, line);
+ }
+ }
+
+ if(G.sce[0] == 0)
+ BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend");
+
+ BLI_free_file_lines(lines);
+
+#ifdef WIN32
+ /* Add the drive names to the listing */
+ {
+ __int64 tmp;
+ char folder[MAX_PATH];
+ char tmps[4];
+ int i;
+
+ tmp= GetLogicalDrives();
+
+ for (i=2; i < 26; i++) {
+ if ((tmp>>i) & 1) {
+ tmps[0]='a'+i;
+ tmps[1]=':';
+ tmps[2]='\\';
+ tmps[3]=0;
+
+// XX fsmenu_insert_entry(tmps, 0, 0);
+ }
+ }
+
+ /* Adding Desktop and My Documents */
+// XXX fsmenu_append_separator();
+
+ SHGetSpecialFolderPath(0, folder, CSIDL_PERSONAL, 0);
+// XXX fsmenu_insert_entry(folder, 0, 0);
+ SHGetSpecialFolderPath(0, folder, CSIDL_DESKTOPDIRECTORY, 0);
+// XXX fsmenu_insert_entry(folder, 0, 0);
+
+// XXX fsmenu_append_separator();
+ }
+#endif
+
+ BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs");
+ lines= BLI_read_file_as_lines(name);
+
+ for (l= lines; l; l= l->next) {
+ char *line= l->link;
+
+ if (!BLI_streq(line, "")) {
+// XXX fsmenu_insert_entry(line, 0, 1);
+ }
+ }
+
+// XXX fsmenu_append_separator();
+
+ /* add last saved file */
+ BLI_split_dirfile(G.sce, name, filename); /* G.sce shouldn't be relative */
+
+// XXX fsmenu_insert_entry(name, 0, 0);
+
+ BLI_free_file_lines(lines);
+}
+
+static void writeBlog(void)
+{
+ struct RecentFile *recent, *next_recent;
+ char name[FILE_MAXDIR+FILE_MAXFILE];
+ FILE *fp;
+ int i;
+
+ BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
+
+ recent = G.recent_files.first;
+ /* refresh .Blog of recent opened files, when current file was changed */
+ if(!(recent) || (strcmp(recent->filename, G.sce)!=0)) {
+ fp= fopen(name, "w");
+ if (fp) {
+ /* add current file to the beginning of list */
+ recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile");
+ recent->filename = (char*)MEM_mallocN(sizeof(char)*(strlen(G.sce)+1), "name of file");
+ recent->filename[0] = '\0';
+ strcpy(recent->filename, G.sce);
+ BLI_addhead(&(G.recent_files), recent);
+ /* write current file to .Blog */
+ fprintf(fp, "%s\n", recent->filename);
+ recent = recent->next;
+ i=1;
+ /* write rest of recent opened files to .Blog */
+ while((i<U.recent_files) && (recent)){
+ /* this prevents to have duplicities in list */
+ if (strcmp(recent->filename, G.sce)!=0) {
+ fprintf(fp, "%s\n", recent->filename);
+ recent = recent->next;
+ }
+ else {
+ next_recent = recent->next;
+ MEM_freeN(recent->filename);
+ BLI_freelinkN(&(G.recent_files), recent);
+ recent = next_recent;
+ }
+ i++;
+ }
+ fclose(fp);
+ }
+ }
+}
+
+static void do_history(char *name)
+{
+ char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE];
+ int hisnr= U.versions;
+
+ if(U.versions==0) return;
+ if(strlen(name)<2) return;
+
+ while( hisnr > 1) {
+ sprintf(tempname1, "%s%d", name, hisnr-1);
+ sprintf(tempname2, "%s%d", name, hisnr);
+
+// if(BLI_rename(tempname1, tempname2))
+// XXX error("Unable to make version backup");
+
+ hisnr--;
+ }
+
+ /* is needed when hisnr==1 */
+ sprintf(tempname1, "%s%d", name, hisnr);
+
+// if(BLI_rename(name, tempname1))
+// XXX error("Unable to make version backup");
+}
+
+void WM_write_file(bContext *C, char *target)
+{
+ Library *li;
+ int writeflags, len;
+ char di[FILE_MAX];
+ char *err;
+
+ len = strlen(target);
+
+ if (len == 0) return;
+ if (len >= FILE_MAX) {
+// XXX error("Path too long, cannot save");
+ return;
+ }
+
+ /* send the OnSave event */
+// XXX if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript(&C->scene->id, SCRIPT_ONSAVE);
+
+ for (li= G.main->library.first; li; li= li->id.next) {
+ if (BLI_streq(li->name, target)) {
+// XXX error("Cannot overwrite used library");
+ return;
+ }
+ }
+
+ if (!BLO_has_bfile_extension(target) && (len+6 < FILE_MAX)) {
+ sprintf(di, "%s.blend", target);
+ } else {
+ strcpy(di, target);
+ }
+
+ if (BLI_exists(di)) {
+// XXX if(!saveover(di))
+// XXX return;
+ }
+
+ if(G.obedit) {
+// XXX exit_editmode(0); /* 0 = no free data */
+ }
+ if (G.fileflags & G_AUTOPACK) {
+ packAll();
+ }
+
+// XXX waitcursor(1); // exit_editmode sets cursor too
+
+ do_history(di);
+
+ /* we use the UserDef to define compression flag */
+ writeflags= G.fileflags & ~G_FILE_COMPRESS;
+ if(U.flag & USER_FILECOMPRESS)
+ writeflags |= G_FILE_COMPRESS;
+
+ if (BLO_write_file(C, di, writeflags, &err)) {
+ strcpy(G.sce, di);
+ G.relbase_valid = 1;
+ strcpy(G.main->name, di); /* is guaranteed current file */
+
+// XXX mainwindow_set_filename_to_title(G.main->name);
+
+ G.save_over = 1;
+
+ writeBlog();
+ } else {
+// XXX error("%s", err);
+ }
+
+// XXX waitcursor(0);
+}
+
+/* operator entry */
+int WM_write_homefile(bContext *C, wmOperator *op)
+{
+ char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
+ int write_flags;
+
+ BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
+
+ /* force save as regular blend file */
+ write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
+ BLO_write_file(C, tstr, write_flags, &err);
+
+ return 1;
+}
+
+void WM_write_autosave(bContext *C)
+{
+ char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
+ int write_flags;
+
+ get_autosave_location(tstr);
+
+ /* force save as regular blend file */
+ write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
+ BLO_write_file(C, tstr, write_flags, &err);
+}
+
+/* if global undo; remove tempsave, otherwise rename */
+void delete_autosave(void)
+{
+ char tstr[FILE_MAXDIR+FILE_MAXFILE];
+
+ get_autosave_location(tstr);
+
+ if (BLI_exists(tstr)) {
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+ BLI_make_file_string("/", str, U.tempdir, "quit.blend");
+
+ if(U.uiflag & USER_GLOBALUNDO) BLI_delete(tstr, 0, 0);
+ else BLI_rename(tstr, str);
+ }
+}
+
+/***/
+
+
+
+
+
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
new file mode 100644
index 00000000000..029c16cee49
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -0,0 +1,302 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+#include "MEM_CacheLimiterC-Api.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_curve.h"
+#include "BKE_displist.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_font.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_mball.h"
+#include "BKE_utildefines.h"
+#include "BKE_packedFile.h"
+
+#include "BMF_Api.h"
+#include "BIF_language.h"
+#ifdef INTERNATIONAL
+#include "FTF_Api.h"
+#endif
+
+#include "BLI_blenlib.h"
+
+#include "BIF_cursors.h"
+#include "BIF_drawtext.h"
+#include "BIF_editaction.h"
+#include "BIF_editarmature.h"
+#include "BIF_editlattice.h"
+#include "BIF_editfont.h"
+#include "BIF_editmesh.h"
+#include "BIF_editmode_undo.h"
+#include "BIF_editsound.h"
+#include "BIF_filelist.h"
+#include "BIF_fsmenu.h"
+#include "BIF_interface.h"
+#include "BIF_gl.h"
+#include "BIF_poseobject.h"
+#include "BIF_previewrender.h"
+#include "BIF_resources.h"
+#include "BIF_usiblender.h" /* XXX */
+
+#include "BSE_drawview.h"
+#include "BSE_edit.h"
+#include "BSE_editipo.h"
+#include "BSE_filesel.h"
+#include "BSE_headerbuttons.h"
+#include "BSE_node.h"
+
+#include "BDR_drawobject.h"
+#include "BDR_editobject.h"
+#include "BDR_editcurve.h"
+#include "BDR_imagepaint.h"
+#include "BDR_vpaint.h"
+
+#include "RE_pipeline.h" /* RE_ free stuff */
+
+#include "radio.h"
+
+#include "BPY_extern.h"
+
+#include "SYS_System.h"
+
+#include "WM_api.h"
+#include "wm.h"
+#include "wm_files.h"
+#include "wm_window.h"
+
+static void initbuttons(void)
+{
+// uiDefFont(UI_HELVB,
+// BMF_GetFont(BMF_kHelveticaBold14),
+// BMF_GetFont(BMF_kHelveticaBold12),
+// BMF_GetFont(BMF_kHelveticaBold10),
+// BMF_GetFont(BMF_kHelveticaBold8));
+// uiDefFont(UI_HELV,
+// BMF_GetFont(BMF_kHelvetica12),
+// BMF_GetFont(BMF_kHelvetica12),
+// BMF_GetFont(BMF_kHelvetica10),
+// BMF_GetFont(BMF_kHelveticaBold8));
+
+// glClearColor(.7f, .7f, .6f, 0.0);
+
+ G.font= BMF_GetFont(BMF_kHelvetica12);
+ G.fonts= BMF_GetFont(BMF_kHelvetica10);
+ G.fontss= BMF_GetFont(BMF_kHelveticaBold8);
+
+// clear_matcopybuf(); /* XXX */
+
+// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+}
+
+/* XXX */
+static void sound_init_listener(void)
+{
+ G.listener = MEM_callocN(sizeof(bSoundListener), "soundlistener");
+ G.listener->gain = 1.0;
+ G.listener->dopplerfactor = 1.0;
+ G.listener->dopplervelocity = 340.29f;
+}
+
+/* only called once, for startup */
+void WM_init(bContext *C)
+{
+
+ wm_ghost_init(C); /* note: it assigns C to ghost! */
+ wm_operatortype_init();
+
+ set_free_windowmanager_cb(wm_close_and_free); /* library.c */
+
+ /* get the default database, plus a wm */
+ WM_read_homefile(C, 0);
+
+ wm_check(C); /* opens window(s), checks keymaps */
+
+// initscreen(); /* for (visual) speed, this first, then setscreen */
+ initbuttons();
+// InitCursorData();
+ sound_init_listener();
+// init_node_butfuncs();
+
+// XXX BIF_preview_init_dbase();
+
+
+// XXX BIF_resources_init(); /* after homefile, to dynamically load an icon file based on theme settings */
+
+// XXX BIF_filelist_init_icons();
+
+// init_gl_stuff(); /* drawview.c, after homefile */
+ read_Blog();
+ BLI_strncpy(G.lib, G.sce, FILE_MAX);
+}
+
+/* free strings of open recent files */
+static void free_openrecent(void)
+{
+ struct RecentFile *recent;
+
+ for(recent = G.recent_files.first; recent; recent=recent->next)
+ MEM_freeN(recent->filename);
+
+ BLI_freelistN(&(G.recent_files));
+}
+
+
+/* bad stuff*/
+
+extern ListBase editNurb;
+extern ListBase editelems;
+extern wchar_t *copybuf;
+extern wchar_t *copybufinfo;
+
+/* called in creator.c even... tsk, split this! */
+void WM_exit(bContext *C)
+{
+ wm_operatortype_free();
+
+ free_ttfont(); /* bke_font.h */
+
+#ifdef WITH_VERSE
+ end_all_verse_sessions();
+#endif
+ free_openrecent();
+
+ freeAllRad();
+ BKE_freecubetable();
+
+// if (G.background == 0)
+// sound_end_all_sounds();
+
+ if(G.obedit) {
+ if(G.obedit->type==OB_FONT) {
+// free_editText();
+ }
+// else if(G.obedit->type==OB_MBALL) BLI_freelistN(&editelems);
+// free_editMesh(G.editMesh);
+ }
+
+// free_editLatt();
+// free_editArmature();
+// free_posebuf();
+
+ /* before free_blender so py's gc happens while library still exists */
+ /* needed at least for a rare sigsegv that can happen in pydrivers */
+// BPY_end_python();
+
+// fastshade_free_render(); /* shaded view */
+ free_blender(); /* blender.c, does entire library */
+// free_matcopybuf();
+// free_ipocopybuf();
+// free_actcopybuf();
+// free_vertexpaint();
+// free_imagepaint();
+
+ /* editnurb can remain to exist outside editmode */
+ freeNurblist(&editNurb);
+
+// fsmenu_free();
+
+#ifdef INTERNATIONAL
+// free_languagemenu();
+#endif
+
+ RE_FreeAllRender();
+
+// free_txt_data();
+
+// sound_exit_audio();
+ if(G.listener) MEM_freeN(G.listener);
+
+
+ libtiff_exit();
+
+#ifdef WITH_QUICKTIME
+ quicktime_exit();
+#endif
+
+ if (!G.background) {
+// XXX BIF_resources_free();
+
+// XXX BIF_filelist_free_icons();
+ }
+
+#ifdef INTERNATIONAL
+ FTF_End();
+#endif
+
+// if (copybuf) MEM_freeN(copybuf);
+// if (copybufinfo) MEM_freeN(copybufinfo);
+
+ /* undo free stuff */
+// undo_editmode_clear();
+
+ BKE_undo_save_quit(); // saves quit.blend if global undo is on
+ BKE_reset_undo();
+
+ BLI_freelistN(&U.themes);
+// XXX BIF_preview_free_dbase();
+
+ MEM_freeN(C);
+
+ if(totblock!=0) {
+ printf("Error Totblock: %d\n",totblock);
+ MEM_printmemlist();
+ }
+// delete_autosave();
+
+ printf("\nBlender quit\n");
+
+#ifdef WIN32
+ /* ask user to press enter when in debug mode */
+ if(G.f & G_DEBUG) {
+ printf("press enter key to exit...\n\n");
+ getchar();
+ }
+#endif
+
+
+ SYS_DeleteSystem(SYS_GetSystem());
+
+ exit(G.afbreek==1);
+}
+
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
new file mode 100644
index 00000000000..da340e35d79
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -0,0 +1,112 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+#include "wm_event_types.h"
+
+/* ***************** generic call, exported **************** */
+
+static void keymap_set(wmKeymapItem *km, short type, short val, int modifier, short keymodifier)
+{
+ km->type= type;
+ km->val= val;
+ km->keymodifier= keymodifier;
+
+ if(modifier & KM_SHIFT)
+ km->shift= 1;
+ else if(modifier & KM_SHIFT2)
+ km->shift= 2;
+ if(modifier & KM_CTRL)
+ km->ctrl= 1;
+ else if(modifier & KM_CTRL2)
+ km->ctrl= 2;
+ if(modifier & KM_ALT)
+ km->alt= 1;
+ else if(modifier & KM_ALT2)
+ km->alt= 2;
+ if(modifier & KM_OSKEY)
+ km->oskey= 1;
+ else if(modifier & KM_OSKEY2)
+ km->oskey= 2;
+}
+
+/* if item was added, then replace */
+void WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
+{
+ wmKeymapItem *km;
+
+ /* if item was added, then bail out */
+ for(km= lb->first; km; km= km->next)
+ if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
+ break;
+ if(km==NULL) {
+ km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
+
+ BLI_addtail(lb, km);
+ BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
+
+ keymap_set(km, type, val, modifier, keymodifier);
+ }
+
+}
+
+/* if item was added, then replace */
+void WM_keymap_set_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
+{
+ wmKeymapItem *km;
+
+ for(km= lb->first; km; km= km->next)
+ if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
+ break;
+ if(km==NULL) {
+ km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
+
+ BLI_addtail(lb, km);
+ BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
+ }
+ keymap_set(km, type, val, modifier, keymodifier);
+}
+
+
+
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
new file mode 100644
index 00000000000..d3216d20725
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -0,0 +1,125 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+
+#include "BIF_toolbox.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+
+static ListBase global_ops= {NULL, NULL};
+
+/* ************ operator API, exported ********** */
+
+wmOperatorType *WM_operatortype_find(const char *idname)
+{
+ wmOperatorType *ot;
+
+ for(ot= global_ops.first; ot; ot= ot->next) {
+ if(strncmp(ot->idname, idname, OP_MAX_TYPENAME)==0)
+ return ot;
+ }
+ return NULL;
+}
+
+/* ************ default ops, exported *********** */
+
+int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
+{
+// if(okee(op->type->name)) {
+// return op->type->exec(C, op);
+// }
+ return 0;
+}
+int WM_operator_winactive(bContext *C)
+{
+ if(C->window==NULL) return 0;
+ return 1;
+}
+
+/* ************ window / screen operator definitions ************** */
+
+static void WM_OT_window_duplicate(wmOperatorType *ot)
+{
+ ot->name= "Duplicate Window";
+ ot->idname= "WM_OT_window_duplicate";
+
+ ot->interactive= NULL; //WM_operator_confirm;
+ ot->exec= wm_window_duplicate_op;
+ ot->poll= WM_operator_winactive;
+}
+
+static void WM_OT_save_homefile(wmOperatorType *ot)
+{
+ ot->name= "Save User Settings";
+ ot->idname= "WM_OT_save_homefile";
+
+ ot->interactive= NULL; //WM_operator_confirm;
+ ot->exec= WM_write_homefile;
+ ot->poll= WM_operator_winactive;
+
+ ot->flag= OPTYPE_REGISTER;
+}
+
+
+
+#define ADD_OPTYPE(opfunc) ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \
+ opfunc(ot); \
+ BLI_addtail(&global_ops, ot)
+
+
+/* called on initialize WM_exit() */
+void wm_operatortype_free(void)
+{
+ BLI_freelistN(&global_ops);
+}
+
+/* called on initialize WM_init() */
+void wm_operatortype_init(void)
+{
+ wmOperatorType *ot;
+
+ ADD_OPTYPE(WM_OT_window_duplicate);
+ ADD_OPTYPE(WM_OT_save_homefile);
+}
+
+
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
new file mode 100644
index 00000000000..4a6a3c572d3
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -0,0 +1,491 @@
+/**
+ * $Id: wm_window.c
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation but based
+ * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "DNA_listBase.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "GHOST_C-api.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+
+#include "WM_api.h"
+#include "wm.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+
+/* the global to talk to ghost */
+GHOST_SystemHandle g_system= NULL;
+
+/* set by commandline */
+static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0;
+
+
+/* ******** win open & close ************ */
+
+
+static void wm_get_screensize(int *width_r, int *height_r)
+{
+ unsigned int uiwidth;
+ unsigned int uiheight;
+
+ GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight);
+ *width_r= uiwidth;
+ *height_r= uiheight;
+}
+
+static void wm_ghostwindow_destroy(wmWindow *win)
+{
+
+ if (win->timer) {
+ GHOST_RemoveTimer(g_system, (GHOST_TimerTaskHandle)win->timer);
+ win->timer= NULL;
+ }
+
+ if(win->ghostwin) {
+ GHOST_DisposeWindow(g_system, win->ghostwin);
+ win->ghostwin= NULL;
+ }
+}
+
+/* including window itself */
+void wm_window_free(bContext *C, wmWindow *win)
+{
+
+ /* update context */
+ if(C) {
+ if(C->wm->windrawable==win)
+ C->wm->windrawable= NULL;
+ if(C->wm->winactive==win)
+ C->wm->winactive= NULL;
+ if(C->window==win)
+ C->window= NULL;
+ if(C->screen==win->screen)
+ C->screen= NULL;
+ }
+ /* XXX free screens */
+
+ if(win->eventstate) MEM_freeN(win->eventstate);
+
+ BLI_freelistN(&win->queue);
+ wm_event_free_handlers(&win->handlers);
+
+ wm_event_free_all(win);
+ wm_ghostwindow_destroy(win);
+
+ MEM_freeN(win);
+}
+
+static int find_free_winid(wmWindowManager *wm)
+{
+ wmWindow *win;
+ int id= 0;
+
+ for(win= wm->windows.first; win; win= win->next)
+ if(id <= win->winid)
+ id= win->winid+1;
+
+ return id;
+}
+
+/* dont change context itself */
+wmWindow *wm_window_new(bContext *C, bScreen *screen)
+{
+ wmWindow *win= MEM_callocN(sizeof(wmWindow), "window");
+
+ BLI_addtail(&C->wm->windows, win);
+ win->winid= find_free_winid(C->wm);
+
+ win->screen= screen;
+ return win;
+}
+
+/* part of wm_window.c api */
+wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
+{
+ wmWindow *win= wm_window_new(C, winorig->screen); /* XXX need copy */
+
+ win->posx= winorig->posx+10;
+ win->posy= winorig->posy;
+ win->sizex= winorig->sizex;
+ win->sizey= winorig->sizey;
+
+ return win;
+}
+
+/* operator callback */
+int wm_window_duplicate_op(bContext *C, wmOperator *op)
+{
+
+ wm_window_copy(C, C->window);
+ wm_check(C);
+
+ return 1;
+}
+
+/* this is event from ghost */
+static void wm_window_close(bContext *C, wmWindow *win)
+{
+ BLI_remlink(&C->wm->windows, win);
+ wm_window_free(C, win);
+
+ if(C->wm->windows.first==NULL)
+ WM_exit(C);
+}
+
+static void wm_window_open(wmWindowManager *wm, char *title, wmWindow *win)
+{
+ GHOST_WindowHandle ghostwin;
+ GHOST_TWindowState inital_state;
+ int scr_w, scr_h, posy;
+
+ wm_get_screensize(&scr_w, &scr_h);
+ posy= (scr_h - win->posy - win->sizey);
+
+ if (win->windowstate == G_WINDOWSTATE_FULLSCREEN)
+ inital_state = GHOST_kWindowStateFullScreen;
+ else if (win->windowstate == G_WINDOWSTATE_BORDER)
+ inital_state = GHOST_kWindowStateMaximized;
+ else
+ inital_state = GHOST_kWindowStateNormal;
+
+#ifdef __APPLE__
+ {
+ extern int macPrefState; /* creator.c */
+ inital_state += macPrefState;
+ }
+#endif
+
+ ghostwin= GHOST_CreateWindow(g_system, title,
+ win->posx, posy, win->sizex, win->sizey,
+ inital_state,
+ GHOST_kDrawingContextTypeOpenGL,
+ 0 /* no stereo */);
+
+ if (ghostwin) {
+
+ win->ghostwin= ghostwin;
+ GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
+
+ if(win->eventstate==NULL)
+ win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
+
+ /* add keymap handler (1 for all keys in map!) */
+ WM_event_add_keymap_handler(&wm->windowkeymap, &win->handlers);
+
+ /* until screens get drawn, make it nice grey */
+ glClearColor(.55, .55, .55, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ wm_window_swap_buffers(win);
+ }
+
+
+}
+
+/* for wmWindows without ghostwin, open these and clear */
+void wm_window_add_ghostwindows(wmWindowManager *wm)
+{
+ wmWindow *win;
+
+ /* no commandline prefsize? then we set this */
+ if (!prefsizx) {
+ wm_get_screensize(&prefsizx, &prefsizy);
+
+#ifdef __APPLE__
+ extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */
+
+ wm_set_apple_prefsize(prefsizx, prefsizy);
+#else
+ prefstax= 0;
+ prefstay= 0;
+
+#endif
+ }
+
+ for(win= wm->windows.first; win; win= win->next) {
+ if(win->ghostwin==NULL) {
+ if(win->sizex==0) {
+ win->posx= prefstax;
+ win->posy= prefstay;
+ win->sizex= prefsizx;
+ win->sizey= prefsizy;
+ win->windowstate= G.windowstate;
+ }
+ wm_window_open(wm, "Blender", win);
+ }
+ }
+}
+
+/* ************ events *************** */
+
+static int query_qual(char qual)
+{
+ GHOST_TModifierKeyMask left, right;
+ int val= 0;
+
+ if (qual=='s') {
+ left= GHOST_kModifierKeyLeftShift;
+ right= GHOST_kModifierKeyRightShift;
+ } else if (qual=='c') {
+ left= GHOST_kModifierKeyLeftControl;
+ right= GHOST_kModifierKeyRightControl;
+ } else if (qual=='C') {
+ left= right= GHOST_kModifierKeyCommand;
+ } else {
+ left= GHOST_kModifierKeyLeftAlt;
+ right= GHOST_kModifierKeyRightAlt;
+ }
+
+ GHOST_GetModifierKeyState(g_system, left, &val);
+ if (!val)
+ GHOST_GetModifierKeyState(g_system, right, &val);
+
+ return val;
+}
+
+void wm_window_make_drawable(bContext *C, wmWindow *win)
+{
+ if (win != C->window && win->ghostwin) {
+// win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */
+
+ C->wm->windrawable= win;
+ C->window= win;
+ C->screen= win->screen;
+
+ GHOST_ActivateWindowDrawingContext(win->ghostwin);
+ }
+}
+
+/* called by ghost, here we handle events for windows themselves or send to event system */
+int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
+{
+ bContext *C= private;
+ GHOST_TEventType type= GHOST_GetEventType(evt);
+
+ if (type == GHOST_kEventQuit) {
+ WM_exit(C);
+ } else {
+ GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt);
+ GHOST_TEventDataPtr data= GHOST_GetEventData(evt);
+ wmWindow *win;
+
+ if (!ghostwin) {
+ // XXX - should be checked, why are we getting an event here, and
+ // what is it?
+
+ return 1;
+ } else if (!GHOST_ValidWindow(g_system, ghostwin)) {
+ // XXX - should be checked, why are we getting an event here, and
+ // what is it?
+
+ return 1;
+ } else {
+ win= GHOST_GetWindowUserData(ghostwin);
+ }
+
+ switch(type) {
+ case GHOST_kEventWindowDeactivate:
+ win->active= 0; /* XXX */
+ break;
+ case GHOST_kEventWindowActivate:
+ {
+ GHOST_TEventKeyData kdata;
+ int cx, cy, wx, wy;
+
+ C->wm->winactive= win; /* no context change! c->window is drawable, or for area queues */
+
+ win->active= 1;
+// window_handle(win, INPUTCHANGE, win->active);
+
+ /* bad ghost support for modifier keys... */
+ kdata.ascii= 0;
+ if (win->eventstate->shift && !query_qual('s')) {
+ kdata.key= GHOST_kKeyLeftShift;
+ wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata);
+ }
+ if (win->eventstate->ctrl && !query_qual('c')) {
+ kdata.key= GHOST_kKeyLeftControl;
+ wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata);
+ }
+ if (win->eventstate->alt && !query_qual('a')) {
+ kdata.key= GHOST_kKeyLeftAlt;
+ wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata);
+ }
+ if (win->eventstate->oskey && !query_qual('C')) {
+ kdata.key= GHOST_kKeyCommand;
+ wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata);
+ }
+
+ /* entering window, update mouse pos. but no event */
+ GHOST_GetCursorPosition(g_system, &wx, &wy);
+
+ GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
+ win->eventstate->x= cx;
+ win->eventstate->y= (win->sizey-1) - cy;
+
+ break;
+ }
+ case GHOST_kEventWindowClose: {
+ wm_window_close(C, win);
+ break;
+ }
+ case GHOST_kEventWindowUpdate: {
+// window_handle(win, REDRAW, 1);
+ break;
+ }
+ case GHOST_kEventWindowSize: {
+ GHOST_RectangleHandle client_rect;
+ int l, t, r, b, scr_w, scr_h;
+
+ /* was GetClientBounds, doesnt work (at least osx) */
+ client_rect= GHOST_GetWindowBounds(win->ghostwin);
+ GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
+
+ GHOST_DisposeRectangle(client_rect);
+
+ wm_get_screensize(&scr_w, &scr_h);
+ win->sizex= r-l;
+ win->sizey= b-t;
+ win->posx= l;
+ win->posy= scr_h - t - win->sizey;
+#ifdef __APPLE__
+ win->posy-= 24; /* gutter... see ghost, bad stuff */
+#endif
+
+// window_handle(win, RESHAPE, 1);
+ break;
+ }
+ default:
+ wm_event_add_ghostevent(win, type, data);
+ break;
+ }
+
+ }
+ return 1;
+}
+
+void wm_window_process_events(int wait_for_event)
+{
+ GHOST_ProcessEvents(g_system, wait_for_event);
+ GHOST_DispatchEvents(g_system);
+}
+
+/* **************** init ********************** */
+
+void wm_ghost_init(bContext *C)
+{
+ if (!g_system) {
+ GHOST_EventConsumerHandle consumer= GHOST_CreateEventConsumer(ghost_event_proc, C);
+
+ g_system= GHOST_CreateSystem();
+ GHOST_AddEventConsumer(g_system, consumer);
+ }
+}
+
+/* **************** timer ********************** */
+
+static void window_timer_proc(GHOST_TimerTaskHandle timer, GHOST_TUns64 time)
+{
+ wmWindow *win= GHOST_GetTimerTaskUserData(timer);
+
+ wm_event_add_ghostevent(win, win->timer_event, NULL);
+}
+
+void wm_window_set_timer(wmWindow *win, int delay_ms, int event)
+{
+ if (win->timer) GHOST_RemoveTimer(g_system, win->timer);
+
+ win->timer_event= event;
+ win->timer= GHOST_InstallTimer(g_system, delay_ms, delay_ms, window_timer_proc, win);
+}
+
+/* ************************************ */
+
+void wm_window_set_title(wmWindow *win, char *title)
+{
+ GHOST_SetTitle(win->ghostwin, title);
+}
+
+void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r)
+{
+ *posx_r= win->posx;
+ *posy_r= win->posy;
+}
+
+void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
+{
+ *width_r= win->sizex;
+ *height_r= win->sizey;
+}
+
+void wm_window_set_size(wmWindow *win, int width, int height)
+{
+ GHOST_SetClientSize(win->ghostwin, width, height);
+}
+
+void wm_window_lower(wmWindow *win)
+{
+ GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderBottom);
+}
+
+void wm_window_raise(wmWindow *win)
+{
+ GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderTop);
+#ifdef _WIN32
+// markdirty_all(); /* to avoid redraw errors in fullscreen mode (aphex) */
+#endif
+}
+
+void wm_window_swap_buffers(wmWindow *win)
+{
+ GHOST_SwapWindowBuffers(win->ghostwin);
+}
+
+/* ******************* exported api ***************** */
+
+
+/* called whem no ghost system was initialized */
+void WM_setprefsize(int stax, int stay, int sizx, int sizy)
+{
+ prefstax= stax;
+ prefstay= stay;
+ prefsizx= sizx;
+ prefsizy= sizy;
+}
+
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
new file mode 100644
index 00000000000..0450adc1268
--- /dev/null
+++ b/source/blender/windowmanager/wm.h
@@ -0,0 +1,43 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef WM_H
+#define WM_H
+
+extern void wm_close_and_free(bContext *C, wmWindowManager *);
+extern void wm_close_and_free_all(bContext *C, ListBase *);
+
+extern void wm_add_default(bContext *C);
+extern void wm_check(bContext *C);
+
+/* wm_operator.c, for init/exit */
+void wm_operatortype_free(void);
+void wm_operatortype_init(void);
+
+
+#endif /* WM_H */
+
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
new file mode 100644
index 00000000000..f185ac791fe
--- /dev/null
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -0,0 +1,115 @@
+/**
+ * $Id: BIF_cursors.h 7739 2006-06-15 14:22:59Z broken $
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+
+
+#ifndef WM_CURSORS_H
+#define WM_CURSORS_H
+
+#define BC_GHOST_CURSORS 1000
+
+/* old cursors */
+enum {
+ CURSOR_FACESEL=BC_GHOST_CURSORS,
+ CURSOR_WAIT,
+ CURSOR_EDIT,
+ CURSOR_X_MOVE,
+ CURSOR_Y_MOVE,
+ CURSOR_HELP,
+ CURSOR_STD,
+ CURSOR_NONE,
+ CURSOR_PENCIL,
+};
+
+
+//typedef struct BCursor_s BCursor;
+typedef struct BCursor {
+
+ char *small_bm;
+ char *small_mask;
+
+ char small_sizex;
+ char small_sizey;
+ char small_hotx;
+ char small_hoty;
+
+ char *big_bm;
+ char *big_mask;
+
+ char big_sizex;
+ char big_sizey;
+ char big_hotx;
+ char big_hoty;
+
+ char fg_color;
+ char bg_color;
+
+} BCursor;
+
+#define LASTCURSOR -2
+#define SYSCURSOR -1
+enum {
+ BC_NW_ARROWCURSOR=0,
+ BC_NS_ARROWCURSOR,
+ BC_EW_ARROWCURSOR,
+ BC_WAITCURSOR,
+ BC_CROSSCURSOR,
+ BC_EDITCROSSCURSOR,
+ BC_BOXSELCURSOR,
+ BC_KNIFECURSOR,
+ BC_VLOOPCURSOR,
+ BC_TEXTEDITCURSOR,
+ BC_PAINTBRUSHCURSOR,
+ BC_HANDCURSOR,
+ BC_NSEW_SCROLLCURSOR,
+ BC_NS_SCROLLCURSOR,
+ BC_EW_SCROLLCURSOR,
+ BC_EYEDROPPER_CURSOR,
+/* --- ALWAYS LAST ----- */
+ BC_NUMCURSORS,
+};
+
+
+enum {
+ BC_BLACK=0,
+ BC_WHITE,
+ BC_RED,
+ BC_BLUE,
+ BC_GREEN,
+ BC_YELLOW
+};
+
+#define SMALL_CURSOR 0
+#define BIG_CURSOR 1
+
+#endif /* WM_CURSORS_H */
+
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
new file mode 100644
index 00000000000..9b918ce3cf6
--- /dev/null
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -0,0 +1,97 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef WM_EVENT_SYSTEM_H
+#define WM_EVENT_SYSTEM_H
+
+/* return value of handler-operator call */
+#define WM_HANDLER_CONTINUE 0
+#define WM_HANDLER_BREAK 1
+
+
+/* each event should have full modifier state */
+/* event comes from eventmanager and from keymap */
+typedef struct wmEvent {
+ struct wmEvent *next, *prev;
+
+ short type; /* event code itself (short, is also in keymap) */
+ short val; /* press, release, scrollvalue */
+ short x, y; /* mouse pointer position */
+ short unicode; /* future, ghost? */
+ char ascii; /* from ghost */
+ char pad1;
+
+ /* modifier states */
+ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
+ short keymodifier; /* rawkey modifier */
+
+ /* keymap item, set by handler (weak?) */
+ const char *keymap_idname;
+
+ /* custom data */
+ short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
+ void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
+
+} wmEvent;
+
+/* wmKeyMap is in DNA_windowmanager.h, it's savable */
+
+typedef struct wmEventHandler {
+ struct wmEventHandler *next, *prev;
+
+ int type, flag; /* type default=0, rest is custom */
+
+ ListBase *keymap; /* pointer to builtin/custom keymaps */
+
+ rctf boundbox; /* float, in bContext space (window, area, region) */
+
+ wmOperator *op; /* for derived handlers */
+
+} wmEventHandler;
+
+/* handler flag */
+ /* after this handler all others are ignored */
+#define WM_HANDLER_BLOCKING 1
+
+/* custom types for handlers, for signalling, freeing */
+enum {
+ WM_HANDLER_DEFAULT,
+ WM_HANDLER_TRANSFORM
+};
+
+
+void wm_event_free_all (wmWindow *win);
+wmEvent *wm_event_next (wmWindow *win);
+void wm_event_free_handlers (ListBase *lb);
+
+/* goes over entire hierarchy: events -> window -> screen -> area -> region */
+void wm_event_do_handlers(bContext *C);
+
+void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata);
+
+#endif /* WM_EVENT_SYSTEM_H */
+
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
new file mode 100644
index 00000000000..25d1e7c9c41
--- /dev/null
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -0,0 +1,255 @@
+/*
+ * $Id: wm_event_types.h
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/*
+ * These define have its origin at sgi, where all device defines were written down in device.h.
+ * Blender copied the conventions quite some, and expanded it with internal new defines (ton)
+ *
+ */
+
+
+#ifndef WM_EVENT_TYPES_H
+#define WM_EVENT_TYPES_H
+
+/* custom data type */
+#define EVT_TABLET 1
+
+/* MOUSE : 0x00x */
+#define LEFTMOUSE 0x001
+#define MIDDLEMOUSE 0x002
+#define RIGHTMOUSE 0x003
+#define MOUSEMOVE 0x004
+ /* only use if you want user option switch possible */
+#define ACTIONMOUSE 0x005
+#define SELECTMOUSE 0x006
+
+#define WHEELUPMOUSE 0x00a
+#define WHEELDOWNMOUSE 0x00b
+
+
+/* SYSTEM : 0x01x */
+#define KEYBD 0x010 /* keyboard */
+#define RAWKEYBD 0x011 /* raw keyboard for keyboard manager */
+#define REDRAW 0x012 /* used by port manager to signal redraws */
+#define INPUTCHANGE 0x013 /* input connected or disconnected */
+#define QFULL 0x014 /* queue was filled */
+#define WINFREEZE 0x015 /* user wants process in this win to shut up */
+#define WINTHAW 0x016 /* user wants process in this win to go again */
+#define WINCLOSE 0x017 /* window close */
+#define WINQUIT 0x018 /* signal from user that app is to go away */
+#define Q_FIRSTTIME 0x019 /* on startup */
+
+/* standard keyboard */
+
+#define AKEY 'a'
+#define BKEY 'b'
+#define CKEY 'c'
+#define DKEY 'd'
+#define EKEY 'e'
+#define FKEY 'f'
+#define GKEY 'g'
+#define HKEY 'h'
+#define IKEY 'i'
+#define JKEY 'j'
+#define KKEY 'k'
+#define LKEY 'l'
+#define MKEY 'm'
+#define NKEY 'n'
+#define OKEY 'o'
+#define PKEY 'p'
+#define QKEY 'q'
+#define RKEY 'r'
+#define SKEY 's'
+#define TKEY 't'
+#define UKEY 'u'
+#define VKEY 'v'
+#define WKEY 'w'
+#define XKEY 'x'
+#define YKEY 'y'
+#define ZKEY 'z'
+
+#define ZEROKEY '0'
+#define ONEKEY '1'
+#define TWOKEY '2'
+#define THREEKEY '3'
+#define FOURKEY '4'
+#define FIVEKEY '5'
+#define SIXKEY '6'
+#define SEVENKEY '7'
+#define EIGHTKEY '8'
+#define NINEKEY '9'
+
+#define CAPSLOCKKEY 211
+
+#define LEFTCTRLKEY 212
+#define LEFTALTKEY 213
+#define RIGHTALTKEY 214
+#define RIGHTCTRLKEY 215
+#define RIGHTSHIFTKEY 216
+#define LEFTSHIFTKEY 217
+
+#define ESCKEY 218
+#define TABKEY 219
+#define RETKEY 220
+#define SPACEKEY 221
+#define LINEFEEDKEY 222
+#define BACKSPACEKEY 223
+#define DELKEY 224
+#define SEMICOLONKEY 225
+#define PERIODKEY 226
+#define COMMAKEY 227
+#define QUOTEKEY 228
+#define ACCENTGRAVEKEY 229
+#define MINUSKEY 230
+#define SLASHKEY 232
+#define BACKSLASHKEY 233
+#define EQUALKEY 234
+#define LEFTBRACKETKEY 235
+#define RIGHTBRACKETKEY 236
+
+#define LEFTARROWKEY 137
+#define DOWNARROWKEY 138
+#define RIGHTARROWKEY 139
+#define UPARROWKEY 140
+
+#define PAD0 150
+#define PAD1 151
+#define PAD2 152
+#define PAD3 153
+#define PAD4 154
+#define PAD5 155
+#define PAD6 156
+#define PAD7 157
+#define PAD8 158
+#define PAD9 159
+
+
+#define PADPERIOD 199
+#define PADSLASHKEY 161
+#define PADASTERKEY 160
+
+
+#define PADMINUS 162
+#define PADENTER 163
+#define PADPLUSKEY 164
+
+
+#define F1KEY 300
+#define F2KEY 301
+#define F3KEY 302
+#define F4KEY 303
+#define F5KEY 304
+#define F6KEY 305
+#define F7KEY 306
+#define F8KEY 307
+#define F9KEY 308
+#define F10KEY 309
+#define F11KEY 310
+#define F12KEY 311
+
+#define PAUSEKEY 165
+#define INSERTKEY 166
+#define HOMEKEY 167
+#define PAGEUPKEY 168
+#define PAGEDOWNKEY 169
+#define ENDKEY 170
+
+#define UNKNOWNKEY 171
+#define COMMANDKEY 172
+#define GRLESSKEY 173
+
+/* used as fake leftmouse events, special handled in interface.c */
+#define BUT_ACTIVATE 200
+#define BUT_NEXT 201
+#define BUT_PREV 202
+
+/* **************** BLENDER QUEUE EVENTS ********************* */
+
+#define CHANGED 0x4000
+#define DRAWEDGES 0x4001
+#define AFTERQUEUE 0x4002
+#define BACKBUFDRAW 0x4003
+#define EXECUTE 0x4004
+#define IGNORE_REDRAW 0x4005
+#define LOAD_FILE 0x4006
+#define RESHAPE 0x4007
+#define UI_BUT_EVENT 0x4008
+#define AUTOSAVE_FILE 0x4009
+#define UNDOPUSH 0x400A
+
+/* REDRAWVIEW3D has to be the first one (lowest number) for buttons! */
+#define REDRAWVIEW3D 0x4010
+#define REDRAWVIEWCAM 0x4011
+#define REDRAWVIEW3D_Z 0x4012
+
+#define REDRAWALL 0x4013
+#define REDRAWHEADERS 0x4014
+
+#define REDRAWBUTSHEAD 0x4015
+#define REDRAWBUTSALL 0x4016
+
+#define REDRAWBUTSSCENE 0x4017
+#define REDRAWBUTSOBJECT 0x4018
+#define REDRAWBUTSEDIT 0x4019
+#define REDRAWBUTSSCRIPT 0x401A
+#define REDRAWBUTSLOGIC 0x401B
+#define REDRAWBUTSSHADING 0x401C
+#define REDRAWBUTSGAME 0x401D
+#define REDRAWBUTSEFFECTS 0x401D
+
+#define REDRAWINFO 0x4021
+#define RENDERPREVIEW 0x4022
+#define REDRAWIPO 0x4023
+#define REDRAWDATASELECT 0x4024
+#define REDRAWSEQ 0x4025
+#define REDRAWIMAGE 0x4026
+#define REDRAWOOPS 0x4027
+#define REDRAWIMASEL 0x4028
+#define AFTERIMASELIMA 0x4029
+#define AFTERIMASELGET 0x402A
+#define AFTERIMAWRITE 0x402B
+#define IMALEFTMOUSE 0x402C
+#define AFTERPIBREAD 0x402D
+#define REDRAWTEXT 0x402E
+#define REDRAWSOUND 0x402F
+#define REDRAWACTION 0x4030
+#define REDRAWNLA 0x4031
+#define REDRAWSCRIPT 0x4032
+#define REDRAWTIME 0x4033
+#define REDRAWBUTSCONSTRAINT 0x4034
+#define ONLOAD_SCRIPT 0x4035
+#define SCREEN_HANDLER 0x4036
+#define REDRAWANIM 0x4037
+#define REDRAWNODE 0x4038
+#define RECALC_COMPOSITE 0x4039
+#define REDRAWMARKER 0x4040 /* all views that display markers */
+#define REDRAWVIEW3D_IMAGE 0x4041
+
+#endif /* WM_EVENT_TYPES_H */
+
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
new file mode 100644
index 00000000000..3f54c388091
--- /dev/null
+++ b/source/blender/windowmanager/wm_files.h
@@ -0,0 +1,36 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef WM_FILES_H
+#define WM_FILES_H
+
+extern void read_Blog(void);
+extern void delete_autosave(void);
+
+
+#endif /* WM_FILES_H */
+
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
new file mode 100644
index 00000000000..3565bceac52
--- /dev/null
+++ b/source/blender/windowmanager/wm_window.h
@@ -0,0 +1,59 @@
+/**
+ * $Id: wm_window.h
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef WM_WINDOW_H
+#define WM_WINDOW_H
+
+struct bScreen;
+
+/* *************** internal api ************** */
+void wm_ghost_init (bContext *C);
+
+wmWindow *wm_window_new (bContext *C, struct bScreen *screen);
+void wm_window_free (bContext *C, wmWindow *win);
+void wm_window_add_ghostwindows (wmWindowManager *wm);
+void wm_window_process_events (int wait_for_event);
+
+void wm_window_make_drawable(bContext *C, wmWindow *win);
+
+void wm_window_raise (wmWindow *win);
+void wm_window_lower (wmWindow *win);
+void wm_window_set_size (wmWindow *win, int width, int height);
+void wm_window_get_size (wmWindow *win, int *width_r, int *height_r);
+void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r);
+void wm_window_set_title (wmWindow *win, char *title);
+void wm_window_swap_buffers (wmWindow *win);
+
+wmWindow *wm_window_copy (bContext *C, wmWindow *winorig);
+
+/* *************** window operators ************** */
+int wm_window_duplicate_op (bContext *C, wmOperator *op);
+
+
+#endif /* WM_WINDOW_H */
+