Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished notifications #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Build/.DS_Store
Binary file not shown.
Binary file modified Build/Screen.u_xcomp/Contents/MacOS/Screen
Binary file not shown.
Binary file not shown.
22 changes: 0 additions & 22 deletions Build/Screen.u_xcomp/Contents/_CodeSignature/CodeResources
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
<data>
yihQNYOsLVDCPkyIDQ49JAE04lY=
</data>
<key>Resources/English.lproj/InfoPlist.strings</key>
<dict>
<key>hash</key>
<data>
RrYQ92PgFYyvBz1akaG1TXp+2Nw=
</data>
<key>optional</key>
<true/>
</dict>
<key>Resources/GENERIC.PNG</key>
<data>
29DpZc5azEl6hRRHzRg5UbxPeco=
Expand All @@ -39,19 +30,6 @@
dq2kAxKxNO8qeNhMdnnHCmhO3dLQrCF3NwTjY9UvnE4=
</data>
</dict>
<key>Resources/English.lproj/InfoPlist.strings</key>
<dict>
<key>hash</key>
<data>
RrYQ92PgFYyvBz1akaG1TXp+2Nw=
</data>
<key>hash2</key>
<data>
my2FlytJxKUQqUgy2Hngfd1Ofv8oRUeMNCOllOUmnto=
</data>
<key>optional</key>
<true/>
</dict>
<key>Resources/GENERIC.PNG</key>
<dict>
<key>hash</key>
Expand Down
2 changes: 1 addition & 1 deletion English.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Screen</string>
<string>generic</string>
</dict>
</plist>
3 changes: 0 additions & 3 deletions English.lproj/Screen.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

1 BITMAP DISCARDABLE "GENERIC.BMP"

STRINGTABLE DISCARDABLE
Expand All @@ -11,5 +10,3 @@ BEGIN
8001 "$dock:$dock() Returns a list with a single row, detailing the position and height of the dock. position code: -1 is left, 0 is bottom, 1 is right"
7000 "$currentScreens:$currentScreens() Returns a list of screens, cached and updated automatically when the screens change"
END


21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Now copy the package tools/omnisrc64.app to xcode's tools folder, like this:

Still in OSX-SDK-10.1, clone the git repo

`git clone git@github.com:suransys/screen-xcomp.git`
`git clone ssh://git@bitbucket.suran.com:7999/sda/screen-xcomp.git`

In Finder, open the new cloned directory, called screen-xcomp. Open the package Screen.xcodeproj using Xcode (Clicking on this file should open it with Xcode automatically)

Expand Down Expand Up @@ -81,7 +81,3 @@ ________________
`position` is an integer, either -1, 0, or 1. This tells you whether the dock is on the left, bottom, or right side of the screen, respectively

`height` is the height of the dock, measured from its anchoring wall. So if the dock is anchored to the right or left side, then "height" will technically be the width, since the dock is sideways

## Contributing
Please see our [guide to contributing](https://github.com/suransys/contributing).

4 changes: 1 addition & 3 deletions Screen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
0C962E332411532200894DDF /* ObjCScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C962E322411532200894DDF /* ObjCScreen.m */; };
0C962E362411538700894DDF /* ScreenInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0C962E352411538700894DDF /* ScreenInterface.mm */; };
2D7566E417BE308C001F871F /* Screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D7566E317BE308C001F871F /* Screen.cpp */; };
2D7DE4B517CE03B300642BA9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2D7DE4B217CE03B300642BA9 /* InfoPlist.strings */; };
2DAD106F17BCEE60005A7F56 /* u_complib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DAD106E17BCEE60005A7F56 /* u_complib.framework */; };
2DD7697817BBA5F4005F1CFB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DD7697717BBA5F4005F1CFB /* Cocoa.framework */; };
2DDD8B9217F437A200F4E765 /* Screen.rc in Resources */ = {isa = PBXBuildFile; fileRef = 2D7DE4B017CE03B300642BA9 /* Screen.rc */; };
Expand All @@ -28,7 +27,7 @@
outputFiles = (
"$(TEMP_FILE_DIR)/omnisrc/Localizable.strings",
);
script = "$DEVELOPER_TOOLS_DIR/omnisrc64.app/Contents/MacOS/omnisrc64 INPUT_FILE_PATH TEMP_FILE_DIR REZ_SEARCH_PATHS XCOMP\nif [ -f $TEMP_FILE_DIR/omnisrc/Bitmap.strings ]; then\ncp $TEMP_FILE_DIR/omnisrc/Bitmap.strings $INSTALL_DIR/$CONTENTS_FOLDER_PATH/Resources\nfi\nshopt -s nullglob\nif [ ! -z \"`echo $TEMP_FILE_DIR/omnisrc/*.PNG`\" ]; then\ncp $TEMP_FILE_DIR/omnisrc/*.PNG $INSTALL_DIR/$CONTENTS_FOLDER_PATH/Resources\nfi";
script = "$DEVELOPER_TOOLS_DIR/omnisrc64.app/Contents/MacOS/omnisrc64 INPUT_FILE_PATH TEMP_FILE_DIR REZ_SEARCH_PATHS XCOMP\nif [ -f $TEMP_FILE_DIR/omnisrc/Bitmap.strings ]; then\ncp $TEMP_FILE_DIR/omnisrc/Bitmap.strings $INSTALL_DIR/$CONTENTS_FOLDER_PATH/Resources\nfi\nshopt -s nullglob\nif [ ! -z \"`echo $TEMP_FILE_DIR/omnisrc/*.PNG`\" ]; then\ncp $TEMP_FILE_DIR/omnisrc/*.PNG $INSTALL_DIR/$CONTENTS_FOLDER_PATH/Resources\nfi\n";
};
/* End PBXBuildRule section */

