mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-06-01 12:41:27 +00:00
some fixes, including miscalulation on bounds checking for quickdraw commands, remove some logging from memory error research, refactor chat message count function and add logging on current vs previous message objects to determine phantom beeping, hopefully final test release
This commit is contained in:
parent
0158121fe1
commit
3985d86486
|
@ -5,7 +5,7 @@ const createHttpLink = require('apollo-link-http').createHttpLink;
|
|||
const gql = require('graphql-tag')
|
||||
|
||||
// TEST_MODE can be turned on or off to prevent communications with the Apollo iMessage Server running on your modern Mac
|
||||
const TEST_MODE = false
|
||||
const TEST_MODE = true
|
||||
const DEBUG = false
|
||||
let lastMessageFromSerialPortTime
|
||||
|
||||
|
|
BIN
dist/MessagesForMacintosh.dsk
vendored
BIN
dist/MessagesForMacintosh.dsk
vendored
Binary file not shown.
BIN
dist/MessagesForMacintosh.zip
vendored
BIN
dist/MessagesForMacintosh.zip
vendored
Binary file not shown.
28
mac_main.c
28
mac_main.c
|
@ -25,7 +25,7 @@
|
|||
|
||||
// #define MAC_APP_DEBUGGING
|
||||
// #define PROFILING 1
|
||||
#define DEBUG_FUNCTION_CALLS
|
||||
// #define DEBUG_FUNCTION_CALLS
|
||||
#ifdef PROFILING
|
||||
|
||||
OSErr writeSerialPortProfile(const char* str)
|
||||
|
@ -182,7 +182,6 @@ void EventLoop(struct nk_context *ctx)
|
|||
int lastMouseVPos = 0;
|
||||
int lastUpdatedTickCountMessagesInChat = 0;
|
||||
int lastUpdatedTickCountChatCounts = 0;
|
||||
Boolean gotNewMessages = false;
|
||||
|
||||
do {
|
||||
|
||||
|
@ -198,17 +197,10 @@ void EventLoop(struct nk_context *ctx)
|
|||
ShowCursor();
|
||||
}
|
||||
|
||||
gotNewMessages = false;
|
||||
|
||||
// check for new stuff every 10 sec?
|
||||
// note! this is used by some of the functionality in our nuklear_app to trigger
|
||||
// new chat lookups
|
||||
if (TickCount() - lastUpdatedTickCountMessagesInChat > 600) {
|
||||
|
||||
gotNewMessages = true;
|
||||
|
||||
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
||||
lastUpdatedTickCountMessagesInChat = TickCount();
|
||||
if (TickCount() - lastUpdatedTickCountMessagesInChat > 300) {
|
||||
|
||||
if (strcmp(activeChat, "no active chat")) {
|
||||
|
||||
|
@ -218,8 +210,8 @@ void EventLoop(struct nk_context *ctx)
|
|||
}
|
||||
|
||||
// this should be out of sync with the counter above it so that we dont end up making
|
||||
// two coprocessor calls on one event loop iteration
|
||||
if (!gotNewMessages && TickCount() - lastUpdatedTickCountChatCounts > 300) {
|
||||
// two coprocessor calls on one event loop iteratio
|
||||
if (TickCount() - lastUpdatedTickCountChatCounts > 600) {
|
||||
|
||||
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
||||
lastUpdatedTickCountChatCounts = TickCount();
|
||||
|
@ -319,18 +311,6 @@ void EventLoop(struct nk_context *ctx)
|
|||
// only re-render if there is an event, prevents screen flickering, speeds up app
|
||||
if (beganInput || firstOrMouseMove || forceRedraw) {
|
||||
|
||||
if (beganInput) {
|
||||
writeSerialPortDebug(boutRefNum, "beganInput");
|
||||
}
|
||||
|
||||
if (beganInput) {
|
||||
writeSerialPortDebug(boutRefNum, "beganInput");
|
||||
}
|
||||
|
||||
if (forceRedraw) {
|
||||
writeSerialPortDebug(boutRefNum, "forceRedraw");
|
||||
}
|
||||
|
||||
#ifdef PROFILING
|
||||
PROFILE_START("nk_input_end");
|
||||
#endif
|
||||
|
|
|
@ -181,14 +181,16 @@ void sendMessage() {
|
|||
|
||||
memset(&box_input_buffer, '\0', 2048);
|
||||
box_input_len = 0;
|
||||
refreshNuklearApp(1);
|
||||
|
||||
// this was an attempt to get the text in the textbox to go away... doesn't really work for a few more redraws
|
||||
// so actually just makes things slower:
|
||||
// refreshNuklearApp(1);
|
||||
|
||||
callFunctionOnCoprocessor("sendMessage", output, jsFunctionResponse);
|
||||
|
||||
getMessagesFromjsFunctionResponse();
|
||||
|
||||
forceRedraw = 2;
|
||||
firstOrMouseMove = true;
|
||||
forceRedraw = 3;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -205,9 +207,10 @@ void getChats() {
|
|||
|
||||
callFunctionOnCoprocessor("getChats", "", jsFunctionResponse);
|
||||
|
||||
char * token = (char *)strtokm(jsFunctionResponse, ",");
|
||||
// loop through the string to extract all other tokens
|
||||
char *token = (char *)strtokm(jsFunctionResponse, ",");
|
||||
|
||||
while (token != NULL) {
|
||||
|
||||
writeSerialPortDebug(boutRefNum, token);
|
||||
sprintf(chatFriendlyNames[chatFriendlyNamesCounter++], "%s", token);
|
||||
token = (char *)strtokm(NULL, ",");
|
||||
|
@ -238,7 +241,7 @@ void sendIPAddressToCoprocessor() {
|
|||
|
||||
// set up function to get messages in current chat
|
||||
// limit to recent messages
|
||||
// figure out pagination?? button on the top that says "get previous chats"?
|
||||
// figure out pagination?? button on the top that says "get previous chats"?, TODO
|
||||
void getMessages(char *thread, int page) {
|
||||
|
||||
#ifdef DEBUG_FUNCTION_CALLS
|
||||
|
@ -284,12 +287,18 @@ void getChatCounts() {
|
|||
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
||||
#endif
|
||||
|
||||
if (strcmp(chatCountFunctionResponse, previousChatCountFunctionResponse)) {
|
||||
// bail out if the responses ARE equal
|
||||
if (!strcmp(chatCountFunctionResponse, previousChatCountFunctionResponse)) {
|
||||
|
||||
#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "no need to update current chat count");
|
||||
return;
|
||||
}
|
||||
|
||||
//#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "update current chat count");
|
||||
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
||||
#endif
|
||||
writeSerialPortDebug(boutRefNum, previousChatCountFunctionResponse);
|
||||
//#endif
|
||||
|
||||
SysBeep(1);
|
||||
|
||||
|
@ -418,10 +427,6 @@ void getChatCounts() {
|
|||
|
||||
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
|
||||
forceRedraw = 3;
|
||||
} else {
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "no need to update current chat count");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -446,9 +451,6 @@ void getHasNewMessagesInChat(char *thread) {
|
|||
writeSerialPortDebug(boutRefNum, "update current chat");
|
||||
SysBeep(1);
|
||||
getMessages(thread, 0);
|
||||
|
||||
// force redraw
|
||||
forceRedraw = 3;
|
||||
} else {
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "do not update current chat");
|
||||
|
|
|
@ -451,16 +451,16 @@ NK_API NkQuickDrawFont* nk_quickdraw_font_create_from_file() {
|
|||
}
|
||||
|
||||
// used for bounds checking
|
||||
int mostLeft = 1;
|
||||
int mostLeft = WINDOW_WIDTH;
|
||||
int mostBottom = 1;
|
||||
int mostTop = WINDOW_HEIGHT;
|
||||
int mostRight = WINDOW_WIDTH;
|
||||
int mostRight = 1;
|
||||
|
||||
void updateBounds(int top, int bottom, int left, int right) {
|
||||
|
||||
#ifdef DEBUG_FUNCTION_CALLS
|
||||
// #ifdef DEBUG_FUNCTION_CALLS
|
||||
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: updateBounds");
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
if (left < mostLeft) {
|
||||
|
||||
|
@ -481,6 +481,7 @@ void updateBounds(int top, int bottom, int left, int right) {
|
|||
|
||||
mostBottom = bottom;
|
||||
}
|
||||
writeSerialPortDebug(boutRefNum, "END OF DEBUG_FUNCTION_CALLS: updateBounds");
|
||||
}
|
||||
|
||||
#ifdef COMMAND_CACHING
|
||||
|
@ -1181,10 +1182,10 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
|
|||
|
||||
CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L);
|
||||
|
||||
mostLeft = 1;
|
||||
mostLeft = WINDOW_WIDTH;
|
||||
mostBottom = 1;
|
||||
mostTop = WINDOW_HEIGHT;
|
||||
mostRight = WINDOW_WIDTH;
|
||||
mostRight = 1;
|
||||
|
||||
#ifdef PROFILING
|
||||
PROFILE_END("copy bits");
|
||||
|
|
Loading…
Reference in New Issue
Block a user