Skip to content

Commit

Permalink
(#20) Split screen.c
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Sep 5, 2020
1 parent 3ab73d0 commit 17e3ccc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/screen.c → src/linux/screen.c
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
#include "screen.h"
#include "os.h"
#include "highlightwindow.h"
#include "../screen.h"
#include "../os.h"
#include "../highlightwindow.h"

#if defined(IS_MACOSX)
#include <ApplicationServices/ApplicationServices.h>
#elif defined(USE_X11)
#include <X11/Xlib.h>
#include "xdisplay.h"
#endif
#include <X11/Xlib.h>
#include "../xdisplay.h"

MMSize getMainDisplaySize(void)
{
#if defined(IS_MACOSX)
CGDirectDisplayID displayID = CGMainDisplayID();
return MMSizeMake(CGDisplayPixelsWide(displayID),
CGDisplayPixelsHigh(displayID));
#elif defined(USE_X11)
Display *display = XGetMainDisplay();
const int screen = DefaultScreen(display);

return MMSizeMake((size_t)DisplayWidth(display, screen),
(size_t)DisplayHeight(display, screen));
#elif defined(IS_WINDOWS)
return MMSizeMake((size_t)GetSystemMetrics(SM_CXSCREEN),
(size_t)GetSystemMetrics(SM_CYSCREEN));
#endif
}

bool pointVisibleOnMainDisplay(MMPoint point)
Expand Down
22 changes: 22 additions & 0 deletions src/macos/screen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "../screen.h"
#include "../os.h"
#include "../highlightwindow.h"

#include <ApplicationServices/ApplicationServices.h>

MMSize getMainDisplaySize(void)
{
CGDirectDisplayID displayID = CGMainDisplayID();
return MMSizeMake(CGDisplayPixelsWide(displayID),
CGDisplayPixelsHigh(displayID));
}

bool pointVisibleOnMainDisplay(MMPoint point)
{
MMSize displaySize = getMainDisplaySize();
return point.x < displaySize.width && point.y < displaySize.height;
}

void highlight(int32_t x, int32_t y, int32_t width, int32_t height, long duration, float opacity) {
showHighlightWindow(x, y, width, height, duration, opacity);
}
19 changes: 19 additions & 0 deletions src/win32/screen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../screen.h"
#include "../os.h"
#include "../highlightwindow.h"

MMSize getMainDisplaySize(void)
{
return MMSizeMake((size_t)GetSystemMetrics(SM_CXSCREEN),
(size_t)GetSystemMetrics(SM_CYSCREEN));
}

bool pointVisibleOnMainDisplay(MMPoint point)
{
MMSize displaySize = getMainDisplaySize();
return point.x < displaySize.width && point.y < displaySize.height;
}

void highlight(int32_t x, int32_t y, int32_t width, int32_t height, long duration, float opacity) {
showHighlightWindow(x, y, width, height, duration, opacity);
}

0 comments on commit 17e3ccc

Please sign in to comment.