Something similar could be said about the UK. But they are actually more aggressive and Gibraltar harmful to the surrounding area (smuggling and off-shore societies).
UK makes claims about the surrounding waters (which as far as I know, they have no claim to) and it's very bullish about enforcing that right. Given the nationalistic derive UK is taking and the change in status because of Brexit, it is very likely that tensions will rise.
Gibraltar has been UK territory for longer than the US has existed. By all means grumble about it, but if you grumble about morocco claiming Melilla in the same breath and don’t see the hypocrisy you really need to try to take an objective look at your views.
If you want to draw comparisons with Melilla, it was an abandoned military plaza that was simply taken by the Castilian crown in the 15th century. It is not a colony, unlike Gibraltar (according to ONU). Morocco didn't exist as a clear political entity back then, so I am not sure what claims would they have to it.
And what I was "grumbling" about Morocco referred to the "Islote de Perejil", where Morocco claimed an inhabited island near Ceuta: https://en.wikipedia.org/wiki/Perejil_Island_crisis
And my personal views are that if Spain could easily get rid of Ceuta and Melilla most spaniards politicians would sign right of the bat. They are just a sinkhole of money, source of diplomatic tensions and immigration problems.
- Gibraltar is a potential choke point for the mediterranean if something happens in the Suez Canal.
- 3 nations (UK, Morocco, and Spain) have territorial waters on the strait. All three are NATO members, but the UK left the EU last month and cannot be considered as an ally for it gibraltar politics anymore...
- Marocco is claiming more territry waters both in the ocean side near canary islands, and in small islands Ceuta and Melilla. See Perejil Island incident (https://en.wikipedia.org/wiki/Perejil_Island).
Also, Spain sells a lot of weapons. Submarines are a good addition to the catalog.
- The nation of Morocco did not exist when Ceuta and Melilla became Portuguese and Spanish respectively, so I assume the only claim Morocco could have would be based on territorial integrity. They were also never part of the Spanish protectorate in Morocco, and are not recognised by the United Nations as colonies.
- On the other hand, Gibraltar has been classified by the United Nations as a Non-Self-Governing Territory subject to decolonisation. Furthermore, it considers Gibraltarians mere "settlers" and as such does not recognise their right to self-determination, and urges the governments of Spain and the UK to negotiate the decolonisation process between themselves.
Whether the UN's position is correct or not is whole different matter, my point is that given the UN's point of view, Spain's position on Gibraltar and Ceuta/Melilla is not contradictory.
Regarding the Canary Islands and "other African colonies", I'm not sure what you are referring to as the only inhabited territories Spain has in Africa are Ceuta, Melilla and the Canary Islands, and as far as I know nobody is claiming the Canary Islands.
I'm sorry, but this is fairly laughable - if you had any idea of the relationship between Spain and the UK over the last n decades, you'd know that Spain is the belligerant 'partner' in this relationship and has, for all but about 5 years around the turn of the millennium been apt to abuse the Gibraltar question as a temporary salve for whatever domestic political problem it is distracting its populace from.
It would be simpler to say that Spain is historically a naval power and has a lot of coastline, and leave it at that... .
I don’t think anyone is claiming that Spain has a serious blue-water Navy any more, or even aspires to have one.
I think Spain is up there as well ( https://en.wikipedia.org/wiki/Spanish_ship_Juan_Carlos_I )