Move common structs to coords.h

The size, point and position structs were defined in common.h. Move them
to coords.h so that common.h could be used for generic code to be
included in all source files.
This commit is contained in:
Romain Vimont 2021-01-08 19:15:29 +01:00
parent 037be4af21
commit 6385b8c162
9 changed files with 28 additions and 27 deletions

View file

@ -1,30 +1,10 @@
#ifndef COMMON_H #ifndef COMMON_H
#define COMMON_H #define COMMON_H
#include <stdint.h>
#include "config.h" #include "config.h"
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
#define MIN(X,Y) (X) < (Y) ? (X) : (Y) #define MIN(X,Y) (X) < (Y) ? (X) : (Y)
#define MAX(X,Y) (X) > (Y) ? (X) : (Y) #define MAX(X,Y) (X) > (Y) ? (X) : (Y)
struct size {
uint16_t width;
uint16_t height;
};
struct point {
int32_t x;
int32_t y;
};
struct position {
// The video screen size may be different from the real device screen size,
// so store to which size the absolute position apply, to scale it
// accordingly.
struct size screen_size;
struct point point;
};
#endif #endif

View file

@ -8,7 +8,7 @@
#include "config.h" #include "config.h"
#include "android/input.h" #include "android/input.h"
#include "android/keycodes.h" #include "android/keycodes.h"
#include "common.h" #include "coords.h"
#define CONTROL_MSG_MAX_SIZE (1 << 18) // 256k #define CONTROL_MSG_MAX_SIZE (1 << 18) // 256k

24
app/src/coords.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef SC_COORDS
#define SC_COORDS
#include <stdint.h>
struct size {
uint16_t width;
uint16_t height;
};
struct point {
int32_t x;
int32_t y;
};
struct position {
// The video screen size may be different from the real device screen size,
// so store to which size the absolute position apply, to scale it
// accordingly.
struct size screen_size;
struct point point;
};
#endif

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "config.h" #include "config.h"
#include "common.h" #include "coords.h"
#include "util/net.h" #include "util/net.h"
#define DEVICE_NAME_FIELD_LENGTH 64 #define DEVICE_NAME_FIELD_LENGTH 64

View file

@ -6,7 +6,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "config.h" #include "config.h"
#include "common.h"
#include "controller.h" #include "controller.h"
#include "fps_counter.h" #include "fps_counter.h"
#include "scrcpy.h" #include "scrcpy.h"

View file

@ -7,7 +7,7 @@
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "config.h"
#include "common.h" #include "coords.h"
#include "scrcpy.h" #include "scrcpy.h"
#include "util/queue.h" #include "util/queue.h"

View file

@ -14,7 +14,6 @@
#endif #endif
#include "config.h" #include "config.h"
#include "common.h"
#include "compat.h" #include "compat.h"
#include "controller.h" #include "controller.h"
#include "decoder.h" #include "decoder.h"

View file

@ -6,7 +6,7 @@
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include "config.h" #include "config.h"
#include "common.h" #include "coords.h"
#include "opengl.h" #include "opengl.h"
struct video_buffer; struct video_buffer;

View file

@ -8,7 +8,6 @@
#include "config.h" #include "config.h"
#include "adb.h" #include "adb.h"
#include "common.h"
#include "scrcpy.h" #include "scrcpy.h"
#include "util/log.h" #include "util/log.h"
#include "util/net.h" #include "util/net.h"