[Bf-blender-cvs] [b892c8a] pie-menus: X11 code that disables autorepeat.

Antony Riakiotakis noreply at git.blender.org
Thu Jul 31 18:38:21 CEST 2014


Commit: b892c8a4523357570d53d2a662ad7a4d34d80294
Author: Antony Riakiotakis
Date:   Thu Jul 31 18:38:06 2014 +0200
Branches: pie-menus
https://developer.blender.org/rBb892c8a4523357570d53d2a662ad7a4d34d80294

X11 code that disables autorepeat.

This makes it so as long as there is a pie menu active, autorepeat is
off. It is meant to cater for support for multiple coexisting pies in
the future too but no tests can be really made here yet.

===================================================================

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_ISystem.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_System.h
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_SystemX11.h
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 9b62307..52f505a 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -890,6 +890,12 @@ extern int GHOST_UseNativePixels(void);
 extern float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle);
 
 
+/**
+ * Turn auto repeat on/off.
+ */
+extern void GHOST_DisableAutoRepeat(void);
+extern void GHOST_EnableAutoRepeat(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 137926b..ec0edbe 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -414,6 +414,13 @@ public:
 	 * in the application
 	 */
 	virtual int confirmQuit(GHOST_IWindow *window) const = 0;
+
+	/**
+	 * Disables the auto-repeat function.
+	 */
+	virtual void disableAutoRepeat(void) = 0;
+	virtual void enableAutoRepeat(void) = 0;
+
 protected:
 	/**
 	 * Initialize the system.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index eaa59f0..bcff9cd 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -914,3 +914,14 @@ float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
 	return 1.0f;
 }
 
+extern void GHOST_DisableAutoRepeat(void)
+{
+	GHOST_ISystem *system = GHOST_ISystem::getSystem();
+	system->disableAutoRepeat();
+}
+
+extern void GHOST_EnableAutoRepeat(void)
+{
+	GHOST_ISystem *system = GHOST_ISystem::getSystem();
+	system->enableAutoRepeat();
+}
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 57aa0a3..a09ad45 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -167,6 +167,13 @@ public:
 	 */
 	virtual bool getFullScreen(void);
 
+
+	/**
+	 * Disables the auto-repeat function.
+	 */
+	virtual void disableAutoRepeat(void) {}
+	virtual void enableAutoRepeat(void) {}
+
 	
 	/**
 	 * Native pixel size support (MacBook 'retina').
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 4d9fd56..3095067 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2064,4 +2064,15 @@ void GHOST_SystemX11::initXInputDevices()
 	}
 }
 
+void GHOST_SystemX11::disableAutoRepeat(void)
+{
+	XAutoRepeatOff(m_display);
+}
+
+void GHOST_SystemX11::enableAutoRepeat(void)
+{
+	XAutoRepeatOn(m_display);
+}
+
+
 #endif /* WITH_X11_XINPUT */
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index 1f95e4b..4596138 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -387,6 +387,12 @@ private:
 	bool
 	generateWindowExposeEvents(
 	    );
+
+	/**
+	 * Disables the auto-repeat function.
+	 */
+	void disableAutoRepeat(void);
+	void enableAutoRepeat(void);
 };
 
 #endif
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index bb5872f..ab29a3e 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8686,6 +8686,8 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 		if ((event->type == block->pie_data.event && event->val == KM_RELEASE) ||
 		     ((event->type == RIGHTMOUSE || event->type == ESCKEY) && (event->val == KM_PRESS)))
 		{
+			WM_menu_pie_enable_autorepeat(C);
+
 			menu->menuretval = UI_RETURN_OK;
 		}
 
@@ -8708,6 +8710,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 
 			if (len_squared_v2(seg) < PIE_CLICK_THRESHOLD) {
 				block->pie_data.flags |= UI_PIE_CLICK_STYLE;
+				WM_menu_pie_enable_autorepeat(C);
 			}
 			else if (!is_click_style) {
 				uiBut *but = ui_but_find_activated(menu->region);
@@ -8738,11 +8741,11 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 			case RIGHTMOUSE:
 				if (!is_click_style) {
 					block->pie_data.flags |= UI_PIE_FINISHED;
-					menu->menuretval = 0;
 					ED_region_tag_redraw(ar);
 				}
-				else
+				else {
 					menu->menuretval = UI_RETURN_CANCEL;
+				}
 				break;
 
 			case AKEY:
@@ -8810,6 +8813,9 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
 		}
 	}
 
+	if (menu->retvalue && !is_click_style)
+		WM_menu_pie_enable_autorepeat(C);
+
 	return retval;
 }
 
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index ae14fb3..e2e980b 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2682,6 +2682,8 @@ struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon
 	uiPieMenu *pie = MEM_callocN(sizeof(uiPopupMenu), "pie menu");
 
 	pie->block_radial = uiBeginBlock(C, NULL, __func__, UI_EMBOSS);
+
+	WM_menu_pie_disable_autorepeat(C);
 	/* may be useful later to allow spawning pies
 	 * from old positions */
 	/* pie->block_radial->flag |= UI_BLOCK_POPUP_MEMORY; */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index a17e416..f6371a3 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -156,7 +156,8 @@ typedef struct wmWindowManager {
 	struct wmTimer *autosavetimer;    /* timer for auto save */
 
 	char is_interface_locked;		/* indicates whether interface is locked for user interaction */
-	char par[7];
+	char par[3];
+	int active_pie_menus;           /* counts active pie menus. useful to turn auto-repeat on and off */
 } wmWindowManager;
 
 /* wmWindowManager.initialized */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 62bedf6..15f01c3 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -281,6 +281,11 @@ struct PointerRNA *WM_operator_property_pie_macro(const char *idname, const char
 /* call operator or call pie menu from expanded enum path property */
 struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *name, const char *description,
                                               int flag, const char *piename, const char *opname, const char *path);
+
+
+void WM_menu_pie_enable_autorepeat(struct bContext *C);
+void WM_menu_pie_disable_autorepeat(struct bContext *C);
+
 /* MOVE THIS SOMEWHERE ELSE */
 #define	SEL_TOGGLE		0
 #define	SEL_SELECT		1
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 46a897a..90f94bf 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3511,3 +3511,31 @@ struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *na
 	return NULL;
 }
 
+
+void WM_menu_pie_enable_autorepeat(struct bContext *C)
+{
+	wmWindowManager *manager = CTX_wm_manager(C);
+
+	manager->active_pie_menus--;
+
+	if (manager->active_pie_menus < 0) {
+		manager->active_pie_menus = 0;
+		printf("Window Manager: Pie Menus cleanup error\n");
+		fflush(stdout);
+	}
+
+	if (manager->active_pie_menus == 0)
+		GHOST_EnableAutoRepeat();
+
+}
+
+void WM_menu_pie_disable_autorepeat(struct bContext *C)
+{
+	wmWindowManager *manager = CTX_wm_manager(C);
+
+	if (manager->active_pie_menus == 0)
+		GHOST_DisableAutoRepeat();
+
+	manager->active_pie_menus++;
+}
+




More information about the Bf-blender-cvs mailing list