Expand Down Expand Up @@ -186,7 +185,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2D7DE4B517CE03B300642BA9 /* InfoPlist.strings in Resources */,
2DDD8B9217F437A200F4E765 /* Screen.rc in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
5 changes: 0 additions & 5 deletions Src/ObjCScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@

@interface ObjCScreen : NSObject

@property void (*callback)(void*);
@property void * userInfo;

-(NSArray<NSScreen*>*)getObjCScreens;
-(NSScreen *)getMainScreen;
-(int)getDockLocation;

-(void)setScreensChangedNotification:(void (*)(void*))callback withUserInfo:(void *) userInfo;

@end


Expand Down
10 changes: 0 additions & 10 deletions Src/ObjCScreen.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,4 @@ -(int)getDockLocation{
return INT_MAX;
}

-(void)setScreensChangedNotification:(void (*)(void*))callback withUserInfo:(void *)userInfo{
self.callback = callback;
self.userInfo = userInfo;
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(onScreenChanged:) name:NSApplicationDidChangeScreenParametersNotification object:nil];
}

-(void)onScreenChanged:(NSNotification*)notification{
self.callback(self.userInfo);
}

@end
38 changes: 31 additions & 7 deletions Src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ void staticOnScreenChanged(std::vector<Screen> screens, void* userInfo){
}

ScreenObject::ScreenObject(){
updatingScreen = UpdatingScreen();
currentScreens = updatingScreen.getCurrentScreens();
updatingScreen.setScreenChangeCallback(staticOnScreenChanged, this);
updatingScreen.screenRunLoop();
currentScreens = Screen::screenList();
}

EXTfldval ScreenObject::staticMethodCall(qlong methodId){
Expand Down Expand Up @@ -207,6 +204,30 @@ void ScreenObject::onScreenChanged(std::vector<Screen> screens){
currentScreens = screens;
}

@interface screenObserver : NSObject
{
}
@property void (*callback)(std::vector<Screen>, void*);
@property void* target;

-(void)setScreenChangeCallback:(void (*)(std::vector<Screen>, void*))callback onTarget:(void *)target;
@end

@implementation screenObserver
-(void)didChangeScreenParameters: (NSNotification*)notification
{
if (!self.callback) return;
self.callback(Screen::screenList(), self.target);
}

-(void)setScreenChangeCallback:(void (*)(std::vector<Screen>, void *))callback onTarget:(void *)target{
self.target = target;
self.callback = callback;
}
@end

screenObserver* gObserver;


// Component library entry point (name as declared in resource 31000 )
extern "C" LRESULT OMNISWNDPROC ScreenWndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, EXTCompInfo* eci)
Expand All @@ -223,10 +244,13 @@ extern "C" LRESULT OMNISWNDPROC ScreenWndProc(HWND hwnd, UINT Msg, WPARAM wParam
// For most components this can be removed - see other BLYTH component examples
case ECM_CONNECT:
{
return EXT_FLAG_LOADED|EXT_FLAG_ALWAYS_USABLE|EXT_FLAG_NVOBJECTS; // Return external flags
gObserver = [[screenObserver alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:gObserver selector:@selector(didChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:[NSApplication sharedApplication]];
return EXT_FLAG_LOADED|EXT_FLAG_ALWAYS_USABLE|EXT_FLAG_NVOBJECTS;
}
case ECM_OBJCONSTRUCT:{
ScreenObject * screenObject = new ScreenObject();
[gObserver setScreenChangeCallback:staticOnScreenChanged onTarget:screenObject];
ECOinsertObject(eci, hwnd, (void*)screenObject);
return qtrue;
}
Expand All @@ -245,6 +269,8 @@ extern "C" LRESULT OMNISWNDPROC ScreenWndProc(HWND hwnd, UINT Msg, WPARAM wParam
// For most components this can be removed - see other BLYTH component examples
case ECM_DISCONNECT:
{
[[NSNotificationCenter defaultCenter] removeObserver:gObserver];
gObserver = nil;
return qtrue;
}

Expand Down Expand Up @@ -273,8 +299,6 @@ extern "C" LRESULT OMNISWNDPROC ScreenWndProc(HWND hwnd, UINT Msg, WPARAM wParam
case ECM_GETOBJECT:{
return ECOreturnObjects(gInstLib, eci, &screenObject[0], OBJECT_COUNT);
}
// case ECM_GETMETHODNAME:
// return ECOreturnMethods(gInstLib, eci, &screensFunction[0], NUMBER_OF_METHODS);
case ECM_METHODCALL:{
ScreenObject * object = (ScreenObject*)ECOfindObject(eci, hwnd);
if (!object) {
Expand Down
2 changes: 0 additions & 2 deletions Src/Screen.he
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ScreenObject
{
private:
std::vector<Screen> currentScreens;
UpdatingScreen updatingScreen;

static EXTqlist * retrieveScreens();
static EXTqlist * screenListFromVector(std::vector<Screen>);
Expand All @@ -21,7 +20,6 @@ private:
static EXTqlist * retrieveDock();

public:

ScreenObject();

static EXTfldval staticMethodCall(qlong);
Expand Down
20 changes: 0 additions & 20 deletions Src/ScreenInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,4 @@ class Screen {
static int dockPosition();
};



class UpdatingScreen{
std::vector<Screen> currentScreens;
void notifyScreensChanged();
static void screensChangedCallback(void*);
void (*_onScreenChanged)(std::vector<Screen>, void*);
void * currentUserInfo;

void * objCScreen;
public:
UpdatingScreen();

std::vector<Screen> getCurrentScreens();
void setScreenChangeCallback(void (*onScreenChanged)(std::vector<Screen>, void*), void* userInfo);
void resetCurrentScreens();
void screenRunLoop();
void screenEndLoop();
};

#endif /* Screen_hpp */
44 changes: 0 additions & 44 deletions Src/ScreenInterface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,4 @@
}


