-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Elsie Hupp <[email protected]>
- Loading branch information
Showing
8 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#import <AppKit/NSApplication.h> | ||
|
||
/** | ||
* @brief CocoaProcessType provides methods for moving the application between | ||
* the background and foreground. | ||
* @ingroup gui | ||
*/ | ||
|
||
#ifndef COCOAPROCESSTYPE_H | ||
#define COCOAPROCESSTYPE_H | ||
|
||
@interface CocoaProcessType : NSApplication | ||
|
||
/** | ||
* @brief CocoaProcessTypeToForeground() enables the macOS menubar and dock icon, which are necessary for a maximized window to be able to exit full screen. | ||
* @ingroup gui | ||
*/ | ||
+ (void)ToForeground; | ||
|
||
/** | ||
* @brief CocoaProcessTypeToBackground() disables the macOS menubar and dock icon, so that the application will only be present as a menubar icon. | ||
* @ingroup gui | ||
*/ | ||
+ (void)ToBackground; | ||
|
||
@end | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "foregroundbackground_cocoa.h" | ||
#include "common/utility.h" | ||
|
||
@implementation CocoaProcessType | ||
|
||
+ (void)ToForeground | ||
{ | ||
NSApplicationLoad(); | ||
ProcessSerialNumber processSerialNumber = { 0, kCurrentProcess }; | ||
TransformProcessType(&processSerialNumber, kProcessTransformToForegroundApplication); | ||
} | ||
|
||
+ (void)ToBackground | ||
{ | ||
NSApplicationLoad(); | ||
ProcessSerialNumber processSerialNumber = { 0, kCurrentProcess }; | ||
TransformProcessType(&processSerialNumber, kProcessTransformToUIElementApplication); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "foregroundbackground_interface.h" | ||
|
||
bool ForegroundBackground::eventFilter(QObject * /*obj*/, QEvent *event) | ||
{ | ||
if (event->type() == QEvent::Show) { | ||
ToForeground(); | ||
return true; | ||
} | ||
if (event->type() == QEvent::Close) { | ||
ToBackground(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void ForegroundBackground::ToForeground() | ||
{ | ||
// To be implemented | ||
return; | ||
} | ||
|
||
void ForegroundBackground::ToBackground() | ||
{ | ||
// To be implemented | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @brief ForegroundBackgroundInterface allows ForegroundBackground to be implemented differently per platform | ||
* @ingroup gui | ||
*/ | ||
|
||
#ifndef FOREGROUNDBACKGROUND_INTERFACE_H | ||
#define FOREGROUNDBACKGROUND_INTERFACE_H | ||
|
||
#include <QObject> | ||
#include <QEvent> | ||
|
||
namespace OCC { | ||
namespace Ui { | ||
|
||
class ForegroundBackground; | ||
|
||
} | ||
} | ||
|
||
class ForegroundBackground : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
ForegroundBackground() = default; | ||
~ForegroundBackground() = default; | ||
|
||
/** | ||
* @brief EventFilter catches events that should trigger ForegroundBackground | ||
* @ingroup gui | ||
*/ | ||
bool eventFilter(QObject *obj, QEvent *event) override; | ||
|
||
private: | ||
/** | ||
* @brief ToForeground() enables the macOS menubar and dock icon, which are necessary for a maximized window to be able to exit full screen. | ||
* @ingroup gui | ||
*/ | ||
void ToForeground(); | ||
|
||
/** | ||
* @brief ToBackground() disables the macOS menubar and dock icon, so that the application will only be present as a menubar icon. | ||
* @ingroup gui | ||
*/ | ||
void ToBackground(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "foregroundbackground_interface.h" | ||
#include "foregroundbackground_cocoa.h" | ||
|
||
bool ForegroundBackground::eventFilter(QObject * /*obj*/, QEvent *event) | ||
{ | ||
if (event->type() == QEvent::Show) { | ||
ToForeground(); | ||
return true; | ||
} | ||
if (event->type() == QEvent::Close) { | ||
ToBackground(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void ForegroundBackground::ToForeground() | ||
{ | ||
[CocoaProcessType ToForeground]; | ||
} | ||
|
||
void ForegroundBackground::ToBackground() | ||
{ | ||
[CocoaProcessType ToBackground]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) by Elsie Hupp <gpl at elsiehupp dot com> | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "foregroundbackground_interface.h" | ||
|
||
bool ForegroundBackground::eventFilter(QObject * /*obj*/, QEvent *event) | ||
{ | ||
if (event->type() == QEvent::Show) { | ||
ToForeground(); | ||
return true; | ||
} | ||
if (event->type() == QEvent::Close) { | ||
ToBackground(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void ForegroundBackground::ToForeground() | ||
{ | ||
// To be implemented | ||
return; | ||
} | ||
|
||
void ForegroundBackground::ToBackground() | ||
{ | ||
// To be implemented | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters