Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added monitor span support #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ namespace Wallpaper {

public static void main (string [] args) {

if(args[1] == "--help" || args[1] == "-h" || args.length != 2) {
print("Usage:\n\tanimated-wallpaper [FILE]");
if(args[1] == "--help" || args[1] == "-h" || args.length == 1) {
print("Usage:\n\tanimated-wallpaper [FILE] [FLAG]");
print("\n\t--span || -s To stretch video across all monitors\n");
return;
}

bool spanMonitors = false;
for(int i = 0; i < args.length; i++) {
if(args[i] == "--span" || args[i] == "-s") spanMonitors = true;
}

GtkClutter.init (ref args);
Gtk.init (ref args);
Gst.init (ref args);
Expand All @@ -37,7 +43,10 @@ namespace Wallpaper {
backgroundWindows = new BackgroundWindow[monitorCount];
string fileName = args[1];
for (int i = 0; i < monitorCount; ++i)
backgroundWindows[i] = new BackgroundWindow(i, fileName);
backgroundWindows[i] = new BackgroundWindow(i,
fileName,
monitorCount,
spanMonitors);

var mainSettings = Gtk.Settings.get_default ();
mainSettings.set("gtk-xft-antialias", 1, null);
Expand Down
18 changes: 11 additions & 7 deletions src/Playable.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ namespace Playable {

Clutter.Actor wallpaperActor = new Clutter.Actor();

public BackgroundWindow (int monitorIndex, string fileName) {
public BackgroundWindow (int monitorIndex,
string fileName,
int monitorCount,
bool spanMonitors) {

title = "Desktop";

// Get current monitor size
getMonitorSize(monitorIndex);
getMonitorSize(monitorIndex, monitorCount, spanMonitors);

embed = new GtkClutter.Embed() {width_request = screenWidth, height_request = screenHeight};
mainActor = embed.get_stage();
Expand Down Expand Up @@ -71,15 +74,16 @@ namespace Playable {
add(embed);
}

void getMonitorSize(int monitorIndex) {
void getMonitorSize(int monitorIndex, int monitorCount, bool spanMonitors) {

Rectangle rectangle;
var screen = Gdk.Screen.get_default ();

screen.get_monitor_geometry (monitorIndex, out rectangle);

screenHeight = rectangle.height;
screenWidth = rectangle.width;
if(spanMonitors) screenWidth = rectangle.width*monitorCount;
else screenWidth = rectangle.width;

move(rectangle.x, rectangle.y);

Expand All @@ -104,7 +108,7 @@ namespace Playable {
});

wallpaperActor.scale_y = 1.00f;
wallpaperActor.scale_x = 1.00f;
wallpaperActor.scale_x = 1.00f;

videoPlayback.set_filename(fileName);
videoPlayback.playing = true;
Expand All @@ -115,8 +119,8 @@ namespace Playable {

// void setImageWallpaper(string fileName) {
// wallpaperActor.scale_y = 1.05f;
// wallpaperActor.scale_x = 1.05f;
//
// wallpaperActor.scale_x = 1.05f;
//
// Gtk.Image image = new Gtk.Image.from_file(fileName);
// GtkClutter.Actor actor = new GtkClutter.Actor.with_contents(image);
// actor.set_size(screenWidth, screenHeight);
Expand Down