Skip to content

Commit

Permalink
Merge pull request #10 from AdrianVovk/split-files
Browse files Browse the repository at this point in the history
Center-view plugin
  • Loading branch information
ammen99 authored Jun 11, 2018
2 parents d1a2690 + fc228f7 commit d61dc90
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions plugins/single_plugins/center-view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <view.hpp>
#include <workspace-manager.hpp>
#include <signal-definitions.hpp>

class wayfire_center_view : public wayfire_plugin_t
{
signal_callback_t created_cb;

public:
void init(wayfire_config *config)
{
created_cb = [=] (signal_data *data)
{
auto view = get_signaled_view(data);
if (view->role == WF_VIEW_ROLE_TOPLEVEL && !view->parent && !view->fullscreen && !view->maximized)
{
wf_geometry workarea = output->workspace->get_workarea();
wf_geometry window = view->get_wm_geometry();
window.x = workarea.x + (workarea.width / 2) - (window.width / 2);
window.y = workarea.y + (workarea.height / 2) - (window.height / 2);
view->move(window.x, window.y);
}
};
output->connect_signal("map-view", &created_cb);
}
};

extern "C"
{
wayfire_plugin_t *newInstance()
{
return new wayfire_center_view();
}
}
1 change: 1 addition & 0 deletions plugins/single_plugins/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ oswitch = shared_module('oswitch', 'oswitch.cpp', include_dire
rotator = shared_module('rotator', 'rotator.cpp', include_directories: [wayfire_api_inc, wayfire_conf_inc], dependencies: [wlroots, pixman, wfconfig], install: true, install_dir: 'lib/wayfire/')
apps_logger = shared_module('apps-logger', 'apps-logger.cpp', include_directories: [wayfire_api_inc, wayfire_conf_inc], dependencies: [wlroots, pixman, wfconfig], install: true, install_dir: 'lib/wayfire/')
window_rules = shared_module('window-rules', 'window-rules.cpp', include_directories: [wayfire_api_inc, wayfire_conf_inc], dependencies: [wlroots, pixman, wfconfig], install: true, install_dir: 'lib/wayfire/')
center_view = shared_module('center-view', 'center-view.cpp', include_directories: [wayfire_api_inc, wayfire_conf_inc], dependencies: [wlroots, pixman, wfconfig], install: true, install_dir: 'lib/wayfire/')

0 comments on commit d61dc90

Please sign in to comment.