void UpdatingScreen::screensChangedCallback(void *userInfo){
if (!userInfo) return;
UpdatingScreen * instUpdatingScreen = (UpdatingScreen*)userInfo;
if (!instUpdatingScreen) return;
instUpdatingScreen -> resetCurrentScreens();
}

UpdatingScreen::UpdatingScreen(){
currentScreens = Screen::screenList();

ObjCScreen * localScreen =[[ObjCScreen alloc] init];
[localScreen setScreensChangedNotification:screensChangedCallback withUserInfo:this];

objCScreen = (__bridge void*)localScreen;
}

void UpdatingScreen::setScreenChangeCallback(void (*onScreenChanged)(std::vector<Screen>, void*), void* userInfo){
_onScreenChanged = onScreenChanged;
currentUserInfo = userInfo;
}

void UpdatingScreen::notifyScreensChanged(){
if (_onScreenChanged){
_onScreenChanged(currentScreens, currentUserInfo);
}
}

void UpdatingScreen::resetCurrentScreens(){
currentScreens = Screen::screenList();
notifyScreensChanged();
}

void UpdatingScreen::screenRunLoop(){
NSApplicationLoad();
CFRunLoopRun();
}


void UpdatingScreen::screenEndLoop(){
CFRunLoopStop(CFRunLoopGetCurrent());
}

std::vector<Screen> UpdatingScreen::getCurrentScreens(){
return currentScreens;
}
Binary file added UnicodeCore.build/.DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions UnicodeCore.build/Objects-normal/x86_64/ObjCScreen.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies: \
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/complib/u_complib.framework/Headers/omnisinc.h \
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/../complib/u_complib.framework/Headers/carbnuni.h \
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/Src/ObjCScreen.m \
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/Src/ObjCScreen.h
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/complib/u_complib.framework/Headers/omnisinc.h \
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/../complib/u_complib.framework/Headers/carbnuni.h \
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/Src/ObjCScreen.m \
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/Src/ObjCScreen.h
Binary file modified UnicodeCore.build/Objects-normal/x86_64/ObjCScreen.o
Binary file not shown.
6 changes: 3 additions & 3 deletions UnicodeCore.build/Objects-normal/x86_64/Screen.LinkFileList
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/Screen.o
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/ObjCScreen.o
/Users/malachi/Documents/learning/c++/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/ScreenInterface.o
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/Screen.o
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/ObjCScreen.o
/Users/malachi/Documents/Suran/Code/OSX-SDK-10.1/screen-xcomp/UnicodeCore.build/Objects-normal/x86_64/ScreenInterface.o
Loading