Disable cocoa's window tabbing and special menu items

This commit is contained in:
Kovid Goyal 2019-08-07 09:39:54 +05:30
parent 08081eaebb
commit 39d08d70fa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 36 additions and 1 deletions

View File

@ -872,6 +872,8 @@ class Application(QApplication):
QApplication.setDesktopFileName(override_program_name) QApplication.setDesktopFileName(override_program_name)
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True) # needed for webengine QApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True) # needed for webengine
QApplication.__init__(self, qargs) QApplication.__init__(self, qargs)
if isosx:
plugins['cocoa'][0].disable_cocoa_ui_elements()
self.setAttribute(Qt.AA_UseHighDpiPixmaps) self.setAttribute(Qt.AA_UseHighDpiPixmaps)
self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False) self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False)
try: try:

View File

@ -5,10 +5,29 @@
* Distributed under terms of the GPL3 license. * Distributed under terms of the GPL3 license.
*/ */
#import <AppKit/AppKit.h>
#import <AppKit/NSWindow.h>
#import <Availability.h>
#include <Cocoa/Cocoa.h>
#include <string.h> #include <string.h>
void
disable_window_tabbing(void) {
if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)])
NSWindow.allowsAutomaticWindowTabbing = NO;
}
void
remove_cocoa_menu_items(void) {
// Remove (disable) the "Start Dictation..." and "Emoji & Symbols" menu
// items from the "Edit" menu
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"];
// Remove (don't have) the "Enter Full Screen" menu item from the "View" menu
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
}
void void
activate_cocoa_multithreading(void) { activate_cocoa_multithreading(void) {
if (![NSThread isMultiThreaded]) [[NSThread new] start]; if (![NSThread isMultiThreaded]) [[NSThread new] start];

View File

@ -11,6 +11,8 @@ extern double cocoa_cursor_blink_time(void);
extern void cocoa_send_notification(const char *identitifer, const char *title, const char *subtitle, const char *informativeText, const char* path_to_image); extern void cocoa_send_notification(const char *identitifer, const char *title, const char *subtitle, const char *informativeText, const char* path_to_image);
extern const char* cocoa_send2trash(const char *utf8_path); extern const char* cocoa_send2trash(const char *utf8_path);
extern void activate_cocoa_multithreading(void); extern void activate_cocoa_multithreading(void);
extern void disable_window_tabbing(void);
extern void remove_cocoa_menu_items(void);
static PyObject *notification_activated_callback = NULL; static PyObject *notification_activated_callback = NULL;
@ -70,11 +72,23 @@ enable_cocoa_multithreading(PyObject *self, PyObject *args) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject*
disable_cocoa_ui_elements(PyObject *self, PyObject *args) {
PyObject *tabbing = Py_True, *menu_items = Py_True;
if (!PyArg_ParseTuple(args, "|OO", &tabbing, &menu_items)) return NULL;
if (PyObject_IsTrue(tabbing)) disable_window_tabbing();
if (PyObject_IsTrue(menu_items) remove_cocoa_menu_items();
Py_RETURN_NONE;
}
static PyMethodDef module_methods[] = { static PyMethodDef module_methods[] = {
{"cursor_blink_time", (PyCFunction)cursor_blink_time, METH_NOARGS, ""}, {"cursor_blink_time", (PyCFunction)cursor_blink_time, METH_NOARGS, ""},
{"enable_cocoa_multithreading", (PyCFunction)enable_cocoa_multithreading, METH_NOARGS, ""}, {"enable_cocoa_multithreading", (PyCFunction)enable_cocoa_multithreading, METH_NOARGS, ""},
{"set_notification_activated_callback", (PyCFunction)set_notification_activated_callback, METH_O, ""}, {"set_notification_activated_callback", (PyCFunction)set_notification_activated_callback, METH_O, ""},
{"send_notification", (PyCFunction)send_notification, METH_VARARGS, ""}, {"send_notification", (PyCFunction)send_notification, METH_VARARGS, ""},
{"disable_cocoa_ui_elements", (PyCFunction)disable_cocoa_ui_elements, METH_VARARGS, ""},
{"send2trash", (PyCFunction)send2trash, METH_VARARGS, ""}, {"send2trash", (PyCFunction)send2trash, METH_VARARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */ {NULL, NULL, 0, NULL} /* Sentinel */
}; };