Skip to content

Commit

Permalink
Updated Sample Code
Browse files Browse the repository at this point in the history
> change settingsservice in js service template
  - "settingsservice" was changed to run in session side.
  - Change it to systemservice/clock/getTime is in host side.
  - Change service's method name "locale" to "time"
> change rect size in built-in nativeqt app
- QRect set via geometry() is not working. Get the size from windowRect
> link the libEGL directly
  • Loading branch information
nickyzero committed Nov 16, 2020
1 parent 89873e7 commit 41da3cb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
13 changes: 6 additions & 7 deletions js-services/com.example.service.js/com_example_service_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ var service = new Service("com.example.service.js");

// A method that always returns the same value
service.register("hello", function(message) {
console.log("[com.example.service.js]", "SERVICE_METHOD_CALLED:hello");
message.respond({
answer: "Hello, JS Service!!"
});
});

// Call another service
service.register("locale", function(message) {
service.call("luna://com.webos.settingsservice/getSystemSettings", {"key":"localeInfo"}, function(m2) {
console.log("[com.example.service.js]", "LOCALE_CALLBACK : get locale response");
var response = "You appear to have your locale set to: " + m2.payload.settings.localeInfo.locales.UI;
message.respond({
message: response
});
service.register("time", function(message) {
service.call("luna://com.webos.service.systemservice/clock/getTime", {}, function(m2) {
console.log("[com.example.service.js]", "SERVICE_METHOD_CALLED:com.webos.service.systemservice/clock/getTime");
const response = "You appear to have your UTC set to: " + m2.payload.utc;
message.respond({message: response});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"com.example.service.js": [
"settings.read", "activities.manage"
"time", "activities.manage"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
#include <QtGui/QOpenGLPaintDevice>
#include <QtGui/QPainter>

MyOpenGLWindow::MyOpenGLWindow(QWindow *parent)
: QWindow(parent)
MyOpenGLWindow::MyOpenGLWindow(QRect rect)
: m_windowRect(rect)
, m_device(nullptr)
{
setSurfaceType(QWindow::OpenGLSurface);
Expand Down Expand Up @@ -82,7 +82,7 @@ void MyOpenGLWindow::render()
m_device->setSize(size() * devicePixelRatio());
m_device->setDevicePixelRatio(devicePixelRatio());

QRect rect = geometry();
QRect rect = QRect(0, 0, m_windowRect.width(), m_windowRect.height());
QPainter painter(m_device);

QFont font = painter.font();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MyOpenGLWindow : public QWindow, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit MyOpenGLWindow(QWindow *parent = 0);
MyOpenGLWindow(QRect rect);
~MyOpenGLWindow();

virtual void render();
Expand All @@ -73,6 +73,7 @@ class MyOpenGLWindow : public QWindow, protected QOpenGLFunctions
void exposeEvent(QExposeEvent *event) override;

private:
QRect m_windowRect;
QOpenGLContext *m_context;
QOpenGLPaintDevice *m_device;
};
Expand Down
2 changes: 1 addition & 1 deletion native-apps/built-in/com.example.app.nativeqt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char **argv)

QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
MyOpenGLWindow window;
MyOpenGLWindow window(screenGeometry);
window.resize(screenGeometry.width(), screenGeometry.height());
window.show();

Expand Down
5 changes: 1 addition & 4 deletions native-apps/external/com.sample.waylandegl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ include_directories(${WLCLIENT_INCLUDE_DIRS})
pkg_check_modules(WLEGL REQUIRED wayland-egl)
include_directories(${WLEGL_INCLUDE_DIRS})

pkg_check_modules(EGL REQUIRED egl)
include_directories(${EGL_INCLUDE_DIRS})

pkg_check_modules(GLESV2 REQUIRED glesv2)
include_directories(${GLESV2_INCLUDE_DIRS})

Expand All @@ -48,7 +45,7 @@ set_target_properties(${BIN_NAME} PROPERTIES LINKER_LANGUAGE C)
target_link_libraries (${BIN_NAME}
${WLCLIENT_LDFLAGS}
${WLEGL_LDFLAGS}
${EGL_LDFLAGS}
-lEGL
${GLESV2_LDFLAGS}
)

Expand Down

0 comments on commit 41da3cb

Please sign in to comment.